Skip to content

Commit

Permalink
added remove weapon trait debug action
Browse files Browse the repository at this point in the history
  • Loading branch information
LinnielDW committed Apr 23, 2023
1 parent 494e4d0 commit f06d364
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Binary file modified 1.4/Assemblies/MorePersonaTraits.dll
Binary file not shown.
25 changes: 25 additions & 0 deletions Source/DebugActions/DebugActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ private static void AddTrait(
weapon.TryGetComp<CompBladelinkWeapon>().RegainBond();
}
}

[DebugAction("PersonaWeapons", "[MPT] Remove Weapon Trait", true, actionType = DebugActionType.ToolMap, allowedGameStates = AllowedGameStates.PlayingOnMap)]
private static void RemoveWeaponTrait()
{
List<DebugMenuOption> list = new List<DebugMenuOption>();
var weapon = (ThingWithComps)Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).First(t => t is ThingWithComps comps && comps.TryGetComp<CompBladelinkWeapon>() != null);

foreach (var trait in weapon.TryGetComp<CompBladelinkWeapon>().TraitsListForReading)
{
list.Add(new DebugMenuOption(trait.defName, DebugMenuOptionMode.Action,
delegate { RemoveTrait(weapon, trait); }));
}

Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
}

private static void RemoveTrait(
ThingWithComps weapon,
WeaponTraitDef weaponTraitDef)
{
weapon.TryGetComp<CompBladelinkWeapon>().TempUnbond();
weapon.TryGetComp<CompBladelinkWeapon>().TraitsListForReading.Remove(weaponTraitDef);
if (weapon.TryGetComp<CompBladelinkWeapon>().TraitsListForReading.NullOrEmpty()) weapon.TryGetComp<CompBladelinkWeapon>().InitializeTraits();
weapon.TryGetComp<CompBladelinkWeapon>().RegainBond();
}

[DebugAction("PersonaWeapons", "[MPT] Reroll Weapon Traits", true, actionType = DebugActionType.ToolMap, allowedGameStates = AllowedGameStates.PlayingOnMap)]
private static void RerollTraits()
Expand Down

0 comments on commit f06d364

Please sign in to comment.