// Token: 0x06000022 RID: 34 RVA: 0x00003818 File Offset: 0x00001A18 public static bool COWTryGetOffHandEquipment(this Pawn_EquipmentTracker instance, out ThingWithComps result) { result = null; bool flag = instance.pawn.HasMissingArmOrHand(); bool result2; if (flag) { result2 = false; } else { ExtendedDataStorage extendedDataStorage = Base.Instance.GetExtendedDataStorage(); foreach (ThingWithComps thingWithComps in instance.AllEquipmentListForReading) { ExtendedThingWithCompsData extendedThingWithCompsData; bool flag2 = extendedDataStorage.TryGetExtendedDataFor(thingWithComps, out extendedThingWithCompsData) && extendedThingWithCompsData.isOffHand; if (flag2) { result = thingWithComps; return(true); } } result2 = false; } return(result2); }
static void Postfix(Thing item) { ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); if (store != null && item is ThingWithComps eq && store.TryGetExtendedDataFor(eq, out ExtendedThingWithCompsData result)) { store.DeleteExtendedDataFor(eq); } }
public static bool IsOffHand(this ThingWithComps instance) { ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); if (store != null) { if (store.TryGetExtendedDataFor(instance, out ExtendedThingWithCompsData twcData)) { return(twcData.isOffHand); } } return(false); }
//Make sure offhand weapons are never stored first in the list. static void Postfix(Pawn_EquipmentTracker __instance, ThingWithComps newEq, ref ThingOwner <ThingWithComps> ___equipment) { ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); ThingWithComps primary = __instance.Primary; if (primary != null && store != null && store.TryGetExtendedDataFor(primary, out ExtendedThingWithCompsData twcData) && twcData.isOffHand) { if (___equipment != null) { ___equipment.Remove(primary); __instance.AddOffHandEquipment(primary); } } }
//Make sure offhand weapons are never stored first in the list. static void Postfix(Pawn_EquipmentTracker __instance, ThingWithComps newEq) { ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); ThingWithComps primary = __instance.Primary; if (primary != null && store != null && store.TryGetExtendedDataFor(primary, out ExtendedThingWithCompsData twcData) && twcData.isOffHand) { ThingOwner <ThingWithComps> equipment = Traverse.Create(__instance).Field("equipment").GetValue <ThingOwner <ThingWithComps> >(); if (equipment != null) { equipment.Remove(primary); __instance.AddOffHandEquipment(primary); } } }
//Only returns true when offhand weapon is used alongside a mainhand weapon. public static bool TryGetOffHandEquipment(this Pawn_EquipmentTracker instance, out ThingWithComps result) { result = null; if (instance.pawn.HasMissingArmOrHand()) { return(false); } ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage(); foreach (ThingWithComps twc in instance.AllEquipmentListForReading) { if (store.TryGetExtendedDataFor(twc, out ExtendedThingWithCompsData ext) && ext.isOffHand) { result = twc; return(true); } } return(false); }