public override void Draw() { Vector3 targetVector; if (parentPawn != null && parentPawn.stances != null && parentPawn.stances.curStance != null) { Stance_Busy stance_Busy = parentPawn.stances.curStance as Stance_Busy; if (stance_Busy != null) { if (stance_Busy.focusTarg.HasThing) { targetVector = stance_Busy.focusTarg.Thing.DrawPos; } else { targetVector = stance_Busy.focusTarg.Cell.ToVector3Shifted(); } if (swap) { currentGraphic = graphics[0]; } else { currentGraphic = graphics[1]; } currentGraphic.MatSingle.color = FireColor; float angle = (targetVector - parent.TrueCenter()).AngleFlat(); Graphics.DrawMesh(MeshPool.GridPlane(new Vector2(2 - currentPower, 1)), parent.TrueCenter() + posFix + new Vector3(Mathf.Sin(angle * Mathf.Deg2Rad) * 1.1f, 1, Mathf.Cos(angle * Mathf.Deg2Rad)) * 1.1f, Quaternion.AngleAxis(angle, Vector3.up), currentGraphic.MatSingle, 0); } } }
private float GetDodgeChance(LocalTargetInfo target) { float result; if (this.surpriseAttack) { result = 0f; } else if (this.IsTargetImmobile(target)) { result = 0f; } else { Pawn pawn = target.Thing as Pawn; if (pawn == null) { result = 0f; } else { Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.verb != null && !stance_Busy.verb.verbProps.IsMeleeAttack) { result = 0f; } else { result = pawn.GetStatValue(StatDefOf.MeleeDodgeChance, true); } } } return(result); }
static void Prefix(Pawn ___pawn, ref Thing eq, ref Vector3 drawLoc, ref float aimAngle, PawnRenderer __instance) { if (___pawn == null) { return; } IDrawnWeaponWithRotation gun = eq as IDrawnWeaponWithRotation; if (gun == null) { return; } Stance_Busy stance_Busy = ___pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { drawLoc -= new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); float f = gun.RotationOffset; /* * if ((aimAngle > 330 && aimAngle < 360) || aimAngle > 0 && aimAngle < 30) * { * if (AMAMod.Dev && f != 0) Log.Message(___pawn.Name + " aiming "+eq.LabelCap+" @: "+drawLoc+" Angle: "+aimAngle + " Offet: "+ f); * } */ aimAngle = (aimAngle + gun.RotationOffset) % 360; drawLoc += new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); } }
static void Prefix(ref Thing eq, ref Vector3 drawLoc, ref float aimAngle, PawnRenderer __instance) { Pawn pawn = pawnField.GetValue(__instance) as Pawn; if (pawn == null) { return; } IDrawnWeaponWithRotation gun = eq as IDrawnWeaponWithRotation; if (gun == null) { return; } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { drawLoc -= new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); aimAngle = (aimAngle + gun.RotationOffset) % 360; drawLoc += new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); } }
private void DrawIcons(Rect rect, Pawn colonist) { if (colonist.Dead) { return; } float num = 20f * this.ColonistBar.Scale; Vector2 vector = new Vector2(rect.x + 1f, rect.yMax - num - 1f); bool flag = false; if (colonist.CurJob != null) { JobDef def = colonist.CurJob.def; if (def == JobDefOf.AttackMelee || def == JobDefOf.AttackStatic) { flag = true; } else if (def == JobDefOf.WaitCombat) { Stance_Busy stance_Busy = colonist.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { flag = true; } } } if (colonist.InAggroMentalState) { this.DrawIcon(ColonistBarColonistDrawer.Icon_MentalStateAggro, ref vector, colonist.MentalStateDef.LabelCap); } else if (colonist.InMentalState) { this.DrawIcon(ColonistBarColonistDrawer.Icon_MentalStateNonAggro, ref vector, colonist.MentalStateDef.LabelCap); } else if (colonist.InBed() && colonist.CurrentBed().Medical) { this.DrawIcon(ColonistBarColonistDrawer.Icon_MedicalRest, ref vector, "ActivityIconMedicalRest".Translate()); } else if (colonist.CurJob != null && colonist.jobs.curDriver.asleep) { this.DrawIcon(ColonistBarColonistDrawer.Icon_Sleeping, ref vector, "ActivityIconSleeping".Translate()); } else if (colonist.CurJob != null && colonist.CurJob.def == JobDefOf.FleeAndCower) { this.DrawIcon(ColonistBarColonistDrawer.Icon_Fleeing, ref vector, "ActivityIconFleeing".Translate()); } else if (flag) { this.DrawIcon(ColonistBarColonistDrawer.Icon_Attacking, ref vector, "ActivityIconAttacking".Translate()); } else if (colonist.mindState.IsIdle && GenDate.DaysPassed >= 1) { this.DrawIcon(ColonistBarColonistDrawer.Icon_Idle, ref vector, "ActivityIconIdle".Translate()); } if (colonist.IsBurning()) { this.DrawIcon(ColonistBarColonistDrawer.Icon_Burning, ref vector, "ActivityIconBurning".Translate()); } }
public static void DoAttackAnimationOffsetsWeapons(Pawn pawn, ref float weaponAngle, ref Vector3 weaponPosition, bool flipped, CompBodyAnimator animator, out bool noTween) { CompEquippable primaryEq = pawn.equipment?.PrimaryEq; noTween = false; // DamageDef damageDef = primaryEq?.PrimaryVerb?.verbProps?.meleeDamageDef; if (primaryEq?.parent?.def == null) { return; } Stance_Busy busy = pawn.stances.curStance as Stance_Busy; if (busy == null) { return; } if (busy.verb == null || !busy.verb.IsMeleeAttack) { return; } DamageDef damageDef = busy.verb.GetDamageDef(); //ThingUtility.PrimaryMeleeWeaponDamageType(primaryEq.parent.def); if (damageDef == null) { return; } // total weapon angle change during animation sequence int totalSwingAngle = 0; Vector3 currentOffset = animator.Jitterer.CurrentOffset; float jitterMax = animator.JitterMax; float magnitude = currentOffset.magnitude; float animationPhasePercent = magnitude / jitterMax; if (damageDef == DamageDefOf.Stab) { weaponPosition += currentOffset; // + new Vector3(0, 0, Mathf.Pow(this.CompFace.Jitterer.CurrentOffset.magnitude, 0.25f))/2; } else if (damageDef == DamageDefOf.Blunt || damageDef == DamageDefOf.Cut) { totalSwingAngle = 120; weaponPosition += currentOffset + new Vector3(0, 0, Mathf.Sin(magnitude * Mathf.PI / jitterMax) / 10); weaponAngle += flipped ? -animationPhasePercent * totalSwingAngle : animationPhasePercent * totalSwingAngle; noTween = true; } }
private void DrawEquipment(Vector3 rootLoc) { if (pawn.Dead || !pawn.Spawned) { return; } if (pawn.equipment?.Primary == null) { return; } if (pawn.CurJob?.def.neverShowWeapon ?? false) { return; } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { Vector3 aimVector = stance_Busy.focusTarg.HasThing ? stance_Busy.focusTarg.Thing.DrawPos : stance_Busy.focusTarg.Cell.ToVector3Shifted(); float num = 0f; if ((aimVector - pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (aimVector - pawn.DrawPos).AngleFlat(); } Vector3 drawLoc = rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num); drawLoc.y += 0.04f; // default weapon angle axis is upward, but all weapons are facing right, so we turn base weapon angle by 90° num -= 90f; DrawEquipmentAiming(pawn.equipment.Primary, drawLoc, num); } else if (CarryWeaponOpenly) { if (pawn.Rotation == Rot4.South) { Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc2.y += 0.04f; DrawEquipmentAiming(pawn.equipment.Primary, drawLoc2, 0f); } else if (pawn.Rotation == Rot4.North) { Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f); DrawEquipmentAiming(pawn.equipment.Primary, drawLoc3, 0f); } else if (pawn.Rotation == Rot4.East) { Vector3 drawLoc4 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc4.y += 0.04f; DrawEquipmentAiming(pawn.equipment.Primary, drawLoc4, 0f); } else if (pawn.Rotation == Rot4.West) { Vector3 drawLoc5 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc5.y += 0.04f; DrawEquipmentAiming(pawn.equipment.Primary, drawLoc5, 180f); } } }
public static bool UpdateRotation(Pawn_RotationTracker __instance) { Pawn pawn = pawnField(__instance); if (pawn.Destroyed || pawn.jobs.HandlingFacing) { return(false); } if (pawn.pather.Moving) { if (pawn.pather.curPath != null && pawn.pather.curPath.NodesLeftCount >= 1) { FaceAdjacentCell2(pawn, pawn.pather.nextCell); } return(false); } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } return(false); } Job job = pawn.CurJob; //ADDED if (job != null) //CHANGED { Pawn_JobTracker jobs = pawn.jobs; if (jobs != null) { JobDriver jobDriver = jobs.curDriver; if (jobDriver != null) { LocalTargetInfo target = job.GetTarget(jobDriver.rotateToFace); //CHANGED __instance.FaceTarget(target); } } } if (pawn.Drafted) { pawn.Rotation = Rot4.South; } return(false); }
static void Postfix(Pawn_RotationTracker __instance, ref Pawn ___pawn) { Stance_Busy stance_Busy = ___pawn.GetStancesOffHand().curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid && !___pawn.pather.Moving) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } } }
private Vector3 GetAimingVector(Vector3 rootLoc) { // copied from vanilla DrawEquipment method Stance_Busy stance_Busy = this.Wearer.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { Vector3 a = (!stance_Busy.focusTarg.HasThing) ? stance_Busy.focusTarg.Cell.ToVector3Shifted() : stance_Busy.focusTarg.Thing.DrawPos; float num = 0f; if ((a - this.Wearer.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (a - this.Wearer.DrawPos).AngleFlat(); } Vector3 drawLoc = rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num); drawLoc.y += 9f / 245f; return(drawLoc); } else if (CarryWeaponOpenly()) { if (this.Wearer.Rotation == Rot4.South) { Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc2.y += 9f / 245f; return(drawLoc2); } else if (this.Wearer.Rotation == Rot4.North) { Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f); drawLoc3.y += 0f; return(drawLoc3); } else if (this.Wearer.Rotation == Rot4.East) { Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f); drawLoc4.y += 9f / 245f; return(drawLoc4); } else if (this.Wearer.Rotation == Rot4.West) { Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f); drawLoc5.y += 9f / 245f; return(drawLoc5); } } return(default(Vector3)); }
static void Postfix(Pawn_RotationTracker __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); Stance_Busy stance_Busy = pawn.GetStancesOffHand().curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid && !pawn.pather.Moving) { if (stance_Busy.focusTarg.HasThing) { __instance.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { __instance.FaceCell(stance_Busy.focusTarg.Cell); } } }
private float GetDodgeChance(LocalTargetInfo target) { if (this.surpriseAttack) { return 0f; } if (this.IsTargetImmobile(target)) { return 0f; } Pawn pawn = target.Thing as Pawn; if (pawn == null) { return 0f; } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.verb != null && !stance_Busy.verb.verbProps.MeleeRange) { return 0f; } return pawn.GetStatValue(StatDefOf.MeleeDodgeChance, true); }
public static void DrawEquipmentAimingModified(PawnRenderer instance, Thing eq, Vector3 drawLoc, float aimAngle) { ThingWithComps offHandEquip = null; Pawn pawn = Traverse.Create(instance).Field("pawn").GetValue <Pawn>(); float mainHandAngle = aimAngle; float offHandAngle = aimAngle; Stance_Busy mainStance = pawn.stances.curStance as Stance_Busy; Stance_Busy offHandStance = null; if (pawn.GetStancesOffHand() != null) { offHandStance = pawn.GetStancesOffHand().curStance as Stance_Busy; } LocalTargetInfo focusTarg = null; if (mainStance != null && !mainStance.neverAimWeapon) { focusTarg = mainStance.focusTarg; } else if (offHandStance != null && !offHandStance.neverAimWeapon) { focusTarg = offHandStance.focusTarg; } if (pawn.equipment == null) { return; } if (pawn.equipment.TryGetOffHandEquipment(out ThingWithComps result)) { offHandEquip = result; } bool mainHandAiming = CurrentlyAiming(mainStance); bool offHandAiming = CurrentlyAiming(offHandStance); Vector3 offsetMainHand = new Vector3(); Vector3 offsetOffHand = new Vector3(); //bool currentlyAiming = (mainStance != null && !mainStance.neverAimWeapon && mainStance.focusTarg.IsValid) || stancesOffHand.curStance is Stance_Busy ohs && !ohs.neverAimWeapon && ohs.focusTarg.IsValid; //When wielding offhand weapon, facing south, and not aiming, draw differently if (offHandEquip != null) { SetAnglesAndOffsets(eq, offHandEquip, aimAngle, pawn, ref offsetMainHand, ref offsetOffHand, ref mainHandAngle, ref offHandAngle, mainHandAiming, offHandAiming); } if (offHandEquip != pawn.equipment.Primary) { instance.DrawEquipmentAiming(eq, drawLoc + offsetMainHand, mainHandAngle); } if (offHandEquip != null) { if ((offHandAiming || mainHandAiming) && focusTarg != null) { offHandAngle = GetAimingRotation(pawn, focusTarg); offsetOffHand.y += 0.1f; Vector3 adjustedDrawPos = pawn.DrawPos + new Vector3(0f, 0f, 0.4f).RotatedBy(offHandAngle) + offsetOffHand; instance.DrawEquipmentAiming(offHandEquip, adjustedDrawPos, offHandAngle); } else { instance.DrawEquipmentAiming(offHandEquip, drawLoc + offsetOffHand, offHandAngle); } } }
private static bool CurrentlyAiming(Stance_Busy stance) { return(stance != null && !stance.neverAimWeapon && stance.focusTarg.IsValid); }
static bool Prefix(ref Thing eq, ref Vector3 drawLoc, ref float aimAngle, PawnRenderer __instance) { if (!Gunplay.settings.enableWeaponAnimations) { return(true); } CompGun comp = eq.TryGetComp <CompGun>(); if (comp == null) { return(true); } Pawn pawn = pawnField.GetValue(__instance) as Pawn; if (pawn == null) { return(true); } Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { drawLoc -= equipmentDir.RotatedBy(aimAngle); aimAngle = (aimAngle + comp.RotationOffset) % 360; drawLoc += equipmentDir.RotatedBy(aimAngle); } GunPropDef prop = GunplaySetup.GunProp(eq); if (prop == null) { return(true); } 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; num -= 180f; num -= eq.def.equippedAngleOffset; } else { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } num %= 360f; drawingScale.x = drawingScale.z = prop.drawScale; CompPrimer primer = eq.TryGetComp <CompPrimer>(); if (primer != null) { primer.Draw(mesh, drawLoc, num, drawingScale); return(false); } if (prop.drawScale == 1f) { return(true); } Material mat; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; if (graphic_StackCount != null) { mat = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { mat = eq.Graphic.MatSingle; } drawingMatrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), drawingScale); Graphics.DrawMesh(mesh, drawingMatrix, mat, 0); return(false); }
public void DrawIcons(Rect rect, Pawn colonist) { if (colonist.Dead) { return; } float num = 20f * TacticUtils.TacticalColonistBar.Scale; Vector2 pos = new Vector2(rect.x + 1f, rect.yMax - num - 1f); bool flag = false; if (colonist.CurJob != null) { JobDef def = colonist.CurJob.def; if (def == JobDefOf.AttackMelee || def == JobDefOf.AttackStatic) { flag = true; } else if (def == JobDefOf.Wait_Combat) { Stance_Busy stance_Busy = colonist.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { flag = true; } } } if (colonist.IsFormingCaravan()) { DrawIcon(Icon_FormingCaravan, ref pos, Strings.ActivityIconFormingCaravan); } if (colonist.InAggroMentalState) { DrawIcon(Icon_MentalStateAggro, ref pos, colonist.MentalStateDef.LabelCap); } else if (colonist.InMentalState) { DrawIcon(Icon_MentalStateNonAggro, ref pos, colonist.MentalStateDef.LabelCap); } else if (colonist.InBed() && colonist.CurrentBed().Medical) { DrawIcon(Icon_MedicalRest, ref pos, Strings.ActivityIconMedicalRest); } else if (colonist.CurJob != null && colonist.jobs.curDriver.asleep) { DrawIcon(Icon_Sleeping, ref pos, Strings.ActivityIconSleeping); } else if (colonist.CurJob != null && colonist.CurJob.def == JobDefOf.FleeAndCower) { DrawIcon(Icon_Fleeing, ref pos, Strings.ActivityIconFleeing); } else if (flag) { DrawIcon(Icon_Attacking, ref pos, Strings.ActivityIconAttacking); } else if (colonist.mindState.IsIdle && GenDate.DaysPassed >= 1) { DrawIcon(Icon_Idle, ref pos, Strings.ActivityIconIdle); } if (colonist.IsBurning() && pos.x + num <= rect.xMax) { DrawIcon(Icon_Burning, ref pos, Strings.ActivityIconBurning); } if (colonist.Inspired && pos.x + num <= rect.xMax) { DrawIcon(Icon_Inspired, ref pos, colonist.InspirationDef.LabelCap); } if (ModCompatibility.RimworldOfMagicIsActive) { ModCompatibility.rimworldOfMagicDrawMethod.Invoke(this, new object[] { null, rect, colonist }); } }
public bool Aiming() { Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; return(stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid); }
/* * static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) * { * var instructionsList = new List<CodeInstruction>(instructions); * foreach (CodeInstruction instruction in instructionsList) * { * if (instruction.operand == typeof(PawnRenderer).GetMethod("DrawEquipmentAiming")) * { * yield return new CodeInstruction(OpCodes.Call, typeof(PawnRenderer_DrawEquipment).GetMethod("DrawEquipmentAimingModified")); * } * else * { * yield return instruction; * } * } * } */ static bool Prefix(PawnRenderer __instance, Thing eq, ref Vector3 drawLoc, ref float aimAngle, ref Pawn ___pawn) { ThingWithComps offHandEquip = null; if (___pawn.equipment == null) { return(true); } if (___pawn.equipment.TryGetOffHandEquipment(out ThingWithComps result)) { offHandEquip = result; } if (offHandEquip == null) { return(true); } float mainHandAngle = aimAngle; float offHandAngle = aimAngle; Stance_Busy mainStance = ___pawn.stances.curStance as Stance_Busy; Stance_Busy offHandStance = null; if (___pawn.GetStancesOffHand() != null) { offHandStance = ___pawn.GetStancesOffHand().curStance as Stance_Busy; } LocalTargetInfo focusTarg = null; if (mainStance != null && !mainStance.neverAimWeapon) { focusTarg = mainStance.focusTarg; } else if (offHandStance != null && !offHandStance.neverAimWeapon) { focusTarg = offHandStance.focusTarg; } bool mainHandAiming = CurrentlyAiming(mainStance); bool offHandAiming = CurrentlyAiming(offHandStance); Vector3 offsetMainHand = new Vector3(); Vector3 offsetOffHand = new Vector3(); //bool currentlyAiming = (mainStance != null && !mainStance.neverAimWeapon && mainStance.focusTarg.IsValid) || stancesOffHand.curStance is Stance_Busy ohs && !ohs.neverAimWeapon && ohs.focusTarg.IsValid; //When wielding offhand weapon, facing south, and not aiming, draw differently SetAnglesAndOffsets(eq, offHandEquip, aimAngle, ___pawn, ref offsetMainHand, ref offsetOffHand, ref mainHandAngle, ref offHandAngle, mainHandAiming, offHandAiming); if (offHandEquip != ___pawn.equipment.Primary) { //drawLoc += offsetMainHand; //aimAngle = mainHandAngle; //__instance.DrawEquipmentAiming(eq, drawLoc + offsetMainHand, mainHandAngle); DrawEquipmentAimingOverride(eq, drawLoc + offsetMainHand, mainHandAngle); } if ((offHandAiming || mainHandAiming) && focusTarg != null) { offHandAngle = GetAimingRotation(___pawn, focusTarg); offsetOffHand.y += 0.1f; Vector3 adjustedDrawPos = ___pawn.DrawPos + new Vector3(0f, 0f, 0.4f).RotatedBy(offHandAngle) + offsetOffHand; DrawEquipmentAimingOverride(offHandEquip, adjustedDrawPos, offHandAngle); } else { DrawEquipmentAimingOverride(offHandEquip, drawLoc + offsetOffHand, offHandAngle); } return(false); }
private void DrawIcons(Rect rect, Pawn colonist) { if (colonist.Dead) { return; } Vector2 vector = new Vector2(rect.x + 1f, rect.yMax - rect.width / 5 * 2 - 1f); bool flag = false; if (colonist.CurJob != null) { JobDef def = colonist.CurJob.def; if (def == JobDefOf.AttackMelee || def == JobDefOf.AttackStatic) { flag = true; } else if (def == JobDefOf.WaitCombat) { Stance_Busy stance_Busy = colonist.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { flag = true; } } } if (colonist.InAggroMentalState) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Aggressive].mainTexture as Texture2D, ref vector, colonist.MentalStateDef.LabelCap); DrawIcon(ColonistBarTextures.Icon_MentalStateAggro, ref vector, colonist.MentalStateDef.LabelCap); } else if (colonist.InMentalState) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Dazed].mainTexture as Texture2D, ref vector, colonist.MentalStateDef.LabelCap); DrawIcon(ColonistBarTextures.Icon_MentalStateNonAggro, ref vector, colonist.MentalStateDef.LabelCap); } else if (colonist.InBed() && colonist.CurrentBed().Medical) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Health].mainTexture as Texture2D, ref vector, "ActivityIconMedicalRest".Translate()); DrawIcon(ColonistBarTextures.Icon_MedicalRest, ref vector, "ActivityIconMedicalRest".Translate()); } else if (colonist.CurJob != null && colonist.jobs.curDriver.asleep) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Tired].mainTexture as Texture2D, ref vector, "ActivityIconSleeping".Translate()); DrawIcon(ColonistBarTextures.Icon_Sleeping, ref vector, "ActivityIconSleeping".Translate()); } else if (colonist.CurJob != null && colonist.CurJob.def == JobDefOf.FleeAndCower) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Leave].mainTexture as Texture2D, ref vector, "ActivityIconFleeing".Translate()); DrawIcon(ColonistBarTextures.Icon_Fleeing, ref vector, "ActivityIconFleeing".Translate()); } else if (flag) { DrawIcon(ColonistBarTextures.Icon_Attacking, ref vector, "ActivityIconAttacking".Translate()); } else if (colonist.mindState.IsIdle && GenDate.DaysPassed >= 1) { // DrawIcon(PSI.PSI.PSIMaterials[Icons.Idle].mainTexture as Texture2D, ref vector, "ActivityIconIdle".Translate()); DrawIcon(ColonistBarTextures.Icon_Idle, ref vector, "ActivityIconIdle".Translate()); } if (false) { PawnStats pawnStats; if (colonist.Dead || colonist.holder != null || !PSI.PSI._statsDict.TryGetValue(colonist, out pawnStats) || colonist.drafter == null || colonist.skills == null) { return; } if (pawnStats.MentalSanity == MentalStateDefOf.BingingDrugMajor || pawnStats.MentalSanity == MentalStateDefOf.BingingDrugExtreme) { Material material = PSI.PSI.PSIMaterials[Icons.Drunk]; DrawIcon(material.mainTexture as Texture2D, ref vector, colonist.MentalStateDef.LabelCap); } } if (colonist.IsBurning()) { DrawIcon(ColonistBarTextures.Icon_Burning, ref vector, "ActivityIconBurning".Translate()); } }
public new void PawnRotatorTick() { if (pawn.Destroyed) { return; } if (pawn.pather.Moving) { if (pawn.pather.curPath == null || pawn.pather.curPath.NodesLeftCount < 1) { return; } FaceAdjacentCell(this, pawn.pather.nextCell); } else { Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { Face(stance_Busy.focusTarg.Thing.DrawPos); } else { FaceCell(stance_Busy.focusTarg.Cell); } return; } if (pawn.jobs.curJob != null) { LocalTargetInfo target = pawn.CurJob.GetTarget(pawn.jobs.curDriver.rotateToFace); if (target.HasThing) { bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = target.Thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (pawn.Position == new IntVec3(j, 0, i)) { Face(target.Thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(pawn.Position)) { FaceAdjacentCell(this, intVec); return; } if (intVec.AdjacentTo8Way(pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } FaceAdjacentCell(this, c); return; } } else if (pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } FaceAdjacentCell(this, target.Cell); return; } } } }
public void DrawIcons(Rect rect, Pawn colonist) { if (colonist.Dead) { return; } tmpIconsToDraw.Clear(); bool flag = false; if (colonist.CurJob != null) { JobDef def = colonist.CurJob.def; if (def == JobDefOf.AttackMelee || def == JobDefOf.AttackStatic) { flag = true; } else if (def == JobDefOf.Wait_Combat) { Stance_Busy stance_Busy = colonist.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { flag = true; } } } if (colonist.IsFormingCaravan()) { tmpIconsToDraw.Add(new IconDrawCall(Icon_FormingCaravan, Strings.ActivityIconFormingCaravan)); } if (colonist.InAggroMentalState) { tmpIconsToDraw.Add(new IconDrawCall(Icon_MentalStateAggro, colonist.MentalStateDef.LabelCap)); } else if (colonist.InMentalState) { tmpIconsToDraw.Add(new IconDrawCall(Icon_MentalStateNonAggro, colonist.MentalStateDef.LabelCap)); } else if (colonist.InBed() && colonist.CurrentBed().Medical) { tmpIconsToDraw.Add(new IconDrawCall(Icon_MedicalRest, Strings.ActivityIconMedicalRest)); } else if (colonist.CurJob != null && colonist.jobs.curDriver.asleep) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Sleeping, Strings.ActivityIconSleeping)); } else if (colonist.CurJob != null && colonist.CurJob.def == JobDefOf.FleeAndCower) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Fleeing, Strings.ActivityIconFleeing)); } else if (flag) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Attacking, Strings.ActivityIconAttacking)); } else if (colonist.mindState.IsIdle && GenDate.DaysPassed >= 1) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Idle, Strings.ActivityIconIdle)); } if (colonist.IsBurning()) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Burning, Strings.ActivityIconBurning)); } if (colonist.Inspired) { tmpIconsToDraw.Add(new IconDrawCall(Icon_Inspired, colonist.InspirationDef.LabelCap)); } if (colonist.IsSlaveOfColony) { tmpIconsToDraw.Add(new IconDrawCall(colonist.guest.GetIcon())); } else { bool flag2 = false; if (colonist.Ideo != null) { Ideo ideo = colonist.Ideo; Precept_Role role = ideo.GetRole(colonist); if (role != null) { tmpIconsToDraw.Add(new IconDrawCall(role.Icon, null, ideo.Color)); flag2 = true; } } if (!flag2) { Faction faction = null; if (colonist.HasExtraMiniFaction()) { faction = colonist.GetExtraMiniFaction(); } else if (colonist.HasExtraHomeFaction()) { faction = colonist.GetExtraHomeFaction(); } if (faction != null) { tmpIconsToDraw.Add(new IconDrawCall(faction.def.FactionIcon, null, faction.Color)); } } } if (!(ModCompatibility.rimworldOfMagicDrawMethod is null)) { ModCompatibility.rimworldOfMagicDrawMethod.Invoke(this, new object[] { null, rect, colonist }); } float num = Mathf.Min(BaseIconAreaWidth / (float)tmpIconsToDraw.Count, BaseIconMaxSize) * TacticUtils.TacticalColonistBar.Scale; Vector2 pos = new Vector2(rect.x + 1f, rect.yMax - num - 1f); foreach (IconDrawCall item in tmpIconsToDraw) { GUI.color = item.color ?? Color.white; DrawIcon(item.texture, ref pos, num, item.tooltip); GUI.color = Color.white; } }
public static bool Prefix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { Traverse traverse = Traverse.Create(__instance); Pawn pp = traverse.Field("pawn").GetValue <Pawn>(); if (pp.kindDef.defName.EqualsIgnoreCase("ra2_rhinotank") || pp.kindDef.defName.EqualsIgnoreCase("ra2_grizzlytank") || pp.kindDef.defName.EqualsIgnoreCase("ra2_apotank")) { Stance_Busy stance_Busy = pp.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { drawLoc -= new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); } else { if (pp.Rotation == Rot4.South) { drawLoc -= new Vector3(0f, 0f, -0.22f); } else if (pp.Rotation == Rot4.North) { drawLoc -= new Vector3(0f, 0f, -0.11f); } else if (pp.Rotation == Rot4.East) { drawLoc -= new Vector3(0.2f, 0f, -0.22f); } else if (pp.Rotation == Rot4.West) { drawLoc -= new Vector3(-0.2f, 0f, -0.22f); } } 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; num -= 180f; num -= eq.def.equippedAngleOffset; } else { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } num %= 360f; if (!pp.TargetCurrentlyAimingAt.IsValid) { //Log.Warning(pp.Rotation+"/"); switch (pp.Rotation.AsInt) { case 0: num = -90f; break; case 1: num = 0f; break; case 2: num = 90f; break; case 3: num = 0f; break; default: num = 0; break; } // num =pp.Rotation.AsAngle- 90f; } 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; } Matrix4x4 matrix = new Matrix4x4(); Vector3 s = new Vector3(pp.kindDef.lifeStages[0].bodyGraphicData.drawSize.x, 1, pp.kindDef.lifeStages[0].bodyGraphicData.drawSize.y); //new Vector3(5,1,5); matrix.SetTRS(drawLoc + new Vector3(0, 1, 0), num.ToQuat(), s); // Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0); Graphics.DrawMesh(mesh, matrix, matSingle, 0); return(false); } return(true); }
public static void DrawMeshModified(Mesh mesh, Vector3 position, Quaternion rotation, Material mat, int layer, Thing eq, float aimAngle) { if (enabled_YayosCombat) { Log.Message("Yayos Oversized"); } CompOversizedWeapon compOversized = eq.TryGetCompFast <CompOversizedWeapon>(); CompEquippable equippable = eq.TryGetCompFast <CompEquippable>(); Pawn pawn = equippable.PrimaryVerb.CasterPawn; if (pawn == null) { return; } if (compOversized == null || (compOversized != null && compOversized.CompDeflectorIsAnimatingNow) || pawn == null || eq == null) { OversizedUtil.Draw(mesh, default(Matrix4x4), mat, layer, eq, pawn, position, rotation); return; } ThingWithComps thingWithComps = eq as ThingWithComps; bool DualWeapon = compOversized.Props != null && compOversized.Props.isDualWeapon; float offHandAngle = aimAngle; float mainHandAngle = aimAngle; Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy; LocalTargetInfo localTargetInfo = null; if (stance_Busy != null && !stance_Busy.neverAimWeapon) { localTargetInfo = stance_Busy.focusTarg; } bool Aiming = OversizedUtil.CurrentlyAiming(stance_Busy); Vector3 offsetMainHand = default(Vector3); Vector3 offsetOffHand = default(Vector3); if (compOversized.Props != null) { OversizedUtil.SetAnglesAndOffsets(eq, thingWithComps, aimAngle, pawn, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, Aiming, DualWeapon && Aiming); } if (DualWeapon) { Vector3 drawLoc = position + offsetMainHand; compOversized.renderPos = drawLoc; PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, eq, drawLoc, offHandAngle, compOversized, equippable, pawn); } if (Aiming && localTargetInfo != null) { mainHandAngle = OversizedUtil.GetAimingRotation(pawn, localTargetInfo); offsetMainHand.y += 0.1f; Vector3 drawLoc2 = pawn.DrawPos + new Vector3(0f, 0f, 0.4f).RotatedBy(mainHandAngle) + (DualWeapon ? offsetOffHand : offsetMainHand); if (DualWeapon) { compOversized.renderPosDual = drawLoc2; } else { compOversized.renderPos = drawLoc2; } PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, thingWithComps, drawLoc2, (DualWeapon ? mainHandAngle : aimAngle), compOversized, equippable, pawn, DualWeapon); } else { Vector3 drawLoc2 = position + (DualWeapon ? offsetOffHand : offsetMainHand); if (DualWeapon) { compOversized.renderPosDual = drawLoc2; } else { compOversized.renderPos = drawLoc2; } PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, thingWithComps, drawLoc2, (DualWeapon ? mainHandAngle : aimAngle), compOversized, equippable, pawn, false); } }
public static bool DrawEquipmentPrefix(PawnRenderer __instance, Pawn ___pawn, Vector3 rootLoc) { if (___pawn.Dead || !___pawn.Spawned) { return(false); } if (___pawn.equipment == null || ___pawn.equipment.Primary == null) { return(false); } if (___pawn.CurJob != null && ___pawn.CurJob.def.neverShowWeapon) { return(false); } Stance_Busy stance_Busy = ___pawn.stances.curStance as Stance_Busy; CompWeaponExtention compW = ___pawn.equipment.Primary.GetComp <CompWeaponExtention>(); CompSheath compSheath = ___pawn.equipment.Primary.GetComp <CompSheath>(); bool busy = (stance_Busy != null) && (!stance_Busy.neverAimWeapon) && (stance_Busy.focusTarg.IsValid); if (busy) { Vector3 drawLoc = rootLoc; Vector3 a; if (stance_Busy.focusTarg.HasThing) { a = stance_Busy.focusTarg.Thing.DrawPos; } else { a = stance_Busy.focusTarg.Cell.ToVector3Shifted(); } float num = 0f; if ((a - ___pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (a - ___pawn.DrawPos).AngleFlat(); } if (compW != null && compW.littleDown) { drawLoc.z += littleDown; } drawLoc += new Vector3(0f, 0f, 0.4f).RotatedBy(num); drawLoc.y += drawYPosition; //DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, num); __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, num); if (compSheath != null) { DrawSheath(compSheath, ___pawn, rootLoc, compSheath.SheathOnlyGraphic); } return(false); } else if ((___pawn.carryTracker == null || ___pawn.carryTracker.CarriedThing == null) && (___pawn.Drafted || (___pawn.CurJob != null && ___pawn.CurJob.def.alwaysShowWeapon) || (___pawn.mindState.duty != null && ___pawn.mindState.duty.def.alwaysShowWeapon))) { Vector3 drawLoc = rootLoc; if (compW != null) { switch (___pawn.Rotation.AsInt) { case 0: drawLoc += compW.Props.northOffset.position; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.northOffset.angle); break; case 1: drawLoc += compW.Props.eastOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.eastOffset.angle); break; case 2: drawLoc += compW.Props.southOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.southOffset.angle); break; case 3: drawLoc += compW.Props.westOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.westOffset.angle); break; default: break; } } else { if (___pawn.Rotation == Rot4.South) { Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc2.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc2, 143f); } else if (___pawn.Rotation == Rot4.North) { Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f); __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc3, 143f); } else if (___pawn.Rotation == Rot4.East) { Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f); drawLoc4.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc4, 143f); } else if (___pawn.Rotation == Rot4.West) { Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f); drawLoc5.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc5, 217f); } } if (compSheath != null) { DrawSheath(compSheath, ___pawn, rootLoc, compSheath.SheathOnlyGraphic); } return(false); } if (!(___pawn.InBed()) && ___pawn.GetPosture() == PawnPosture.Standing) { if (compSheath != null) { Vector3 drawLoc = rootLoc; DrawSheath(compSheath, ___pawn, drawLoc, compSheath.FullGraphic); } } return(false); }
private void DrawEquipment(Vector3 rootLoc, int curLevel, int baseLevel) { if (this.pawn.Dead || !this.pawn.Spawned) { return; } if (this.pawn.equipment == null || this.pawn.equipment.Primary == null) { return; } if (this.pawn.CurJob != null && this.pawn.CurJob.def.neverShowWeapon) { return; } Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { Vector3 a; if (stance_Busy.focusTarg.HasThing) { a = stance_Busy.focusTarg.Thing.DrawPos; } else { a = stance_Busy.focusTarg.Cell.ToVector3Shifted(); } float num = 0f; if ((a - this.pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (a - this.pawn.DrawPos).AngleFlat(); } Vector3 drawLoc = rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); drawLoc.y += 0.03787879f; this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc, num, curLevel, baseLevel); return; } if (this.CarryWeaponOpenly()) { if (this.pawn.Rotation == Rot4.South) { Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); drawLoc2.y += 0.03787879f; this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc2, 143f, curLevel, baseLevel); return; } if (this.pawn.Rotation == Rot4.North) { Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); drawLoc3.y += 0f; this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc3, 143f, curLevel, baseLevel); return; } if (this.pawn.Rotation == Rot4.East) { Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); drawLoc4.y += 0.03787879f; this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc4, 143f, curLevel, baseLevel); return; } if (this.pawn.Rotation == Rot4.West) { Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); drawLoc5.y += 0.03787879f; this.DrawEquipmentAiming(this.pawn.equipment.Primary, drawLoc5, 217f, curLevel, baseLevel); } } }
public static void ReloadWeaponIfEndingCooldown(Stance_Busy __instance) { if (__instance.verb?.EquipmentSource == null) { return; } var pawn = __instance.verb.CasterPawn; if (pawn == null) { return; } var reloadable = __instance.verb.GetReloadable(); if (reloadable == null || reloadable.ShotsRemaining != 0 || pawn.stances.curStance.StanceBusy) { return; } var item = pawn.inventory.innerContainer.FirstOrDefault(t => reloadable.CanReloadFrom(t)); if (item == null) { if (!pawn.IsColonist && reloadable.Parent is ThingWithComps eq && !pawn.equipment.TryDropEquipment(eq, out var result, pawn.Position)) { Log.Message("Failed to drop " + result); } pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); if (pawn.inventory.innerContainer.FirstOrDefault(t => t.def.IsWeapon && t.def.equipmentType == EquipmentType.Primary) is ThingWithComps newWeapon) { if (reloadable.Parent == pawn.equipment.Primary && reloadable.Parent is ThingWithComps oldWeapon) { pawn.inventory.innerContainer.TryAddOrTransfer(oldWeapon, false); } pawn.inventory.innerContainer.TryTransferToContainer(newWeapon, pawn.equipment.GetDirectlyHeldThings(), 1, false); } if (!pawn.IsColonist && (pawn.equipment.Primary?.def.IsMeleeWeapon ?? true)) { pawn.GetLord()?.CurLordToil?.UpdateAllDuties(); } return; } var job = new Job(pawn.CurJobDef, pawn.CurJob.targetA, pawn.CurJob.targetB, pawn.CurJob.targetC) { canUseRangedWeapon = pawn.CurJob.canUseRangedWeapon, verbToUse = __instance.verb, endIfCantShootInMelee = pawn.CurJob.endIfCantShootInMelee }; pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); pawn.jobs.TryTakeOrderedJob(JobGiver_ReloadFromInventory.MakeReloadJob(reloadable, item), JobTag.UnspecifiedLordDuty); if (!pawn.IsColonist) { pawn.GetLord()?.CurLordToil?.UpdateAllDuties(); } else { pawn.jobs.TryTakeOrderedJob(job, JobTag.UnspecifiedLordDuty, true); } }