Skip to content

Material filter #61

Open
feldoh wants to merge 5 commits into
mainfrom
feature/material-filter
Open

Material filter #61
feldoh wants to merge 5 commits into
mainfrom
feature/material-filter

Conversation

@feldoh

@feldoh feldoh commented Jun 18, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread 1.6/Source/Patches/WeaponGenPatch.cs
Comment thread 1.6/Source/Patches/ApparelGenPatch.cs
Comment thread 1.6/Source/Tabs/WeaponTab.cs Outdated
Comment thread 1.6/Source/Tabs/ApparelTab.cs Outdated
Comment thread 1.6/Source/Tabs/ApparelTab.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 15 changed files in this pull request and generated 4 comments.

Comment thread 1.6/Source/Patches/WeaponGenPatch.cs
Comment thread 1.6/Source/Patches/WeaponGenPatch.cs
Comment thread 1.6/Source/Patches/ApparelGenPatch.cs
Comment thread 1.6/Source/Patches/ApparelGenPatch.cs
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 15 changed files in this pull request and generated 3 comments.

Comment thread 1.6/Source/DefCache.cs
Comment thread 1.6/Source/UISupport/DrawSupport/ListDrawSupport.cs
Comment thread 1.6/Source/UISupport/DrawSupport/ListDrawSupport.cs Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 15 changed files in this pull request and generated 2 comments.

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants