Material filter #61
Open
feldoh wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces per-pawnkind material filtering for apparel/weapons (whitelist/blacklist), adds UI support (mode toggle, allowed-summary, warnings), and adds an optional “ignore price limits” fallback to avoid empty gear slots when budgets are too low.
Changes:
- Add apparel/weapon material rule fields to
PawnKindEdit, cache + apply them during vanilla generation (Harmony patches). - Extend editor UI to configure material rules (mode toggle, allowed summary, required-apparel warnings).
- Add a mod setting to optionally equip the cheapest allowed gear when budgets would otherwise leave slots empty, plus verbose logging.
Reviewed changes
Copilot reviewed 11 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Common/Languages/English/Keyed/FactionLoadout_Keys.xml | Adds new translation keys for material filters and ignore-price setting. |
| 1.6/Source/UISupport/EditTab.cs | Adds material mode toggle + allowed-summary UI helpers; extends def-ref list wrapper with warnings. |
| 1.6/Source/UISupport/DrawSupport/ListDrawSupport.cs | Adds per-row warning highlighting + tooltip support for def-ref lists. |
| 1.6/Source/UISupport/Dialog_FactionLoadout.cs | Adds “Ignore price limits” checkbox to settings dialog. |
| 1.6/Source/Tabs/WeaponTab.cs | Adds weapon material rule override UI + summary display. |
| 1.6/Source/Tabs/ApparelTab.cs | Adds apparel material rule override UI + summary display; adds required-apparel material incompatibility warnings. |
| 1.6/Source/PawnKindEdit.cs | Adds new serialized fields for apparel/weapon material lists + blacklist mode flags. |
| 1.6/Source/Patches/WeaponGenPatch.cs | Adds price-limit weapon fallback + applies weapon material rule in commonality patch. |
| 1.6/Source/Patches/ApparelGenPatch.cs | Adds price-limit torso fallback + applies apparel material rule in CanUsePair/CanUseStuff patches. |
| 1.6/Source/MySettings.cs | Adds IgnorePriceLimits setting persisted via Scribe. |
| 1.6/Source/DefCache.cs | Adds precomputed per-kind material-rule caches + summary helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR #61 review (Copilot): HandleWeaponPriceLimit / HandleApparelPriceLimit now early-return when both VerboseLogging and IgnorePriceLimits are off, avoiding the allWeaponPairs / allApparelPairs scan in the common case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR #61 review (Copilot): MaterialCategorySummary skips the HashSet + full StuffDefs scan in whitelist mode (uses the selected materials directly); ListDrawSupport warning highlight uses !string.IsNullOrEmpty so an empty-string warning draws no red box and registers no empty tooltip. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment on lines
+205
to
+206
| if (!pawn.RaceProps.ToolUser || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || pawn.WorkTagIsDisabled(WorkTags.Violent)) | ||
| return; |
Comment on lines
+207
to
+222
| private string RequiredApparelMaterialWarning(ThingDef item) | ||
| { | ||
| List<DefRef<ThingDef>> rule = Current.ApparelMaterials; | ||
| if (item == null || !item.MadeFromStuff || rule == null || rule.Count == 0) | ||
| return null; | ||
|
|
||
| bool blacklist = Current.ApparelMaterialsBlacklist; | ||
| foreach (ThingDef stuff in GenStuff.AllowedStuffsFor(item)) | ||
| { | ||
| bool listed = RuleContains(rule, stuff); | ||
| if (blacklist ? !listed : listed) | ||
| return null; // at least one allowed material can make this item | ||
| } | ||
|
|
||
| return "FactionLoadout_Materials_NoValidStuff".Translate(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.