public GoldfishModule(Pawn owner, bool fillExisting) { this.Owner = owner; if (fillExisting) { List <Thing> meleeWeapons; List <Thing> rangedWeapons; GettersFilters.getWeaponLists(out meleeWeapons, out rangedWeapons, Owner.inventory); foreach (Thing weapon in meleeWeapons) { AddSidearm(weapon.def); } foreach (Thing weapon in rangedWeapons) { AddSidearm(weapon.def); } if (owner.equipment != null && owner.equipment.Primary != null) { AddSidearm(owner.equipment.Primary.def); SetPrimary(owner.equipment.Primary.def, true); } else { SetPrimaryEmpty(true); } } }
private static void GetGizmos(Pawn __instance, ref IEnumerable <Gizmo> __result) { if (__instance.IsColonistPlayerControlled) { if (__instance.inventory != null) { List <Thing> rangedWeapons; List <Thing> meleeWeapons; GettersFilters.getWeaponLists(out rangedWeapons, out meleeWeapons, __instance.inventory); GoldfishModule pawnMemory = GoldfishModule.GetGoldfishForPawn(__instance); //if (pawnMemory == null) // return; if (rangedWeapons.Count > 0 || meleeWeapons.Count > 0 || (pawnMemory != null && pawnMemory.weapons.Count > 0)) { List <ThingDef> rangedWeaponMemories = new List <ThingDef>(); List <ThingDef> meleeWeaponMemories = new List <ThingDef>(); if (pawnMemory != null) { foreach (string weapon in pawnMemory.weapons) { ThingDef wepDef = DefDatabase <ThingDef> .GetNamedSilentFail(weapon); if (wepDef == null) { continue; } if (wepDef.IsMeleeWeapon) { meleeWeaponMemories.Add(wepDef); } else if (wepDef.IsRangedWeapon) { rangedWeaponMemories.Add(wepDef); } } } Gizmo_SidearmsList advanced = new Gizmo_SidearmsList(__instance, rangedWeapons, meleeWeapons, rangedWeaponMemories, meleeWeaponMemories); advanced.defaultLabel = "DrawSidearm_gizmoTitle".Translate(); //draft.hotKey = KeyBindingDefOf.CommandColonistDraft; advanced.defaultDesc = "DrawSidearm_gizmoTooltip".Translate(); List <Gizmo> results = new List <Gizmo>(); foreach (Gizmo gizmo in __result) { results.Add(gizmo); } results.Add(advanced); __result = results; } } } }