public static void SetStancesOffHand(this Pawn instance, Pawn_StanceTracker stancesOffHand) { if (Base.Instance.GetExtendedDataStorage() is ExtendedDataStorage store) { store.GetExtendedDataFor(instance).stancesOffhand = stancesOffHand; } }
public override void Tick() { if (this.tickCounter == 0) { this.PerformPreFiringTreatment(); } if (this.tickCounter < this.Props.TickOffset) { this.GetPreFiringDrawingParameters(); } else { if (this.tickCounter == this.Props.TickOffset) { this.Fire(); } this.GetPostFiringDrawingParameters(); } if (this.tickCounter == this.Props.TickOffset + this.Props.TickOffsetSecond) { base.Tick(); this.Destroy(0); } Pawn pawn = this.launcher as Pawn; if (pawn != null) { Pawn_StanceTracker stances = pawn.stances; if (stances != null && (!(stances.curStance is Stance_Busy) || pawn.Dead)) { this.Destroy(0); } } this.tickCounter++; }
static void Prefix(Pawn_StanceTracker __instance, ref int ticks) { if (__instance.pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Juggernaut) ?? false) { ticks = 0; } }
public static bool FullBodyAndOffHandBusy(Pawn_StanceTracker instance) { if (instance.pawn.GetStancesOffHand() is Pawn_StanceTracker stOffHand && instance.pawn.equipment != null && instance.pawn.equipment.TryGetOffHandEquipment(out ThingWithComps twc)) { return(stOffHand.FullBodyBusy && instance.FullBodyBusy); } return(instance.FullBodyBusy); }
private void Init() { pather = new Pawn_PathFollower(this); stances = new Pawn_StanceTracker(this); health = new Pawn_HealthTracker(this); jobs = new Pawn_JobTracker(this); filth = new Pawn_FilthTracker(this); }
public static void Postfix(Pawn_StanceTracker __instance) { if (!(__instance.curStance is Stance_PsiWarmup)) { return; } __instance.SetStance(new Stance_Mobile()); }
// Token: 0x0600001E RID: 30 RVA: 0x000033E8 File Offset: 0x000015E8 internal static float GetGunFlashEff(Pawn pawn, Pawn seer) { if (pawn != null && (pawn?.Map) != null && seer != null && (seer?.Map) != null && (pawn?.Map) == (seer?.Map)) { Verb verb = pawn?.CurrentEffectiveVerb; if (verb != null && !verb.IsMeleeAttack) { float muzzleFlashScale = verb.verbProps.muzzleFlashScale; if (muzzleFlashScale > 0f) { int burstShotCount = verb.verbProps.burstShotCount; if (burstShotCount > 0) { bool flag; if (pawn == null) { flag = (null != null); } else { Pawn_StanceTracker stances = pawn.stances; flag = ((stances?.curStance) != null); } if (flag && pawn.stances.curStance is Stance_Cooldown) { float num = 1f; float num2 = Mathf.Lerp(1f, 1.25f, Math.Min(1f, muzzleFlashScale / 7f)) * num; float num3 = Mathf.Lerp(1f, 1.15f, (float)(Math.Min(burstShotCount, 5) / 5)); if (CamoUtility.IsDebugMode()) { string text = string.Concat(new string[] { "RF: ", num.ToString("F2"), ", FF: ", num2.ToString("F2"), " BF: ", num3.ToString("F2") }); text = string.Concat(new string[] { text, "flash: MFS: ", muzzleFlashScale.ToString("F2"), ", maxburst: ", burstShotCount.ToString() }); Log.Message(text, false); } return(1f * num2 * num3); } } } } } return(1f); }
// Token: 0x06000008 RID: 8 RVA: 0x00002164 File Offset: 0x00000364 public override void Tick() { bool flag = this.tickCounter == 0; if (flag) { this.PerformPreFiringTreatment(); } bool flag2 = this.tickCounter < this.Props.TickOffset; if (flag2) { this.GetPreFiringDrawingParameters(); } else { bool flag3 = this.tickCounter == this.Props.TickOffset; if (flag3) { this.Fire(); } this.GetPostFiringDrawingParameters(); } bool flag4 = this.tickCounter == this.Props.TickOffset + this.Props.TickOffsetSecond; if (flag4) { base.Tick(); this.Destroy(DestroyMode.Vanish); } Thing launcher = this.launcher; Pawn pawn = launcher as Pawn; Pawn_StanceTracker stances = new Pawn_StanceTracker(pawn); bool flag5; if (pawn != null) { stances = pawn.stances; flag5 = (stances != null); } else { flag5 = false; } bool flag6 = flag5; if (flag6) { Stance curStance = stances.curStance; bool flag7 = !(curStance is Stance_Busy) || pawn.Dead; if (flag7) { this.Destroy(DestroyMode.Vanish); } } this.tickCounter++; }
static void Postfix(Pawn_StanceTracker __instance, ref bool __result) { if (__result) { return; } else { __result = FullBodyBusyOrOffHandCooldown(__instance); } }
// Token: 0x06000008 RID: 8 RVA: 0x00002164 File Offset: 0x00000364 public override void Tick() { if (tickCounter == 0) { PerformPreFiringTreatment(); } if (tickCounter < Props.TickOffset) { GetPreFiringDrawingParameters(); } else { if (tickCounter == Props.TickOffset) { Fire(); } GetPostFiringDrawingParameters(); } if (tickCounter == Props.TickOffset + Props.TickOffsetSecond) { base.Tick(); Destroy(); } var thing = launcher; var pawn = thing as Pawn; var stances = new Pawn_StanceTracker(pawn); bool b; if (pawn != null) { stances = pawn.stances; b = stances != null; } else { b = false; } if (b) { var curStance = stances.curStance; if (!(curStance is Stance_Busy) || pawn.Dead) { Destroy(); } } tickCounter++; }
public static bool FullBodyBusyOrOffHandCooldown(Pawn_StanceTracker instance) { bool result = false; Pawn pawn = instance.pawn; if (pawn.GetStancesOffHand() is Pawn_StanceTracker stancesOffHand) { if (pawn.GetStancesOffHand() is Pawn_StanceTracker offHandStance && offHandStance.curStance is Stance_Cooldown && !RunAndGunEnabled(pawn)) { result = stancesOffHand.curStance.StanceBusy; } } return(result); }
public static bool CurrentHandBusy(Pawn_StanceTracker instance, Verb verb) { Pawn pawn = instance.pawn; if (verb.EquipmentSource == null || !verb.EquipmentSource.IsOffHand()) { return(pawn.stances.FullBodyBusy); } else if (pawn.GetStancesOffHand() is Pawn_StanceTracker stancesOffHand) { return(!verb.Available() || stancesOffHand.curStance.StanceBusy); } return(false); }
public static void SetStanceRunAndGun(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance) { if (stanceTracker.pawn.equipment == null) { stanceTracker.SetStance(stance); return; } if (stanceTracker.pawn.equipment.Primary == stance.verb.EquipmentSource || stance.verb.EquipmentSource == null) { if ((((stanceTracker.curStance is Stance_RunAndGun) || (stanceTracker.curStance is Stance_RunAndGun_Cooldown))) && stanceTracker.pawn.pather.Moving) { stanceTracker.SetStance(new Stance_RunAndGun_Cooldown(stance.ticksLeft, stance.focusTarg, stance.verb)); } else { stanceTracker.SetStance(stance); } } }
public static void SetStanceOffHand(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance) { ThingWithComps offHandEquip = null; CompEquippable compEquippable = null; if (stance.verb.EquipmentSource != null && Base.Instance.GetExtendedDataStorage().TryGetExtendedDataFor(stance.verb.EquipmentSource, out ExtendedThingWithCompsData twcdata) && twcdata.isOffHand) { offHandEquip = stance.verb.EquipmentSource; compEquippable = offHandEquip.TryGetComp <CompEquippable>(); } //Check if verb is one from a offhand weapon. if (compEquippable != null && offHandEquip != stanceTracker.pawn.equipment.Primary) //TODO: check this code { stanceTracker.pawn.GetStancesOffHand().SetStance(stance); } else if (!(stanceTracker.curStance is Stance_Cooldown) && stanceTracker.curStance.GetType().Name != "Stance_RunAndGun_Cooldown") { stanceTracker.SetStance(stance); } }
public static bool FullBodyBusyOrOffHandCooldown(Pawn_StanceTracker instance) { bool result = false; Pawn pawn = instance.pawn; if (pawn.stances.FullBodyBusy) { return(true); } if (pawn.GetStancesOffHand() is Pawn_StanceTracker stancesOffHand) { bool runAndGunEnabled = false; if (pawn.AllComps.FirstOrDefault((ThingComp tc) => tc.GetType().Name == "CompRunAndGun") is ThingComp comp) { runAndGunEnabled = Traverse.Create(comp).Field("isEnabled").GetValue <bool>(); } if (pawn.GetStancesOffHand() is Pawn_StanceTracker offHandStance && offHandStance.curStance is Stance_Cooldown && !runAndGunEnabled) { result = stancesOffHand.curStance.StanceBusy; } } return(result); }
//When Run and Gun or the to be patched method isn't found, patch this stub method so no error is thrown. public static void Stub(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance) { //Do nothing }
static void Postfix(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance) { //Make sure this is called when run and gun patches the same line of code as we do in the harmony Patch Verb_TryCastNextBurstShot. //SetStanceOffHand(stanceTracker, stance); Verb_TryCastNextBurstShot.SetStanceOffHand(stanceTracker, stance); }
public override void VerbTickCE() { //if (CasterPawn != null) //{ //List<IntVec3> cheese = CasterPawn.CellsAdjacent8WayAndInside().ToList(); //if (cheese != null) //{ //if (this.CasterPawn.jobs.posture != PawnPosture.Standing) //{ //this.CasterPawn.jobs.posture = PawnPosture.Standing; //} //foreach (IntVec3 element in cheese) //{ //if (element != null) //{ //if (Verse.GridsUtility.GetCover(element, CasterPawn.Map) != null) //{ //Building ting = Verse.GridsUtility.GetCover(element, CasterPawn.Map) as Building; //float flat = ting.def.fillPercent; //if (this.CasterPawn.jobs.posture != PawnPosture.Standing) //{ //this.CasterPawn.jobs.posture = PawnPosture.Standing; //} //Log.Error(Verse.GridsUtility.GetCover(element, CasterPawn.Map).ToString()); //} //else //{ //if (!CasterPawn.pather.MovingNow) //{ //if (BipodComp.BipodSetUp) //{ //this.CasterPawn.jobs.posture = PawnPosture.LayingOnGroundNormal; //} //} //} //} //} //} //else //{ //Log.Error("cheesent"); //} //} //CasterPawn.cell if (BipodComp.Props.Recoilchange == this.VerbPropsCE.recoilAmount) { Log.Error(this.VerbPropsCE.recoilAmount.ToString()); } if (CasterPawn != null) { if (BipodComp.BipodSetUp) { this.VerbPropsCE.recoilAmount = BipodComp.Props.Recoilchange; } else { this.VerbPropsCE.recoilAmount = BipodComp.InitRecoil; } } if (!Myself.TryGetComp <Biped2>().shoe) { if (Myself.ParentHolder != Myself.Map) { if (CasterPawn != null) { if (daPawn != null) { if (daPawn.pather.Moving) { Myself.TryGetComp <Biped2>().BipodSetUp = false; } if (daPawn.Drafted) { if (Myself.TryGetComp <Biped2>().ShouldSetUpBipodGizmoBool) { if (!daPawn.pather.Moving) { if (!daPawn.pather.MovingNow) { ThinkNode jobGiver = null; Pawn_JobTracker jobs = this.CasterPawn.jobs; Job job = this.TryMakeBipodJob(); Job newJob = job; JobCondition lastJobEndCondition = JobCondition.InterruptForced; Job curJob = this.CasterPawn.CurJob; if (jobs.curJob != job) { if (Myself.TryGetComp <Biped2>().BipodSetUp != true) { jobs.StartJob(newJob, lastJobEndCondition, jobGiver, ((curJob != null) ? curJob.def : null) != job.def, true, null, null, false, false); } } } } } } } } } } bool isAiming = this._isAiming; if (isAiming) { bool flag = !this.ShouldAim; if (flag) { this.WarmupComplete(); } bool flag2; if (!(this.caster is Building_TurretGunCE)) { Pawn shooterPawn = base.ShooterPawn; Type left; if (shooterPawn == null) { left = null; } else { Pawn_StanceTracker stances = shooterPawn.stances; if (stances == null) { left = null; } else { Stance curStance = stances.curStance; left = ((curStance != null) ? curStance.GetType() : null); } } flag2 = (left != typeof(Stance_Warmup)); } else { flag2 = false; } bool flag3 = flag2; if (flag3) { this._isAiming = false; } } }
// Token: 0x0600001C RID: 28 RVA: 0x000031E8 File Offset: 0x000013E8 internal static float GetMiscFactor(Pawn target, Pawn seer, bool ActiveCamo) { float num = 1f; bool flag = StealthyBox.IsWearingStealthBox(target, out _); if (flag) { num *= 0.5f; } bool flag2; if (target == null) { flag2 = (null != null); } else { Pawn_StanceTracker stances = target.stances; flag2 = ((stances?.curStance) != null); } if (flag2) { if (!target.Downed) { if (target.stances.curStance is Stance_Mobile) { if (flag) { num *= 1.5f; } else { num *= 1.1f; } if (CamoUtility.IsInsectoid(seer)) { num *= 1.25f; } } else if (target.stances.curStance is Stance_Cooldown || target.stances.curStance is Stance_Warmup) { num *= 0.95f; if (CamoUtility.IsInsectoid(seer)) { num *= 0.75f; } } } else { num *= 0.5f; if (CamoUtility.IsInsectoid(seer)) { num *= 0.75f; } } } if (Controller.Settings.DoCheckWeather && (target?.Map) != null) { float accuracyMultiplier = target.Map.weatherManager.curWeather.accuracyMultiplier; if (accuracyMultiplier != 1f) { num *= accuracyMultiplier; } } if (Controller.Settings.DoCheckLight && !ActiveCamo) { PsychGlow psychGlow = target.Map.glowGrid.PsychGlowAt(target.Position); if (psychGlow == PsychGlow.Overlit) { num *= 1.15f; } else { num *= 0.8f; } PsychGlow psychGlow2 = seer.Map.glowGrid.PsychGlowAt(seer.Position); if (psychGlow2 == PsychGlow.Overlit) { num *= 0.85f; } else { num *= 1.2f; } } if (Controller.Settings.DoCheckTemp) { float temperature = GridsUtility.GetTemperature(target.Position, target.Map); float num2 = 21f; if (temperature > num2) { num *= Mathf.Lerp(1f, 0.85f, (temperature - num2) / temperature); } } return(num); }
private static bool ShouldSetStance(bool original, Pawn_StanceTracker stanceTracker, Stance_Cooldown stance) { // Also factor in off-hand shield return(original || stanceTracker.pawn.OffHandShield() == stance.verb.EquipmentSource); }
public static bool StartJob(Pawn_JobTracker __instance, Job newJob, JobCondition lastJobEndCondition = JobCondition.None, ThinkNode jobGiver = null, bool resumeCurJobAfterwards = false, bool cancelBusyStances = true, ThinkTreeDef thinkTree = null, JobTag?tag = null, bool fromQueue = false, bool canReturnCurJobToPool = false) { __instance.startingNewJob = true; try { if (!fromQueue && (!Find.TickManager.Paused || __instance.lastJobGivenAtFrame == RealTime.frameCount)) { ++__instance.jobsGivenThisTick; if (Prefs.DevMode) { __instance.jobsGivenThisTickTextual = __instance.jobsGivenThisTickTextual + "(" + newJob.ToString() + ") "; } } __instance.lastJobGivenAtFrame = RealTime.frameCount; if (__instance.jobsGivenThisTick > 10) { string givenThisTickTextual = __instance.jobsGivenThisTickTextual; __instance.jobsGivenThisTick = 0; __instance.jobsGivenThisTickTextual = ""; __instance.startingNewJob = false; __instance.pawn.ClearReservationsForJob(newJob); JobUtility.TryStartErrorRecoverJob(__instance.pawn, __instance.pawn.ToStringSafe <Pawn>() + " started 10 jobs in one tick. newJob=" + newJob.ToStringSafe <Job>() + " jobGiver=" + jobGiver.ToStringSafe <ThinkNode>() + " jobList=" + givenThisTickTextual); } else { if (__instance.debugLog) { __instance.DebugLogEvent("StartJob [" + (object)newJob + "] lastJobEndCondition=" + (object)lastJobEndCondition + ", jobGiver=" + (object)jobGiver + ", cancelBusyStances=" + cancelBusyStances.ToString()); } Pawn_StanceTracker stances = __instance.pawn.stances; //changed if (cancelBusyStances && stances != null && stances.FullBodyBusy) //changed { stances.CancelBusyStanceHard(); } if (__instance.curJob != null) { if (lastJobEndCondition == JobCondition.None) { Log.Warning(__instance.pawn.ToString() + " starting job " + (object)newJob + " from JobGiver " + (object)newJob.jobGiver + " while already having job " + (object)__instance.curJob + " without a specific job end condition."); lastJobEndCondition = JobCondition.InterruptForced; } if (resumeCurJobAfterwards && __instance.curJob.def.suspendable) { __instance.jobQueue.EnqueueFirst(__instance.curJob); if (__instance.debugLog) { __instance.DebugLogEvent(" JobQueue EnqueueFirst curJob: " + (object)__instance.curJob); } __instance.CleanupCurrentJob(lastJobEndCondition, false, cancelBusyStances); } else { __instance.CleanupCurrentJob(lastJobEndCondition, true, cancelBusyStances, canReturnCurJobToPool); } } if (newJob == null) { Log.Warning(__instance.pawn.ToString() + " tried to start doing a null job."); } else { newJob.startTick = Find.TickManager.TicksGame; if (__instance.pawn.Drafted || newJob.playerForced) { newJob.ignoreForbidden = true; newJob.ignoreDesignations = true; } __instance.curJob = newJob; __instance.curJob.jobGiverThinkTree = thinkTree; __instance.curJob.jobGiver = jobGiver; JobDriver cDriver = __instance.curJob.MakeDriver(__instance.pawn); //changed __instance.curDriver = cDriver; //changed bool flag = fromQueue; if (__instance.curDriver.TryMakePreToilReservations(!flag)) { Job newJob1 = __instance.TryOpportunisticJob(newJob); if (newJob1 != null) { __instance.jobQueue.EnqueueFirst(newJob); __instance.curJob = (Job)null; __instance.curDriver = (JobDriver)null; __instance.StartJob(newJob1); } else { if (tag.HasValue) { __instance.pawn.mindState.lastJobTag = tag.Value; } cDriver.SetInitialPosture(); //changed cDriver.Notify_Starting(); //changed cDriver.SetupToils(); //changed cDriver.ReadyForNextToil(); //changed } } else if (flag) { __instance.EndCurrentJob(JobCondition.QueuedNoLongerValid); } else { Log.Warning("TryMakePreToilReservations() returned false for a non-queued job right after StartJob(). This should have been checked before. curJob=" + __instance.curJob.ToStringSafe <Job>()); __instance.EndCurrentJob(JobCondition.Errored); } } } } finally { __instance.startingNewJob = false; } return(false); }