public static void Notify_EquipmentAddedPostfix(Pawn_EquipmentTracker __instance, ThingWithComps eq) { if (eq == null || __instance == null) { return; } if (eq.TryGetCompFast <AbilitesExtended.CompAbilityItem>() != null && eq.TryGetCompFast <AbilitesExtended.CompAbilityItem>() is AbilitesExtended.CompAbilityItem abilityItem) { Pawn pawn = __instance.pawn; if (!pawn.RaceProps.Humanlike) { return; } if (!abilityItem.Props.Abilities.NullOrEmpty()) { foreach (EquipmentAbilityDef def in abilityItem.Props.Abilities) { if (!__instance.pawn.abilities.abilities.Any(x => x.def == def) && (!def.requirePsyker || isPsyker(pawn))) { __instance.pawn.abilities.GainEquipmentAbility(def, eq); } } } } }
public static void Notify_EquipmentRemovedPostfix(Pawn_EquipmentTracker __instance, ThingWithComps eq) { if (eq == null || __instance == null) { return; } if (eq.TryGetCompFast <AbilitesExtended.CompAbilityItem>() != null && eq.TryGetCompFast <AbilitesExtended.CompAbilityItem>() is AbilitesExtended.CompAbilityItem abilityItem) { Pawn pawn = __instance.pawn; if (!pawn.RaceProps.Humanlike) { return; } if (!abilityItem.Props.Abilities.NullOrEmpty()) { foreach (AbilityDef def in abilityItem.Props.Abilities) { if (__instance.pawn.abilities.abilities.Any(x => x.def == def)) { Ability ability = __instance.pawn.abilities.abilities.Find(x => x.def == def); __instance.pawn.abilities.abilities.Remove(ability); } } } } }
public static Thing ReplacedThing(ThingWithComps original) { bool actionRequired = original.GetType() != original.def.thingClass; if (actionRequired) { // Log.Message("original.GetType("+ original.GetType()+ ") != original.def.thingClass("+ original.def.thingClass+")"); bool act = original.def.modContentPack != null && original.def.modContentPack.Name.Contains("Adeptus Mechanicus"); if (act) { try { // Log.Message("act"); // Log.Warning(original.LabelCap + "'s ThingClass doesnt match its Defs ThingClass, trying to fix"); Thing thing = ThingMaker.MakeThing(original.def, original.Stuff); thing.Position = original.Position; CompQuality quality = original.TryGetCompFast <CompQuality>(); if (quality != null) { quality.parent = thing as ThingWithComps; } CompArt art = original.TryGetCompFast <CompArt>(); if (art != null) { art.parent = thing as ThingWithComps; } thing.thingIDNumber = original.thingIDNumber; IThingHolder holder = original.ParentHolder; CompEquippable equippable = original.TryGetCompFast <CompEquippable>(); if (equippable != null) { Thing user = equippable.VerbTracker.PrimaryVerb.Caster; Pawn p = user as Pawn; if (p != null) { p.equipment.Remove(original); p.equipment.AddEquipment(thing as ThingWithComps); } } else if (holder != null) { holder.GetDirectlyHeldThings().Remove(original); holder.GetDirectlyHeldThings().TryAdd(thing); } return(thing); } catch (Exception) { Log.Warning("Something went wrong trying to replace " + original.LabelCap + "'s ThingClass from " + original.GetType().Name + " to " + original.def.thingClass.Name); return(original); } } } return(original); }
public static void Postfix(Pawn_EquipmentTracker __instance, ThingWithComps eq) { if (eq.TryGetCompFast <CompOversizedWeapon>() != null && eq.TryGetCompFast <CompOversizedWeapon>() is CompOversizedWeapon oversized) { if (oversized.Props != null && oversized.Props.groundGraphic != null) { Graphic g = eq.DefaultGraphic; } } }
public static Thing ReplacedThing(ThingWithComps original) { Type oldType = original.GetType(); Type newType = original.def.thingClass; try { // if (AMAMod.Dev) Log.Warning(original.LabelCap + "'s ThingClass(" + oldType + ") doesnt match its Defs ThingClass(" + newType + "), trying to fix"); Thing thing = ThingMaker.MakeThing(original.def, original.Stuff); thing.Position = original.Position; CompQuality quality = original.TryGetCompFast <CompQuality>(); if (quality != null) { quality.parent = thing as ThingWithComps; } CompArt art = original.TryGetCompFast <CompArt>(); if (art != null) { art.parent = thing as ThingWithComps; } thing.thingIDNumber = original.thingIDNumber; IThingHolder holder = original.ParentHolder; CompEquippable equippable = original.TryGetCompFast <CompEquippable>(); if (equippable != null) { Thing user = equippable.VerbTracker.PrimaryVerb.Caster; Pawn p = user as Pawn; if (p != null) { p.equipment.Remove(original); p.equipment.AddEquipment(thing as ThingWithComps); } } else if (holder != null) { holder.GetDirectlyHeldThings().Remove(original); holder.GetDirectlyHeldThings().TryAdd(thing); } if (AMAMod.Dev) { Log.Message(original.LabelCap + "'s ThingClass(" + thing.GetType() + ") " + (thing.GetType() == newType ? "now matches" : "doesnt match") + "its Defs ThingClass(" + newType + ")"); } return(thing); } catch (Exception) { Log.Warning("Something went wrong trying to replace " + original.LabelCap + "'s ThingClass from " + oldType.Name + " to " + newType.Name); return(original); } }
// Token: 0x0600567B RID: 22139 RVA: 0x001CE8D0 File Offset: 0x001CCAD0 public static bool CanUseConsideringQueuedJobs(Pawn pawn, ThingWithComps gear, bool showMessage = true) { OgsOld_CompTurret compReloadable = gear.TryGetCompFast <OgsOld_CompTurret>(); if (compReloadable == null) { return(true); } string text = null; if (!Event.current.shift) { if (!compReloadable.CanBeUsed) { text = compReloadable.DisabledReason(compReloadable.MinAmmoNeeded(false), compReloadable.MaxAmmoNeeded(false)); } } else if (OgsOld_CompTurretReloadableUtility.TotalChargesFromQueuedJobs(pawn, gear) + 1 > compReloadable.RemainingCharges) { text = compReloadable.DisabledReason(compReloadable.MaxAmmoAmount(), compReloadable.MaxAmmoAmount()); } if (text != null) { if (showMessage) { Messages.Message(text, pawn, MessageTypeDefOf.RejectInput, false); } return(false); } return(true); }
public static bool IsMeleeWeapon(ThingWithComps eq) { bool flag = eq == null; bool result; if (flag) { result = false; } else { CompEquippable compEquippable = eq.TryGetCompFast <CompEquippable>(); bool flag2 = compEquippable != null; if (flag2) { bool isMeleeAttack = compEquippable.PrimaryVerb.IsMeleeAttack; if (isMeleeAttack) { return(true); } } result = false; } return(result); }
// Token: 0x0600567A RID: 22138 RVA: 0x001CE860 File Offset: 0x001CCA60 public static int TotalChargesFromQueuedJobs(Pawn pawn, ThingWithComps gear) { OgsOld_CompTurret compReloadable = gear.TryGetCompFast <OgsOld_CompTurret>(); int num = 0; if (compReloadable != null && pawn != null) { foreach (Job job in pawn.jobs.AllJobs()) { Verb_ShootCompMounted verbToUse = job.verbToUse as Verb_ShootCompMounted; if (verbToUse != null && compReloadable == verbToUse.ReloadableCompSource) { num++; } } } return(num); }
public static void Postfix(Thing __instance, ref Color __result) { ThingWithComps thing = __instance as ThingWithComps; if (thing != null) { CompColorableTwo colorableTwo = thing.TryGetCompFast <CompColorableTwo>(); if (colorableTwo != null && colorableTwo.ActiveTwo) { __result = colorableTwo.ColorTwo; return; } if (colorableTwo is CompColorableTwoFaction colorableFaction && colorableFaction.FactionActiveTwo) { __result = colorableFaction.ColorTwo; return; } } }
public static void SetColors(this Thing t, Color newColorOne, Color?newColorTwo = null, bool setFaction = false, FactionDef factionDef = null, Graphic graphic = null, bool reportFailure = true) { ThingWithComps twc = t as ThingWithComps; if (twc == null) { if (reportFailure) { Log.Error("SetColor on non-ThingWithComps " + t); } return; } t.SetColorOne(newColorOne); if (newColorTwo.HasValue) { t.SetColorTwo(newColorTwo.Value); } if (setFaction) { CompColorableTwoFaction comp = twc.TryGetCompFast <CompColorableTwoFaction>(); if (comp != null && factionDef != null) { comp.FactionDef = factionDef; if (graphic != null) { FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); Traverse traverse = Traverse.Create(t); subgraphic.SetValue(t, graphic); } } } if (t is Apparel apparel && apparel.Wearer != null && !apparel.def.apparel.wornGraphicPath.NullOrEmpty()) { apparel.Wearer.Drawer.renderer.graphics.ResolveApparelGraphics(); } }
public static float AdjustedWarmup(float warmUpTime, Verb verb, LocalTargetInfo castTarg) { if (AdeptusIntergrationUtility.enabled_CombatExtended) { if (!CE(verb)) { return(warmUpTime); } } else { if (!(verb is Verb_Shoot) && !(verb is AbilitesExtended.Verb_ShootEquipment)) { return(warmUpTime); } } float result = warmUpTime; // AdvancedVerbProperties props = verb.verbProps as AdvancedVerbProperties; IAdvancedVerb props = verb.verbProps as IAdvancedVerb; ThingWithComps gun = verb.EquipmentSource; CompEquippable compeq = verb.EquipmentCompSource; Thing caster = verb.caster; Pawn CasterPawn = verb.CasterPawn; if (props != null) { if (verb.GetsHot(out bool GetsHotCrit, out float GetsHotCritChance, out bool GetsHotCritExplosion, out float GetsHotCritExplosionChance, out bool canDamageWeapon, out float extraWeaponDamage)) { } if (props.RapidFire) { // log.message(string.Format("RapidFire prefix pre-modified Values, Warmup: {0}", gun.def.Verbs[0].warmupTime, cooldown)); if (caster.Position.InHorDistOf(castTarg.Cell, verb.verbProps.range * props.RapidFireRange)) { float reduction = ((verb.verbProps.burstShotCount - 1) * verb.verbProps.ticksBetweenBurstShots).TicksToSeconds() / 4; reduction += warmUpTime / 2; result -= reduction; } // log.message(string.Format("RapidFire prefix post-modified Values, Warmup: {0}", gun.def.Verbs[0].warmupTime, cooldown)); } else if (props.HeavyWeapon && verb.CasterIsPawn) { CompWeapon_GunSpecialRules GunExt = gun.TryGetCompFast <CompWeapon_GunSpecialRules>(); if (GunExt.ticksHere < (props.HeavyWeaponSetupTime.SecondsToTicks())) { float extra = props.HeavyWeaponSetupTime; if (CasterPawn.story?.bodyType == BodyTypeDefOf.Hulk) { extra *= 0.5f; } extra = Math.Max(0, extra - GunExt.ticksHere.TicksToSeconds()); // Log.Message(string.Format("HeavyWeapon prefix pre-modified Values, Warmup: {0} + {1}, last move tick: {2}", __instance.verbProps.warmupTime, extra, GunExt.LastMovedTick)); result += extra; } // log.message(string.Format("HeavyWeapon prefix post-modified Values, Warmup: {0}, last move tick: {1}", gun.def.Verbs[0].warmupTime, GunExt.LastMovedTick)); } if (compeq != null) { if (verb.GetProjectile().projectile.Conversion()) { float distance = caster.Position.DistanceTo(castTarg.Cell); result = (float)warmUpTime + (distance / 30); } } } // Log.Message("Testing return result" + result + " warmUpTime: " + warmUpTime + " for verb: " + verb + " casting at " + castTarg); return(result); }