static void Postfix(ref bool __result, ReservationManager __instance, Pawn claimant, LocalTargetInfo target, int maxPawns, int stackCount, ReservationLayerDef layer, bool ignoreOtherReservations) { if (mapFI == null) { mapFI = typeof(ReservationManager).GetField("map", BindingFlags.NonPublic | BindingFlags.Instance); } #if DEBUG_RESERVE Log.Warning("\nCanReserve original result: " + __result); #endif if (!__result && (target.Thing == null || target.GetType() == typeof(Building_WeaponStorage))) { IEnumerable <Thing> things = ((Map)mapFI.GetValue(__instance))?.thingGrid.ThingsAt(target.Cell); if (things != null) { #if DEBUG_RESERVE Log.Warning("CanReserve - Found things"); #endif foreach (Thing t in things) { #if DEBUG_RESERVE Log.Warning("CanReserve - def " + t.def.defName); #endif if (t.GetType() == typeof(Building_WeaponStorage)) { #if DEBUG_RESERVE Log.Warning("CanReserve is now true\n"); #endif __result = true; } } } } }
// Token: 0x060039E1 RID: 14817 RVA: 0x001B83B8 File Offset: 0x001B67B8 private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target) { float damAmount = this.verbProps.AdjustedMeleeDamageAmount(this, base.CasterPawn); float armorPenetration = this.verbProps.AdjustedArmorPenetration(this, base.CasterPawn); DamageDef damDef = this.verbProps.meleeDamageDef; BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = null; damAmount = Rand.Range(damAmount * 0.8f, damAmount * 1.2f); if (base.CasterIsPawn) { bodyPartGroupDef = this.verbProps.AdjustedLinkedBodyPartsGroup(this.tool); if (damAmount >= 1f) { if (base.HediffCompSource != null) { hediffDef = base.HediffCompSource.Def; } } else { damAmount = 1f; damDef = DamageDefOf.Blunt; } } ThingDef source; if (base.EquipmentSource != null) { source = base.EquipmentSource.def; } else { source = base.CasterPawn.def; } Vector3 direction = (target.Thing.Position - base.CasterPawn.Position).ToVector3(); DamageDef def = damDef; float num = damAmount; float num2 = armorPenetration; Thing caster = this.caster; DamageInfo mainDinfo = new DamageInfo(def, num, num2, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); mainDinfo.SetWeaponHediff(hediffDef); mainDinfo.SetAngle(direction); yield return(mainDinfo); if (this.surpriseAttack && ((this.verbProps.surpriseAttack != null && !this.verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) || (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()))) { IEnumerable <ExtraMeleeDamage> extraDamages = Enumerable.Empty <ExtraMeleeDamage>(); if (this.verbProps.surpriseAttack != null && this.verbProps.surpriseAttack.extraMeleeDamages != null) { extraDamages = extraDamages.Concat(this.verbProps.surpriseAttack.extraMeleeDamages); } if (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) { extraDamages = extraDamages.Concat(this.tool.surpriseAttack.extraMeleeDamages); } foreach (ExtraMeleeDamage extraDamage in extraDamages) { int extraDamageAmount = GenMath.RoundRandom(extraDamage.AdjustedDamageAmount(this, base.CasterPawn)); float extraDamageArmorPenetration = extraDamage.AdjustedArmorPenetration(this, base.CasterPawn); def = extraDamage.def; num2 = (float)extraDamageAmount; num = extraDamageArmorPenetration; caster = this.caster; DamageInfo extraDinfo = new DamageInfo(def, num2, num, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); extraDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); extraDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef); extraDinfo.SetWeaponHediff(hediffDef); extraDinfo.SetAngle(direction); yield return(extraDinfo); } } if (target.GetType() == typeof(Pawn)) { Pawn hitPawn = (Pawn)target; HarmonyPatches.PushEffect(CasterPawn, hitPawn, (int)((Rand.Range(2, 3) + CasterPawn.BodySize) - hitPawn.BodySize), true); } yield break; }
// Token: 0x06005F6B RID: 24427 RVA: 0x0020F288 File Offset: 0x0020D488 private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target) { float num = this.verbProps.AdjustedMeleeDamageAmount(this, this.CasterPawn); float armorPenetration = this.verbProps.AdjustedArmorPenetration(this, this.CasterPawn); DamageDef def = this.verbProps.meleeDamageDef; BodyPartGroupDef bodyPartGroupDef = null; HediffDef hediffDef = null; num = Rand.Range(num * 0.8f, num * 1.2f); if (this.CasterIsPawn) { bodyPartGroupDef = this.verbProps.AdjustedLinkedBodyPartsGroup(this.tool); if (num >= 1f) { if (base.HediffCompSource != null) { hediffDef = base.HediffCompSource.Def; } } else { num = 1f; def = DamageDefOf.Blunt; } } ThingDef source; if (base.EquipmentSource != null) { source = base.EquipmentSource.def; } else { source = this.CasterPawn.def; } Vector3 direction = (target.Thing.Position - this.CasterPawn.Position).ToVector3(); DamageInfo damageInfo = new DamageInfo(def, num, armorPenetration, -1f, this.caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); damageInfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); damageInfo.SetWeaponBodyPartGroup(bodyPartGroupDef); damageInfo.SetWeaponHediff(hediffDef); damageInfo.SetAngle(direction); yield return(damageInfo); if (this.tool != null && this.tool.extraMeleeDamages != null) { foreach (ExtraDamage extraDamage in this.tool.extraMeleeDamages) { if (Rand.Chance(extraDamage.chance)) { num = extraDamage.amount; num = Rand.Range(num * 0.8f, num * 1.2f); damageInfo = new DamageInfo(extraDamage.def, num, extraDamage.AdjustedArmorPenetration(this, this.CasterPawn), -1f, this.caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); damageInfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); damageInfo.SetWeaponBodyPartGroup(bodyPartGroupDef); damageInfo.SetWeaponHediff(hediffDef); damageInfo.SetAngle(direction); yield return(damageInfo); } } // List<ExtraDamage>.Enumerator enumerator = default(List<ExtraDamage>.Enumerator); } if (this.surpriseAttack && ((this.verbProps.surpriseAttack != null && !this.verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraDamage>()) || (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraDamage>()))) { IEnumerable <ExtraDamage> enumerable = Enumerable.Empty <ExtraDamage>(); if (this.verbProps.surpriseAttack != null && this.verbProps.surpriseAttack.extraMeleeDamages != null) { enumerable = enumerable.Concat(this.verbProps.surpriseAttack.extraMeleeDamages); } if (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraDamage>()) { enumerable = enumerable.Concat(this.tool.surpriseAttack.extraMeleeDamages); } foreach (ExtraDamage extraDamage2 in enumerable) { int num2 = GenMath.RoundRandom(extraDamage2.AdjustedDamageAmount(this, this.CasterPawn)); float armorPenetration2 = extraDamage2.AdjustedArmorPenetration(this, this.CasterPawn); DamageInfo damageInfo2 = new DamageInfo(extraDamage2.def, (float)num2, armorPenetration2, -1f, this.caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null); damageInfo2.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside); damageInfo2.SetWeaponBodyPartGroup(bodyPartGroupDef); damageInfo2.SetWeaponHediff(hediffDef); damageInfo2.SetAngle(direction); yield return(damageInfo2); } // IEnumerator<ExtraDamage> enumerator2 = null; } if (target.GetType() == typeof(Pawn)) { Pawn hitPawn = (Pawn)target; Main.PushEffect(CasterPawn, hitPawn, (int)((Rand.Range(2, 3) + CasterPawn.BodySize) - hitPawn.BodySize), true); } yield break; }