// The def's chance is the overall chance against the whole shot period. The combined probability // needs to be separated out for each shot in the burst. public override float GetRealChance(ThingWithComps thing, bool usePreModProps = false) { var comp = thing?.TryGetComp <CompLootAffixableThing>(); if (comp == null) { return(chance); } VerbProperties modVerbProps = usePreModProps ? comp.PrimaryVerbPropsFromDef : comp.PrimaryVerbProps; if (modVerbProps == null) { return(chance); } // Give one-use items a 100% chance if (modVerbProps.verbClass == typeof(Verb_ShootOneUse)) { return(1); } // 1 - (1 - chance) to the count-th root float realChance = 1f - Mathf.Pow(1f - chance, 1f / modVerbProps.burstShotCount); if (realChance >= 0.95f) { realChance = 1; } return(realChance); }
// Enhanced label with per-bullet chances public override TaggedString GetModifierChangeLabel(ThingWithComps thing) { VerbProperties modVerbProps = thing?.TryGetComp <CompLootAffixableThing>()?.PrimaryVerbProps; NamedArgument[] args = GetModifierChangeLabelArguments(thing); int shotCount = modVerbProps != null ? modVerbProps.burstShotCount : 0; float realChance = GetRealChance(thing); return (realChance >= 0.95f ? "RimLoot_ChangeProjectileModifierLabel_Permanent".Translate(args) : thing == null ? "RimLoot_ChangeProjectileModifierLabel_Chance".Translate(args) : shotCount > 1 ? "RimLoot_ChangeProjectileModifierLabel_ChanceBurst".Translate(args) : "RimLoot_ChangeProjectileModifierLabel_ChanceSingle".Translate(args) ); }
public static void EquipmentRemoved_Postfix(ThingWithComps eq, Pawn_EquipmentTracker __instance) { if (Base.IgnoredMods.Contains(eq.def.modContentPack.Name)) { return; } var comp = eq.TryGetComp <CompEquippable>(); if (comp == null) { return; } var manager = __instance.pawn?.Manager(); if (manager == null) { return; } foreach (var verb in comp.VerbTracker.AllVerbs) { manager.RemoveVerb(verb); } }
public static void OversizedWeapon(ThingWithComps weapon, float aimAngle, Verb verb, ref Vector3 origin) { OgsCompOversizedWeapon.CompOversizedWeapon compOversized = weapon.TryGetComp <OgsCompOversizedWeapon.CompOversizedWeapon>(); if (compOversized != null) { bool DualWeapon = compOversized.Props != null && compOversized.Props.isDualWeapon; Vector3 offsetMainHand = default(Vector3); Vector3 offsetOffHand = default(Vector3); float offHandAngle = aimAngle; float mainHandAngle = aimAngle; Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.SetAnglesAndOffsets(compOversized.parent, compOversized.parent, aimAngle, verb.Caster, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, true, DualWeapon && !compOversized.FirstAttack); if (DualWeapon) { Log.Message("Throwing flash for " + compOversized.parent.LabelCap + " offsetMainHand: " + offsetMainHand + " offsetOffHand: " + offsetOffHand + " Using " + (!compOversized.FirstAttack ? "OffHand" : "MainHand") + " FirstAttack: " + compOversized.FirstAttack); } origin += DualWeapon && !compOversized.FirstAttack ? offsetOffHand : offsetMainHand; // origin += compOversized.AdjustRenderOffsetFromDir(equippable.PrimaryVerb.CasterPawn, !compOversized.FirstAttack); if (compOversized.Props.isDualWeapon) { compOversized.FirstAttack = !compOversized.FirstAttack; } } }
/// <summary> /// From the list of available Things, add the compatible subparts to the item /// </summary> /// <param name="item">The item to add the subparts to</param> /// <param name="available">The available things to add</param> /// <param name="reset">Should it reset the list of subparts in the item</param> public static void AddSubparts(ThingWithComps item, List <Thing> available, bool reset = true) { CompIncludedChildParts comp = item.TryGetComp <CompIncludedChildParts>(); if (comp != null) { if (reset) { comp.IncludedParts.Clear(); } foreach (ThingDef missing in comp.MissingParts) { Thing match = available.Find(x => x.def == missing); if (match != null) { available.Remove(match); comp.AddPart(match); } } } }
protected void AddAvailableAmmoFor(ThingWithComps eq) { if (eq == null || availableDefs == null) { return; } CompAmmoUser compAmmo = eq.TryGetComp <CompAmmoUser>(); if (compAmmo != null && !compAmmo.Props.ammoSet.ammoTypes.NullOrEmpty()) { List <ThingDef> listammo = (from ThingDef g in compAmmo.Props.ammoSet.ammoTypes select g).ToList <ThingDef>(); ThingDef randomammo = GenCollection.RandomElement <ThingDef>(listammo); if (randomammo.canBeSpawningInventory) { availableDefs.Add(randomammo); } else { return; } } }
// Affix cost needs to be based on whether the source projectile actual does more damage than the destination public override float GetNewAffixCost(ThingWithComps thing, float affixCost) { var comp = thing.TryGetComp <CompLootAffixableThing>(); VerbProperties verbProps = comp.PrimaryVerbPropsFromDef; var projProps = verbProps.defaultProjectile.projectile; var modProjProps = ((ThingDef)resolvedDef).projectile; float baseDamage = projProps.damageDef.harmsHealth == false ? 0f : projProps.GetDamageAmount(thing); float modDamage = modProjProps.damageDef.harmsHealth == false ? 0f : modProjProps.GetDamageAmount(thing); float realChance = GetRealChance(thing, true); // can't use other affixes to calculate chance while affixes are being applied float totalDamage = baseDamage * (1 - realChance) + modDamage * realChance; float factor = baseDamage != 0f ? totalDamage / baseDamage : 100f; // higher factor = positive effect on weapon // https://www.desmos.com/calculator/qbe15qrcpu // affix cost needs to be negative on fractional factors float newAffixCost; newAffixCost = Mathf.Log10(factor) * 10; newAffixCost = Mathf.Clamp(newAffixCost, -4, 4); // if it's more dangerous, it shouldn't be dynamic return(Mathf.RoundToInt(newAffixCost)); }
public static void TryStartCastOn_RapidFire_Postfix(ref Verb __instance, LocalTargetInfo castTarg, float __state) { List <Type> types = typeof(Verb_LaunchProjectile).AllSubclassesNonAbstract().ToList(); types.Add(typeof(Verb_LaunchProjectile)); List <Type> nottypes = typeof(AbilityUser.Verb_UseAbility).AllSubclassesNonAbstract().ToList(); nottypes.Add(typeof(AbilityUser.Verb_UseAbility)); if (!types.Contains(__instance.GetType()) || nottypes.Contains(__instance.GetType())) { /* * List<string> listl = new List<string>(); * types.ForEach(x => listl.Add(x.Name)); * Log.Message(string.Format("Mismatched Verbtype: {0}, needs {1}", __instance.GetType(), listl.ToCommaList())); */ return; } if (__instance.EquipmentSource != null) { ThingWithComps gun = __instance.EquipmentSource; CompEquippable compeq = gun.TryGetComp <CompEquippable>(); if (!__instance.EquipmentSource.AllComps.NullOrEmpty()) { if (__instance.EquipmentSource.GetComp <CompWeapon_GunSpecialRules>() != null) { if (__instance.EquipmentSource.GetComp <CompWeapon_GunSpecialRules>() is CompWeapon_GunSpecialRules GunExt) { if (GunExt.OriginalwarmupTime != 0) { __instance.verbProps.warmupTime = (float)GunExt.OriginalwarmupTime; } } } } // Log.Message(string.Format("postfix Instance modified Values, Warmup: {0}, ticksbetween: {1}, cooldown: {2}", __instance.verbProps.warmupTime, __instance.verbProps.ticksBetweenBurstShots, __instance.verbProps.defaultCooldownTime)); } }
static public bool ShouldReload(Pawn p) { //For mechanoids replace the check of is p.RaceProps.HumanLike by custom logic if (p.RaceProps.IsMechanoid && p.IsHacked()) { //return true when a mechanoid is hacked and does not have much ammo. CompInventory inventory = p.TryGetComp <CompInventory>(); ThingWithComps primaryEq = p.equipment.Primary; if (inventory != null && primaryEq != null) { CompAmmoUser ammoUser = primaryEq.TryGetComp <CompAmmoUser>(); if (ammoUser != null) { int ammoCount = inventory.AmmoCountOfDef(ammoUser.CurrentAmmo); int minAmmo = ammoUser.Props.magazineSize == 0 ? 10 : ammoUser.Props.magazineSize; //No magic numbers? if (ammoCount < minAmmo) { return(true); } } } } return(p.RaceProps.Humanlike); }
public static void AddEquipment_PostFix(Pawn_EquipmentTracker __instance, ThingWithComps newEq) { Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_EquipmentTracker), "pawn").GetValue(__instance); CompLightsaberActivatableEffect lightsaberEffect = newEq.TryGetComp <CompLightsaberActivatableEffect>(); if (lightsaberEffect != null) { if (pawn != null) { if (pawn.Faction != null) { if (pawn.Faction != Faction.OfPlayerSilentFail) { CompCrystalSlotLoadable crystalSlot = newEq.GetComp <CompCrystalSlotLoadable>(); if (crystalSlot != null) { CrystalSlotter(crystalSlot, lightsaberEffect); } } } } } }
static void DropDownThingMenu(object tab, Thing thing) { Pawn SelPawnForGear = (Pawn)LSelPawnForGear.GetValue(tab); Pawn SelPawn = (Pawn)LSelPawn.GetValue(tab); bool canControl = (bool)LCanControl.GetValue(tab); List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate() { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null, 0f, null, null)); //bool canControl = this.CanControl; if (canControl) { ThingWithComps eq = thing as ThingWithComps; bool flag10 = eq != null && eq.TryGetComp <CompEquippable>() != null; if (flag10) { object comp = SelPawnForGear.getCompInventory(); CompBiocodable compBiocodable = eq.TryGetComp <CompBiocodable>(); bool flag11 = comp != null; if (flag11) { string value = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); bool flag12 = compBiocodable != null && compBiocodable.Biocoded && compBiocodable.CodedPawn != SelPawnForGear; FloatMenuOption item; if (flag12) { item = new FloatMenuOption("CannotEquip".Translate(value) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag13 = SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear); if (flag13) { TaggedString t = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(value) : "CannotEquip".Translate(value); item = new FloatMenuOption(t + ": " + "CE_CannotChangeEquipment".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag14 = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null; if (flag14) { item = new FloatMenuOption("CE_PutAway".Translate(value), delegate() { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); }, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag15 = !SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation); if (flag15) { item = new FloatMenuOption("CannotEquip".Translate(value), null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text4 = "Equip".Translate(value); bool flag16 = eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler); if (flag16) { text4 = text4 + " " + "EquipWarningBrawler".Translate(); } item = new FloatMenuOption(text4, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate() { CEAccess.trySwitchToWeapon(comp, eq); }), MenuOptionPriority.Default, null, null, 0f, null, null); } } } } list.Add(item); } } //Pawn selPawnForGear = SelPawnForGear; //?? List <Apparel> list2; if (SelPawnForGear == null) { list2 = null; } else { Pawn_ApparelTracker apparel2 = SelPawnForGear.apparel; list2 = ((apparel2 != null) ? apparel2.WornApparel : null); } List <Apparel> list3 = list2; using (List <Apparel> .Enumerator enumerator = list3.GetEnumerator()) { while (enumerator.MoveNext()) { Apparel apparel = enumerator.Current; CompReloadable compReloadable = apparel.TryGetComp <CompReloadable>(); bool flag17 = compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true); if (flag17) { bool flag18 = !SelPawnForGear.Drafted; if (flag18) { FloatMenuOption item2 = new FloatMenuOption("CE_ReloadApparel".Translate(apparel.Label, thing.Label), delegate() { SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing), JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null); list.Add(item2); } } } } bool flag19 = canControl && thing.IngestibleNow && SelPawn.RaceProps.CanEverEat(thing); if (flag19) { Action action = delegate() { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); LInterfaceIngest.Invoke(tab, new object[] { thing }); }; string text5 = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); bool flag20 = SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug; if (flag20) { List <FloatMenuOption> list4 = list; string str = text5; string str2 = ": "; TraitDegreeData traitDegreeData = (from x in TraitDefOf.DrugDesire.degreeDatas where x.degree == -1 select x).First <TraitDegreeData>(); list4.Add(new FloatMenuOption(str + str2 + ((traitDegreeData != null) ? traitDegreeData.label : null), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { list.Add(new FloatMenuOption(text5, action, MenuOptionPriority.Default, null, null, 0f, null, null)); } } bool flag21 = SelPawnForGear.isItemQuestLocked(eq); if (flag21) { list.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { list.Add(new FloatMenuOption("DropThing".Translate(), delegate() { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); LInterfaceDrop.Invoke(tab, new object[] { thing }); }, MenuOptionPriority.Default, null, null, 0f, null, null)); list.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), delegate() { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceDropHaul(SelPawnForGear, thing, SelPawn); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } bool flag22 = canControl && (bool)LHoldTrackerIsHeld.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerIsHeld(thing); if (flag22) { Action action2 = delegate() { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); LHoldTrackerForget.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerForget(thing); }; list.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), action2, MenuOptionPriority.Default, null, null, 0f, null, null)); } } FloatMenu window = new FloatMenu(list, thing.LabelCap, false); Find.WindowStack.Add(window); }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null)); Text.WordWrap = true; string text2 = string.Concat(new object[] { thing.LabelCap, "\n", thing.DescriptionDetailed, "\n", thing.GetWeightAndBulkTip() }); if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", "HitPointsBasic".Translate().CapitalizeFirst(), ": ", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(thingLabelRect, text2); y += 28f; // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); CompBiocodable compBiocoded = eq.TryGetComp <CompBiocodable>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null); } else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null); } else { string equipOptionLabel = "Equip".Translate(eqLabel); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption( equipOptionLabel, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action dropApparel = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); }; Action dropApparelHaul = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }; if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceIngest(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug) { floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null)); } else { floatOptionList.Add(new FloatMenuOption(label, eatFood)); } } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel)); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), dropApparelHaul)); if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
protected override Job TryGiveJob(Pawn pawn) { if (!Controller.settings.EnableAmmoSystem || !Controller.settings.AutoTakeAmmo) { return(null); } if (!pawn.RaceProps.Humanlike || (pawn.story != null && pawn.story.WorkTagIsDisabled(WorkTags.Violent))) { return(null); } if (pawn.Faction.IsPlayer && pawn.Drafted) { return(null); } if (!Rand.MTBEventOccurs(60, 1, 30)) { return(null); } // Log.Message(pawn.ToString() + " - priority:" + (GetPriorityWork(pawn)).ToString() + " capacityWeight: " + pawn.TryGetComp<CompInventory>().capacityWeight.ToString() + " currentWeight: " + pawn.TryGetComp<CompInventory>().currentWeight.ToString() + " capacityBulk: " + pawn.TryGetComp<CompInventory>().capacityBulk.ToString() + " currentBulk: " + pawn.TryGetComp<CompInventory>().currentBulk.ToString()); var brawler = (pawn.story != null && pawn.story.traits != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)); CompInventory inventory = pawn.TryGetComp <CompInventory>(); bool hasPrimary = (pawn.equipment != null && pawn.equipment.Primary != null); CompAmmoUser primaryammouser = hasPrimary ? pawn.equipment.Primary.TryGetComp <CompAmmoUser>() : null; if (inventory != null) { // Prefer ranged weapon in inventory if (!pawn.Faction.IsPlayer && hasPrimary && pawn.equipment.Primary.def.IsMeleeWeapon && !brawler) { if ((pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= pawn.skills.GetSkill(SkillDefOf.Melee).Level || pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= 6)) { ThingWithComps InvListGun3 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null && thing.TryGetComp <CompAmmoUser>().HasAmmoOrMagazine); if (InvListGun3 != null) { inventory.TrySwitchToWeapon(InvListGun3); } } } // Drop excess ranged weapon if (!pawn.Faction.IsPlayer && primaryammouser != null && GetPriorityWork(pawn) == WorkPriority.Unloading && inventory.rangedWeaponList.Count >= 1) { Thing ListGun = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (ListGun != null) { Thing ammoListGun = null; if (!ListGun.TryGetComp <CompAmmoUser>().HasAmmoOrMagazine) { foreach (AmmoLink link in ListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { if (inventory.ammoList.Find(thing => thing.def == link.ammo) == null) { ammoListGun = ListGun; break; } } } if (ammoListGun != null) { Thing droppedWeapon; if (inventory.container.TryDrop(ListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ListGun.stackCount, out droppedWeapon)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, droppedWeapon, 30, true)); } } } } // Find and drop not need ammo from inventory if (!pawn.Faction.IsPlayer && hasPrimary && inventory.ammoList.Count > 1 && GetPriorityWork(pawn) == WorkPriority.Unloading) { Thing WrongammoThing = null; WrongammoThing = primaryammouser != null ? inventory.ammoList.Find(thing => !primaryammouser.Props.ammoSet.ammoTypes.Any(a => a.ammo == thing.def)) : inventory.ammoList.RandomElement <Thing>(); if (WrongammoThing != null) { Thing InvListGun = inventory.rangedWeaponList.Find(thing => hasPrimary && thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (InvListGun != null) { Thing ammoInvListGun = null; foreach (AmmoLink link in InvListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun = inventory.ammoList.Find(thing => thing.def == link.ammo); break; } if (ammoInvListGun != null && ammoInvListGun != WrongammoThing) { Thing droppedThingAmmo; if (inventory.container.TryDrop(ammoInvListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ammoInvListGun.stackCount, out droppedThingAmmo)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } else { Thing droppedThing; if (inventory.container.TryDrop(WrongammoThing, pawn.Position, pawn.Map, ThingPlaceMode.Near, WrongammoThing.stackCount, out droppedThing)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } } Room room = RegionAndRoomQuery.RoomAtFast(pawn.Position, pawn.Map); // Find weapon in inventory and try to switch if any ammo in inventory. if (GetPriorityWork(pawn) == WorkPriority.Weapon && !hasPrimary) { ThingWithComps InvListGun2 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null); if (InvListGun2 != null) { Thing ammoInvListGun2 = null; foreach (AmmoLink link in InvListGun2.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun2 = inventory.ammoList.Find(thing => thing.def == link.ammo); break; } if (ammoInvListGun2 != null) { inventory.TrySwitchToWeapon(InvListGun2); } } // Find weapon with near ammo for ai. if (!pawn.Faction.IsPlayer) { Predicate <Thing> validatorWS = (Thing w) => w.def.IsWeapon && w.MarketValue > 500 && pawn.CanReserve(w, 1) && (DangerInPosRadius(pawn, w.Position, pawn.Map, 30f).Count() <= 0 ? pawn.Position.InHorDistOf(w.Position, 25f) : pawn.Position.InHorDistOf(w.Position, 6f)) && pawn.CanReach(w, PathEndMode.Touch, Danger.Deadly, true) && (pawn.Faction.HostileTo(Faction.OfPlayer) || pawn.Faction == Faction.OfPlayer || !pawn.Map.areaManager.Home[w.Position]); // generate a list of all weapons (this includes melee weapons) List <Thing> allWeapons = ( from w in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorWS(w) orderby w.MarketValue - w.Position.DistanceToSquared(pawn.Position) * 2f descending select w ).ToList(); // now just get the ranged weapons out... List <Thing> rangedWeapons = allWeapons.Where(w => w.def.IsRangedWeapon).ToList(); if (!rangedWeapons.NullOrEmpty()) { foreach (Thing thing in rangedWeapons) { if (thing.TryGetComp <CompAmmoUser>() == null) { // pickup a non-CE ranged weapon... int numToThing = 0; if (inventory.CanFitInInventory(thing, out numToThing)) { return(new Job(JobDefOf.Equip, thing) { checkOverrideOnExpire = true, expiryInterval = 100 }); } } else { // pickup a CE ranged weapon... List <ThingDef> thingDefAmmoList = thing.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes.Select(g => g.ammo as ThingDef).ToList(); Predicate <Thing> validatorA = (Thing t) => t.def.category == ThingCategory.Item && t is AmmoThing && pawn.CanReserve(t, 1) && (DangerInPosRadius(pawn, t.Position, pawn.Map, 30f).Count() <= 0 ? pawn.Position.InHorDistOf(t.Position, 25f) : pawn.Position.InHorDistOf(t.Position, 6f)) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && (pawn.Faction.HostileTo(Faction.OfPlayer) || pawn.Faction == Faction.OfPlayer || !pawn.Map.areaManager.Home[t.Position]); List <Thing> thingAmmoList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorA(t) select t ).ToList(); if (thingAmmoList.Count > 0 && thingDefAmmoList.Count > 0) { int desiredStackSize = thing.TryGetComp <CompAmmoUser>().Props.magazineSize * 2; Thing th = thingAmmoList.FirstOrDefault(x => thingDefAmmoList.Contains(x.def) && x.stackCount > desiredStackSize); if (th != null) { int numToThing = 0; if (inventory.CanFitInInventory(thing, out numToThing)) { return(new Job(JobDefOf.Equip, thing) { checkOverrideOnExpire = true, expiryInterval = 100 }); } } } } } } // else if no ranged weapons with nearby ammo was found, lets consider a melee weapon. if (allWeapons != null && allWeapons.Count > 0) { // since we don't need to worry about ammo, just pick one. Thing meleeWeapon = allWeapons.FirstOrDefault(w => !w.def.IsRangedWeapon && w.def.IsMeleeWeapon); if (meleeWeapon != null) { return(new Job(JobDefOf.Equip, meleeWeapon) { checkOverrideOnExpire = true, expiryInterval = 100 }); } } } } // Find ammo if ((GetPriorityWork(pawn) == WorkPriority.Ammo || GetPriorityWork(pawn) == WorkPriority.LowAmmo) && primaryammouser != null) { List <ThingDef> curAmmoList = (from AmmoLink g in primaryammouser.Props.ammoSet.ammoTypes select g.ammo as ThingDef).ToList(); if (curAmmoList.Count > 0) { Predicate <Thing> validator = (Thing t) => t is AmmoThing && pawn.CanReserve(t, 1) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && ((pawn.Faction.IsPlayer && !ForbidUtility.IsForbidden(t, pawn)) || (!pawn.Faction.IsPlayer && DangerInPosRadius(pawn, t.Position, Find.VisibleMap, 30f).Count() <= 0 ? pawn.Position.InHorDistOf(t.Position, 25f) : pawn.Position.InHorDistOf(t.Position, 6f))) && (pawn.Faction.HostileTo(Faction.OfPlayer) || pawn.Faction == Faction.OfPlayer || !pawn.Map.areaManager.Home[t.Position]); List <Thing> curThingList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validator(t) select t ).ToList(); foreach (Thing th in curThingList) { foreach (ThingDef thd in curAmmoList) { if (thd == th.def) { //Defence from low count loot spam float thw = (th.GetStatValue(CE_StatDefOf.Bulk)) * th.stackCount; if (thw > 0.5f) { if (pawn.Faction.IsPlayer) { int SearchRadius = 0; if (GetPriorityWork(pawn) == WorkPriority.LowAmmo) { SearchRadius = 70; } else { SearchRadius = 30; } Thing closestThing = GenClosest.ClosestThingReachable( pawn.Position, pawn.Map, ThingRequest.ForDef(th.def), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.None, TraverseMode.ByPawn), SearchRadius, x => !x.IsForbidden(pawn) && pawn.CanReserve(x)); if (closestThing != null) { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = numToCarry }); } } } else { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = Mathf.RoundToInt(numToCarry * 0.8f), expiryInterval = 150, checkOverrideOnExpire = true }); } } } } } } } } /* * if (!pawn.Faction.IsPlayer && pawn.apparel != null && GetPriorityWork(pawn) == WorkPriority.Apparel) * { * if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Torso)) * { * Apparel apparel = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Torso); * if (apparel != null) * { * int numToapparel = 0; * if (inventory.CanFitInInventory(apparel, out numToapparel)) * { * return new Job(JobDefOf.Wear, apparel) * { * ignoreForbidden = true * }; * } * } * } * if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Legs)) * { * Apparel apparel2 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Legs); * if (apparel2 != null) * { * int numToapparel2 = 0; * if (inventory.CanFitInInventory(apparel2, out numToapparel2)) * { * return new Job(JobDefOf.Wear, apparel2) * { * ignoreForbidden = true * }; * } * } * } * if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.FullHead)) * { * Apparel apparel3 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.FullHead); * if (apparel3 != null) * { * int numToapparel3 = 0; * if (inventory.CanFitInInventory(apparel3, out numToapparel3)) * { * return new Job(JobDefOf.Wear, apparel3) * { * ignoreForbidden = true, * locomotionUrgency = LocomotionUrgency.Sprint * }; * } * } * } * } */ return(null); } return(null); }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { var dropForbidden = IsItemDropForbidden(thing); Color color = dropForbidden ? Color.grey : Color.white; Color mouseoverColor = dropForbidden ? Color.grey : GenUI.MouseoverColor; Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, dropForbidden ? "DropThingLocked".Translate() : "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop, color, mouseoverColor) && !dropForbidden) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null)); Text.WordWrap = true; string text2 = string.Concat(new object[] { thing.LabelCap, "\n", thing.DescriptionDetailed, "\n", thing.GetWeightAndBulkTip() }); if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", "HitPointsBasic".Translate().CapitalizeFirst(), ": ", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(thingLabelRect, text2); y += 28f; // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); CompBiocodable compBiocoded = eq.TryGetComp <CompBiocodable>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null); } else if (SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear)) { var forbiddenEquipOrPutAway = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(eqLabel) : "CannotEquip".Translate(eqLabel); equipOption = new FloatMenuOption(forbiddenEquipOrPutAway + ": " + "CE_CannotChangeEquipment".Translate(), null); } else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null); } else { string equipOptionLabel = "Equip".Translate(eqLabel); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption( equipOptionLabel, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } //Reload apparel option IEnumerable <Apparel> worn_apparel = SelPawnForGear?.apparel?.WornApparel ?? Enumerable.Empty <Apparel>(); foreach (var apparel in worn_apparel) { var compReloadable = apparel.TryGetComp <CompReloadable>(); if (compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true)) { if (!SelPawnForGear.Drafted) //TODO-1.2 This should be doable for drafted pawns as well, but the job does nothing. Figure out what's wrong and remove this condition. { FloatMenuOption reloadApparelOption = new FloatMenuOption( "CE_ReloadApparel".Translate(apparel.Label, thing.Label), new Action(delegate { //var reloadJob = JobMaker.MakeJob(JobDefOf.Reload, apparel, thing); //SelPawnForGear.jobs.StartJob(reloadJob, JobCondition.InterruptForced, null, SelPawnForGear.CurJob?.def != reloadJob.def, true); SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing)); }) ); floatOptionList.Add(reloadApparelOption); } } } // Consume option if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceIngest(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug) { floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null)); } else { floatOptionList.Add(new FloatMenuOption(label, eatFood)); } } // Drop, and drop&haul options if (IsItemDropForbidden(eq)) { floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null)); floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null)); } else { floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); }))); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }))); } // Stop holding in inventory option if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
public static IEnumerable <ThingDef> NeedsAmmunition(Pawn pawn) { if (pawn.Dead) { yield break; } if (pawn.NonHumanlikeOrWildMan()) { yield break; } if (pawn.TryGetComp <CompAbilityUserAura>() != null && pawn.TryGetComp <CompAbilityUserAura>().AbilityData != null) { foreach (AbilitySemblance abilitySemblance in pawn.TryGetComp <CompAbilityUserAura>().AbilityData.AllPowers) { if (abilitySemblance.SemblanceDef.usesAmmunition != null) { yield return(abilitySemblance.SemblanceDef.usesAmmunition); } } } if (pawn.story != null && pawn.story.traits.HasTrait(RWBYDefOf.Semblance_Hazel)) { yield return(RWBYDefOf.FireDustCrystal); yield return(RWBYDefOf.IceDustCrystal); yield return(RWBYDefOf.LightningDustCrystal); yield return(RWBYDefOf.GravityDustCrystal); yield return(RWBYDefOf.HardLightDustCrystal); } if (pawn.equipment.Primary != null && pawn.equipment.Primary.TryGetComp <CompWeaponTransform>() != null) { foreach (CompWeaponTransform thingComp in pawn.equipment.Primary.AllComps.FindAll(c => c.GetType().Equals(typeof(CompWeaponTransform)))) { if (thingComp.Props.usesAmmunition != null) { yield return(thingComp.Props.usesAmmunition); } } } if (pawn.equipment.Primary != null && pawn.equipment.Primary.TryGetComp <CompWeaponProjectile>() != null) { foreach (CompWeaponProjectile thingComp in pawn.equipment.Primary.AllComps.FindAll(c => c.GetType().Equals(typeof(CompWeaponProjectile)))) { if (thingComp.Props.usesAmmunition != null) { yield return(thingComp.Props.usesAmmunition); } } } ThingWithComps thingWithComps1 = pawn.equipment.AllEquipmentListForReading.Find(t => t.def == RWBYDefOf.RWBY_Anesidora_Camera); if (thingWithComps1 != null) { yield return(thingWithComps1.TryGetComp <CompTakePhoto>().Props.usesAmmunition); } ThingWithComps thingWithComps2 = pawn.equipment.AllEquipmentListForReading.Find(t => t.def == RWBYDefOf.RWBY_Anesidora_Box); if (thingWithComps2 != null) { yield return(thingWithComps2.TryGetComp <CompTakePhoto>().Props.usesAmmunition); } yield break; }
public static bool IsSilverTreated(this ThingWithComps thing) { return(thing?.TryGetComp <CompSilverTreated>() is { treated : true } ||
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedNullOrForbidden(TargetIndex.B); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1)); yield return(Toils_Reserve.ReserveQueue(TargetIndex.A, 1)); yield return(Toils_Reserve.Reserve(TargetIndex.B, 10, 1)); yield return(Toils_Reserve.ReserveQueue(TargetIndex.B, 1)); Toil toil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A); yield return(toil); yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true)); yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toil, TargetIndex.A)); Toil toil2 = Toils_Goto.Goto(TargetIndex.B, PathEndMode.ClosestTouch); yield return(toil2); Toil toil3 = new Toil(); toil3.defaultCompleteMode = ToilCompleteMode.Delay; toil3.defaultDuration = 500; toil3.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); yield return(toil3); yield return(new Toil { initAction = delegate { ShipBase ship = (ShipBase)TargetB.Thing; ThingWithComps thing = (ThingWithComps)TargetA.Thing; CompShipWeapon comp = thing.TryGetComp <CompShipWeapon>(); Action action = delegate { if (comp != null) { switch (comp.SProps.weaponSystemType) { case WeaponSystemType.LightCaliber: { if (ship.TryInstallTurret(comp)) { this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing); ship.weaponsToInstall.Remove(comp.slotToInstall); } break; } case WeaponSystemType.HeavyCaliber: { break; } case WeaponSystemType.Bombing: { WeaponSystemShipBomb bomb = thing as WeaponSystemShipBomb; if (ship.TryInstallPayload(bomb, comp)) { this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing); ship.weaponsToInstall.Remove(comp.slotToInstall); } break; } } } }; action(); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield break; }
public static bool IsSilverTreated(this ThingWithComps thing) { return((thing?.TryGetComp <CompSilverTreated>() is CompSilverTreated t && t.treated) || ((thing?.def?.IsMeleeWeapon ?? false) && (thing?.Stuff == ThingDefOf.Silver))); }
public Job TryEquipFreeTool(Pawn pawn) { // find proper tools of the specific work type IEnumerable<Thing> availableTools = Find.ListerThings.AllThings.FindAll( tool => IsProperTool(tool) && !tool.IsForbidden(pawn.Faction) && pawn.CanReserveAndReach(tool, PathEndMode.ClosestTouch, pawn.NormalMaxDanger())); if (availableTools.Any()) { // find closest reachable tool of the specific work type closestAvailableTool = GenClosest.ClosestThing_Global(pawn.Position, availableTools) as ThingWithComps; if (closestAvailableTool != null) { // if pawn has equipped weapon, put it in inventory if (pawn.equipment.Primary != null) { previousPawnWeapons.Add(pawn.equipment.Primary, pawn); ThingWithComps leftover; pawn.equipment.TryTransferEquipmentToContainer(pawn.equipment.Primary, pawn.inventory.container, out leftover); } // reserve and set as auto equipped pawn.Reserve(closestAvailableTool); closestAvailableTool.TryGetComp<CompTool>().wasAutoEquipped = true; return new Job(JobDefOf.Equip, closestAvailableTool); } } return null; }
// Verse.Pawn_EquipmentTracker public static bool TryDropEquipment_PreFix(ThingWithComps eq, out ThingWithComps resultingEq, ref bool __result) { resultingEq = null; return(__result = (!(!eq?.TryGetComp <CompInstalledPart>()?.uninstalled) ?? true)); }
public static void TryStartCastOn_RapidFire_Prefix(ref Verb __instance, LocalTargetInfo castTarg, float __state) { /* * List<Type> types = typeof(Verb_LaunchProjectile).AllSubclassesNonAbstract().ToList(); * types.Add(typeof(Verb_LaunchProjectile)); * List<Type> nottypes = typeof(AbilityUser.Verb_UseAbility).AllSubclassesNonAbstract().ToList(); * nottypes.Add(typeof(AbilityUser.Verb_UseAbility)); * if (!types.Contains(__instance.GetType()) || nottypes.Contains(__instance.GetType())) * { * return; * } */ if (__instance.GetType() != typeof(Verb_Shoot) && __instance.GetType() != typeof(Verb_ShootEquipment)) { return; } if (__instance.EquipmentSource != null) { ThingWithComps gun = __instance.EquipmentSource; CompEquippable compeq = gun.TryGetComp <CompEquippable>(); if (!__instance.EquipmentSource.AllComps.NullOrEmpty()) { if (__instance.EquipmentSource.GetComp <CompWeapon_GunSpecialRules>() != null) { if (__instance.EquipmentSource.GetComp <CompWeapon_GunSpecialRules>() is CompWeapon_GunSpecialRules GunExt) { // Log.Message(string.Format("prefix pre-modified Values, Warmup: {0}, ticksbetween: {1}, cooldown: {2}, last move tick: {3}", gun.def.Verbs[0].warmupTime, gun.def.Verbs[0].ticksBetweenBurstShots, gun.def.Verbs[0].defaultCooldownTime, GunExt.LastMovedTick)); if (GunExt.RapidFire) { if (__instance.caster.Position.InHorDistOf(castTarg.Cell, __instance.verbProps.range / 2)) { if (GunExt.DualFireMode && GunExt.Toggled) { __instance.verbProps.warmupTime = GunExt.Props.VerbEntries[1].VerbProps.warmupTime / 2; } else { __instance.verbProps.warmupTime = GunExt.OriginalwarmupTime / 2; } } else { if (GunExt.DualFireMode && GunExt.Toggled) { __instance.verbProps.warmupTime = GunExt.Props.VerbEntries[1].VerbProps.warmupTime; } else { __instance.verbProps.warmupTime = GunExt.OriginalwarmupTime; } } } else if (GunExt.HeavyWeapon) { if (GunExt.ticksHere < GunExt.HeavyWeaponSetupTime.SecondsToTicks()) { __instance.verbProps.warmupTime = GunExt.OriginalwarmupTime + (GunExt.HeavyWeaponSetupTime - GunExt.ticksHere.TicksToSeconds()); } else { __instance.verbProps.warmupTime = GunExt.OriginalwarmupTime; } } } } if (compeq != null) { if (__instance.GetProjectile().projectile.Conversion()) { float distance = __instance.caster.Position.DistanceTo(castTarg.Cell); __instance.verbProps.warmupTime = (float)__state + (distance / 30); } } } } }
public static bool IsLock(this ThingWithComps thing, out LockComp lockComp) => (lockComp = thing.TryGetComp <LockComp>()) != null;
protected override Job TryGiveJob(Pawn pawn) { if (!pawn.RaceProps.Humanlike || (pawn.story != null && pawn.story.WorkTagIsDisabled(WorkTags.Violent))) { return(null); } if (pawn.Faction.IsPlayer && pawn.Drafted) { return(null); } /* * Log.Message(pawn.ToString() + " priority:" + (GetPriorityWork(pawn)).ToString()); * Log.Message(pawn.ToString() + " capacityWeight: " + pawn.TryGetComp<CompInventory>().capacityWeight.ToString()); * Log.Message(pawn.ToString() + " currentWeight: " + pawn.TryGetComp<CompInventory>().currentWeight.ToString()); * Log.Message(pawn.ToString() + "capacityBulk: " + pawn.TryGetComp<CompInventory>().capacityBulk.ToString()); * Log.Message(pawn.ToString() + "currentBulk: " + pawn.TryGetComp<CompInventory>().currentBulk.ToString()); */ var brawler = pawn.story.traits.HasTrait(TraitDefOf.Brawler); CompInventory inventory = pawn.TryGetComp <CompInventory>(); CompAmmoUser ammouser = pawn.TryGetComp <CompAmmoUser>(); CompAmmoUser primaryammouser = pawn.equipment.Primary.TryGetComp <CompAmmoUser>(); if (inventory != null) { Room room = RoomQuery.RoomAtFast(pawn.Position, pawn.Map); // Prefer ranged weapon in inventory if (!pawn.Faction.IsPlayer && pawn.equipment != null) { if (pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsMeleeWeapon && !brawler && (pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= pawn.skills.GetSkill(SkillDefOf.Melee).Level || pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= 6)) { ThingWithComps InvListGun3 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null); if (InvListGun3 != null) { Thing ammoInvListGun3 = null; foreach (ThingDef InvListGunDef3 in InvListGun3.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun3 = inventory.ammoList.Find(thing => thing.def == InvListGunDef3); break; } if (ammoInvListGun3 != null) { inventory.TrySwitchToWeapon(InvListGun3); } } } } // Drop excess ranged weapon if (!pawn.Faction.IsPlayer && pawn.equipment.Primary != null && primaryammouser != null && GetPriorityWork(pawn) == WorkPriority.Unloading && inventory.rangedWeaponList.Count >= 1) { Thing ListGun = inventory.rangedWeaponList.Find(thing => pawn.equipment != null && pawn.equipment.Primary != null && thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (ListGun != null) { Thing ammoListGun = null; foreach (ThingDef ListGunDef in ListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { if (inventory.ammoList.Find(thing => thing.def == ListGunDef) == null) { ammoListGun = ListGun; break; } } if (ammoListGun != null) { Thing droppedWeapon; if (inventory.container.TryDrop(ListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ListGun.stackCount, out droppedWeapon)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, droppedWeapon, 30, true)); } } } } // Find and drop not need ammo from inventory if (!pawn.Faction.IsPlayer && inventory.ammoList.Count > 1 && GetPriorityWork(pawn) == WorkPriority.Unloading) { Thing WrongammoThing = null; foreach (ThingDef WrongammoDef in primaryammouser.Props.ammoSet.ammoTypes) { WrongammoThing = inventory.ammoList.Find(thing => thing.def != WrongammoDef); break; } if (WrongammoThing != null) { Thing InvListGun = inventory.rangedWeaponList.Find(thing => pawn.equipment != null && pawn.equipment.Primary != null && thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (InvListGun != null) { Thing ammoInvListGun = null; foreach (ThingDef InvListGunDef in InvListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun = inventory.ammoList.Find(thing => thing.def == InvListGunDef); break; } if (ammoInvListGun != null && ammoInvListGun != WrongammoThing) { Thing droppedThingAmmo; if (inventory.container.TryDrop(ammoInvListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ammoInvListGun.stackCount, out droppedThingAmmo)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } else { Thing droppedThing; if (inventory.container.TryDrop(WrongammoThing, pawn.Position, pawn.Map, ThingPlaceMode.Near, WrongammoThing.stackCount, out droppedThing)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } } // Find weapon in inventory and try to switch if any ammo in inventory. if (GetPriorityWork(pawn) == WorkPriority.Weapon && pawn.equipment.Primary == null) { ThingWithComps InvListGun2 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null); if (InvListGun2 != null) { Thing ammoInvListGun2 = null; foreach (ThingDef InvListGunDef2 in InvListGun2.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun2 = inventory.ammoList.Find(thing => thing.def == InvListGunDef2); break; } if (ammoInvListGun2 != null) { inventory.TrySwitchToWeapon(InvListGun2); } } // Find weapon with near ammo for ai. if (!pawn.Faction.IsPlayer && pawn.equipment.Primary == null) { Predicate <Thing> validatorWS = (Thing w) => w.def.IsWeapon && w.MarketValue > 500 && pawn.CanReserve(w, 1) && pawn.CanReach(w, PathEndMode.Touch, Danger.Deadly, true) && ((!pawn.Faction.HostileTo(Faction.OfPlayer) && pawn.Map.areaManager.Home[w.Position]) || (pawn.Faction.HostileTo(Faction.OfPlayer))) && (w.Position.DistanceToSquared(pawn.Position) < 15f || room == RoomQuery.RoomAtFast(w.Position, pawn.Map)); List <Thing> weapon = ( from w in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorWS(w) where w.def.IsRangedWeapon // added this since what we are doing with the weapon list is looking for ammo. orderby w.MarketValue - w.Position.DistanceToSquared(pawn.Position) * 2f descending select w ).ToList(); if (weapon != null && weapon.Count > 0) { foreach (Thing thing in weapon) { List <ThingDef> thingDefAmmoList = (from ThingDef g in thing.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes select g).ToList <ThingDef>(); Predicate <Thing> validatorA = (Thing t) => t.def.category == ThingCategory.Item && t is AmmoThing && pawn.CanReserve(t, 1) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && (t.Position.DistanceToSquared(pawn.Position) < 20f || room == RoomQuery.RoomAtFast(t.Position, pawn.Map)); List <Thing> thingAmmoList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorA(t) select t ).ToList(); if (thingAmmoList.Count > 0 && thingDefAmmoList.Count > 0) { foreach (Thing th in thingAmmoList) { foreach (ThingDef thd in thingDefAmmoList) { if (thd == th.def) { int ammothingcount = 0; foreach (ThingDef ammoDef in thing.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammothingcount += th.stackCount; } if (ammothingcount > thing.TryGetComp <CompAmmoUser>().Props.magazineSize * 2) { int numToThing = 0; if (inventory.CanFitInInventory(thing, out numToThing)) { if (thing.Position == pawn.Position || thing.Position.AdjacentToCardinal(pawn.Position)) { return(new Job(JobDefOf.Equip, thing) { checkOverrideOnExpire = true, expiryInterval = 100, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } return(GotoForce(pawn, thing, PathEndMode.Touch)); } } } } } } } } // else if we didn't find a ranged weapon with available ammo above, lets try a melee weapon. Thing meleeWeapon = ( from w in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorWS(w) where !w.def.IsRangedWeapon // Looking for non-ranged weapons. where w.def.IsMeleeWeapon // Make sure it's melee capable. orderby w.MarketValue - w.Position.DistanceToSquared(pawn.Position) * 2f descending select w ).FirstOrDefault(); if (meleeWeapon != null) { if (meleeWeapon.Position == pawn.Position || meleeWeapon.Position.AdjacentToCardinal(pawn.Position)) { return(new Job(JobDefOf.Equip, meleeWeapon) { checkOverrideOnExpire = true, expiryInterval = 100, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } return(GotoForce(pawn, meleeWeapon, PathEndMode.Touch)); } } } // Find ammo if ((GetPriorityWork(pawn) == WorkPriority.Ammo || GetPriorityWork(pawn) == WorkPriority.LowAmmo) && pawn.equipment != null && pawn.equipment.Primary != null && primaryammouser != null) { List <ThingDef> curAmmoList = (from ThingDef g in primaryammouser.Props.ammoSet.ammoTypes select g).ToList <ThingDef>(); if (curAmmoList.Count > 0) { Predicate <Thing> validator = (Thing t) => t is AmmoThing && pawn.CanReserve(t, 1) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && ((pawn.Faction.IsPlayer && !ForbidUtility.IsForbidden(t, pawn)) || (!pawn.Faction.IsPlayer && (!pawn.Faction.HostileTo(Faction.OfPlayer) && pawn.Map.areaManager.Home[t.Position]) || (pawn.Faction.HostileTo(Faction.OfPlayer)))) && (t.Position.DistanceToSquared(pawn.Position) < 20f || room == RoomQuery.RoomAtFast(t.Position, pawn.Map)); List <Thing> curThingList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validator(t) select t ).ToList(); foreach (Thing th in curThingList) { foreach (ThingDef thd in curAmmoList) { if (thd == th.def) { //Defence from low count loot spam float thw = (th.GetStatValue(CR_StatDefOf.Bulk)) * th.stackCount; if (thw > 0.5f) { if (pawn.Faction.IsPlayer) { int SearchRadius = 0; if (GetPriorityWork(pawn) == WorkPriority.LowAmmo) { SearchRadius = 70; } else { SearchRadius = 30; } Thing closestThing = GenClosest.ClosestThingReachable( pawn.Position, pawn.Map, ThingRequest.ForDef(th.def), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.None, TraverseMode.ByPawn), SearchRadius, x => !x.IsForbidden(pawn) && pawn.CanReserve(x)); if (closestThing != null) { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = numToCarry }); } } } else { if (th.Position == pawn.Position || th.Position.AdjacentToCardinal(pawn.Position)) { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = Mathf.RoundToInt(numToCarry * 0.8f), expiryInterval = 150, checkOverrideOnExpire = true, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } return(GotoForce(pawn, th, PathEndMode.Touch)); } } } } } } } if (!pawn.Faction.IsPlayer && pawn.apparel != null && GetPriorityWork(pawn) == WorkPriority.Apparel) { if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Torso)) { Apparel apparel = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Torso); if (apparel != null) { int numToapparel = 0; if (inventory.CanFitInInventory(apparel, out numToapparel)) { return(new Job(JobDefOf.Wear, apparel) { ignoreForbidden = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } } if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Legs)) { Apparel apparel2 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Legs); if (apparel2 != null) { int numToapparel2 = 0; if (inventory.CanFitInInventory(apparel2, out numToapparel2)) { return(new Job(JobDefOf.Wear, apparel2) { ignoreForbidden = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } } /* * if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.FullHead)) * { * Apparel apparel3 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.FullHead); * if (apparel3 != null) * { * int numToapparel3 = 0; * if (inventory.CanFitInInventory(apparel3, out numToapparel3)) * { * return new Job(JobDefOf.Wear, apparel3) * { * ignoreForbidden = true, * locomotionUrgency = LocomotionUrgency.Sprint * }; * } * } * } */ } return(null); } return(null); }
private void DrawThingRow(ref float y, float width, Thing thing) { Rect rect = new Rect(0f, y, width, 28f); TooltipHandler.TipRegion(rect, thing.GetWeightAndBulkTip()); if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (Widgets.ButtonInvisible(rect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Medium, null, null)); if (this.CanEdit) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { ThingWithComps oldEq; SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action action = null; Apparel ap = thing as Apparel; if (ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap)) { Apparel unused; action = delegate { this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true); }; } else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq)) { ThingWithComps unused; action = delegate { this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true); }; } else if (!thing.def.destroyOnDrop) { Thing unused; action = delegate { this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused); }; } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null)); } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect rect2 = new Rect(36f, y, width - 36f, 28f); string text = thing.LabelCap; if (thing is Apparel && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) { text = text + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(rect2, text); y += 28f; }
public void Transform() { foreach (ThingWithComps lightCopy in GetPawn.equipment.AllEquipmentListForReading.FindAll(t => t.TryGetComp <CompLightCopy>() != null)) { lightCopy.Destroy(); } CompQuality compQualityOld = parent.TryGetComp <CompQuality>(); CompTakePhoto compTakePhotoOld = parent.TryGetComp <CompTakePhoto>(); int hitPoints = parent.HitPoints; ThingComp compInfusedOld = parent.AllComps.Find(c => c.GetType().ToString() == "Infused.CompInfused"); ThingWithComps weaponToCreate = (ThingWithComps)ThingMaker.MakeThing(Props.transformInto, parent.Stuff); weaponToCreate.HitPoints = hitPoints; if (compQualityOld != null && weaponToCreate.TryGetComp <CompQuality>() is CompQuality compQualityNew) { weaponToCreate.AllComps.Remove(compQualityNew); weaponToCreate.AllComps.Add(compQualityOld); } if (compInfusedOld != null && weaponToCreate.AllComps.Find(c => c.GetType().ToString() == "Infused.CompInfused") is ThingComp compInfusedNew) { weaponToCreate.AllComps.Remove(compInfusedNew); weaponToCreate.AllComps.Add(compInfusedOld); } if (compTakePhotoOld != null && weaponToCreate.TryGetComp <CompTakePhoto>() is CompTakePhoto compTakePhotoNew) { compTakePhotoNew.ListOfDifferentPhotos = compTakePhotoOld.ListOfDifferentPhotos; } ThingWithComps weaponToCreateSecondary = null; if (Props.transformSecondaryProduct != null) { weaponToCreateSecondary = (ThingWithComps)ThingMaker.MakeThing(Props.transformSecondaryProduct, parent.Stuff); weaponToCreateSecondary.HitPoints = hitPoints; if (compQualityOld != null && weaponToCreateSecondary.TryGetComp <CompQuality>() is CompQuality compQualityNew2) { weaponToCreateSecondary.AllComps.Remove(compQualityNew2); weaponToCreateSecondary.AllComps.Add(compQualityOld); } if (compInfusedOld != null && weaponToCreateSecondary.AllComps.Find(c => c.GetType().ToString() == "Infused.CompInfused") is ThingComp compInfusedNew2) { weaponToCreateSecondary.AllComps.Remove(compInfusedNew2); weaponToCreateSecondary.AllComps.Add(compInfusedOld); } } if (LoadedModManager.RunningMods.Any(m => m.Name == "PsiTech")) // compatibility with PsiTech weapon infusion, if the Mod is not running nothing happens here, if PsiTech changes any names this will break { Type typeExtensionMethods = Type.GetType("PsiTech.Utility.ExtensionMethods, PsiTech"); MethodInfo methodInfo = typeExtensionMethods.GetMethod("PsiEquipmentTracker", new Type[] { typeof(Thing) }); object objectPsiTechEquipmentTracker = methodInfo.Invoke(parent, new object[] { parent }); Type typePsiTechEquipmentTracker = Type.GetType("PsiTech.Misc.PsiTechEquipmentTracker, PsiTech"); FieldInfo fieldInfo = typePsiTechEquipmentTracker.GetField("IsPsychic"); if (typePsiTechEquipmentTracker.GetField("IsPsychic").GetValue(objectPsiTechEquipmentTracker) is bool IsPsychic && IsPsychic) { objectPsiTechEquipmentTracker = methodInfo.Invoke(weaponToCreate, new object[] { weaponToCreate }); typePsiTechEquipmentTracker.GetField("IsPsychic").SetValue(objectPsiTechEquipmentTracker, true); } } if (!ConsumeAmmunition()) { return; } Pawn tmpPawn = GetPawn; parent.Destroy(); tmpPawn.equipment.AddEquipment(weaponToCreate); if (weaponToCreateSecondary != null) { tmpPawn.equipment.AddEquipment(weaponToCreateSecondary); } PlaySound(Props.transformSound); }
/// <summary> /// Adds another "layer" to the equipment aiming if they have a /// weapon with a CompActivatableEffect. /// </summary> /// <param name="__instance"></param> /// <param name="eq"></param> /// <param name="drawLoc"></param> /// <param name="aimAngle"></param> public static bool DrawEquipmentAimingPreFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { ThingWithComps thingWithComps = eq as ThingWithComps; if (thingWithComps != null) { //If the deflector is active, it's already using this code. var deflector = thingWithComps.AllComps.FirstOrDefault<ThingComp>((ThingComp y) => y.GetType().ToString() == "CompDeflector.CompDeflector" || y.GetType().BaseType.ToString() == "CompDeflector.CompDeflector"); if (deflector != null) { bool isAnimatingNow = Traverse.Create(deflector).Property("IsAnimatingNow").GetValue<bool>(); if (isAnimatingNow) { return false; } } CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp<CompOversizedWeapon>(); if (compOversizedWeapon != null) { bool flip = false; float num = aimAngle - 90f; Mesh mesh; if (aimAngle > 20f && aimAngle < 160f) { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } else if (aimAngle > 200f && aimAngle < 340f) { mesh = MeshPool.plane10Flip; flip = true; num -= 180f; num -= eq.def.equippedAngleOffset; } else { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } num %= 360f; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; Material matSingle; if (graphic_StackCount != null) { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { matSingle = eq.Graphic.MatSingle; } Vector3 s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s); if (!flip) Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0); else Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0); return false; } } //} return true; }
public void CreateLightCopy(string defname) { Pawn tmpPawn = GetPawn; if (GetPawn.equipment.Primary != null) //if primary equipped { if (GetPawn.equipment.Primary.TryGetComp <CompTakePhoto>() == null) // if primary not camera { if (GetPawn.equipment.Primary.TryGetComp <CompLightCopy>() != null) // if primary light copy { GetPawn.equipment.Primary.Destroy(); // destroy light copy } else { return; // primary is no camera or light copy } } else { MakeBox(); // primary is camera } } // new weapon with specific color ThingWithComps weaponToCreate = new ThingWithComps(); if (ThingDef.Named(defname).MadeFromStuff) { weaponToCreate = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(defname), GenStuff.RandomStuffFor(ThingDef.Named(defname))); } else { weaponToCreate = (ThingWithComps)ThingMaker.MakeThing(ThingDef.Named(defname), null); } if (weaponToCreate.TryGetComp <CompQuality>() != null) { weaponToCreate.TryGetComp <CompQuality>().SetQuality(parent.TryGetComp <CompQuality>().Quality, ArtGenerationContext.Colony); } weaponToCreate.HitPoints = 1; if (weaponToCreate.TryGetComp <CompColorable>() == null) { CompColorable compColorable = new CompColorable { parent = weaponToCreate }; CompProperties compProps = new CompProperties { compClass = typeof(CompColorable) }; compColorable.Initialize(compProps); weaponToCreate.AllComps.Add(compColorable); } weaponToCreate.TryGetComp <CompColorable>().Color = Props.LightCopyColor; // remove certain special abilities from light copy weaponToCreate.AllComps.RemoveAll(x => x.GetType().Name.Equals("CompWeaponTransform")); // checking for string because "monster hunter rimworld" mod also has transformable weapons weaponToCreate.AllComps.RemoveAll(x => x.GetType().Equals(typeof(CompTakePhoto))); CompLightCopy rWBYLightCopyDestroyAbility = new CompLightCopy { parent = weaponToCreate }; CompProperties compProps2 = new CompProperties { compClass = typeof(CompLightCopy) }; rWBYLightCopyDestroyAbility.Initialize(compProps2); weaponToCreate.AllComps.Add(rWBYLightCopyDestroyAbility); if (!ConsumeAmmunition()) { return; } ListOfDifferentPhotos.Remove(defname); tmpPawn.equipment.AddEquipment(weaponToCreate); }
protected override IEnumerable <Toil> MakeNewToils() { /// //Set fail conditions /// this.FailOnDestroyedOrNull(CartInd); //Note we only fail on forbidden if the target doesn't start that way //This helps haul-aside jobs on forbidden items if (!TargetThingA.IsForbidden(pawn.Faction)) { this.FailOnForbidden(CartInd); } ThingWithComps cart = TargetThingA as ThingWithComps; if (ToolsForHaulUtility.FindStorageCell(pawn, cart) == IntVec3.Invalid) { JobFailReason.Is(ToolsForHaulUtility.NoEmptyPlaceForCart); } if (cart.TryGetComp <CompMountable>().Driver != null) { this.FailOnSomeonePhysicallyInteracting(CartInd); } /// //Define Toil /// Toil toilGoToCell = Toils_Goto.GotoCell(StoreCellInd, PathEndMode.ClosestTouch); /// //Toils Start /// //Reserve thing to be stored and storage cell yield return(Toils_Reserve.Reserve(CartInd)); yield return(Toils_Reserve.Reserve(StoreCellInd)); //JumpIf already mounted yield return(Toils_Jump.JumpIf(toilGoToCell, () => { return cart.TryGetComp <CompMountable>().Driver == pawn ? true : false; })); //Mount on Target yield return(Toils_Goto.GotoThing(CartInd, PathEndMode.ClosestTouch) .FailOnDestroyedOrNull(CartInd)); yield return(Toils_Cart.MountOn(CartInd)); //Dismount yield return(toilGoToCell); yield return(Toils_Cart.DismountAt(CartInd, StoreCellInd)); }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 position = IntVec3.FromVector3(clickPos); // Add options for equipment. if (pawn.equipment != null) { List <Thing> things = position.GetThingList(pawn.Map); foreach (Thing thing in things) { if (thing.TryGetComp <CompEquippable>() != null) { ThingWithComps equipment = (ThingWithComps)thing; if (equipment.def.IsWeapon && !pawn.WorkTagIsDisabled(WorkTags.Violent) && pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly) && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && !(pawn.IsQuestLodger() && (!equipment.def.IsWeapon || pawn.equipment.Primary != null)) && EquipmentUtility.CanEquip(equipment, pawn, out _)) { string text3 = UIText.AIEquip.Translate(thing.LabelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 += " " + UIText.EquipWarningBrawler.Translate(); } var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( text3, () => { TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn); CompBladelinkWeapon compBladelinkWeapon = equipment.TryGetComp <CompBladelinkWeapon>(); if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn) { if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n"; } equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate(); } if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate(); Find.WindowStack.Add( new Dialog_MessageBox( equipWeaponConfirmationDialogText, "Yes".Translate(), () => { Equip(); }, "No".Translate())); } else { Equip(); } }, MenuOptionPriority.High), pawn, equipment); opts.Add(option); } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(AwesomeInventory_JobDefOf.AwesomeInventory_MapEquip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } } } } // Add options for apparel. if (pawn.apparel != null) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(position); if (apparel != null) { if (pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly) && !apparel.IsBurning() && ApparelOptionUtility.CanWear(pawn, apparel)) { FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIForceWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = true; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = false; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); } } } }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (this.CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); string tipString = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? "ConsumeThing".Translate(new object[] { thing.LabelShort }) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); TooltipHandler.TipRegion(rect3, tipString); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); this.InterfaceEatThis(thing); } rect.width -= 24f; } if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(thingLabelRect, thingLabel); y += _thingRowHeight; TooltipHandler.TipRegion(thingLabelRect, thing.GetWeightAndBulkTip()); // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action dropApparel = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); }; Action dropApparelHaul = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }; if (this.CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceEatThis(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? "ConsumeThing".Translate(new object[] { thing.LabelShort }) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); floatOptionList.Add(new FloatMenuOption(label, eatFood)); } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel)); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), dropApparelHaul)); if (this.CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
public override void CompTickRare() { if (this.hediff != null) { Apparel artifact = this.parent as Apparel; if (artifact != null) { if (artifact.Wearer != null) { //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort); if (artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false) != null) { } else { HealthUtility.AdjustSeverity(artifact.Wearer, hediff, hediffSeverity); HediffComp_EnchantedItem hdc = artifact.Wearer.health.hediffSet.GetFirstHediffOfDef(hediff, false).TryGetComp <HediffComp_EnchantedItem>(); if (hdc != null) { hdc.enchantedItem = artifact; } //HediffComp_EnchantedItem comp = diff.TryGetComp<HediffComp_EnchantedItem>(); } } } } if (this.Props.hasAbility && !this.abilitiesInitialized) { Apparel artifact = this.parent as Apparel; if (artifact != null) { if (artifact.Wearer != null) { //Log.Message("" + artifact.LabelShort + " has holding owner " + artifact.Wearer.LabelShort); this.InitializeAbilities(artifact); } this.MagicAbilities = artifact.GetComp <CompAbilityItem>().Props.Abilities; //this.MagicAbilities = new List<AbilityDef>(); //this.MagicAbilities.Clear(); // abilities; } } if (GetEnchantedStuff_HediffDef != null) { if (WearingPawn != null) { hediffStuff.Clear(); List <Apparel> wornApparel = WearingPawn.apparel.WornApparel; for (int i = 0; i < wornApparel.Count; i++) { CompEnchantedItem itemComp = wornApparel[i].TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null) { int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff); if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount) { if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff)) { Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff); if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount)) { WearingPawn.health.RemoveHediff(hd); HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } else { HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } } } if (WearingPawn.equipment != null && WearingPawn.equipment.Primary != null && !EnchantedStuff.apparelOnly) { ThingWithComps eq = WearingPawn.equipment.Primary; CompEnchantedItem itemComp = eq.TryGetComp <CompEnchantedItem>(); if (itemComp != null && itemComp.GetEnchantedStuff_HediffDef != null) { int hdCount = GetStuffCount_Hediff(itemComp.EnchantedStuff.appliedHediff); if (hdCount >= itemComp.EnchantedStuff.applyHediffAtCount) { if (WearingPawn.health.hediffSet.HasHediff(itemComp.EnchantedStuff.appliedHediff)) { Hediff hd = WearingPawn.health.hediffSet.GetFirstHediffOfDef(itemComp.EnchantedStuff.appliedHediff); if (hd.Severity < (hdCount * itemComp.EnchantedStuff.severityPerCount)) { WearingPawn.health.RemoveHediff(hd); HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } else { HealthUtility.AdjustSeverity(WearingPawn, itemComp.EnchantedStuff.appliedHediff, hdCount * itemComp.EnchantedStuff.severityPerCount); } } } } } } base.CompTickRare(); }