// Token: 0x0600004A RID: 74 RVA: 0x00003EE8 File Offset: 0x000020E8 private void CheckForAutoAttack() { bool downed = this.pawn.Downed; if (!downed) { bool fullBodyBusy = this.pawn.stances.FullBodyBusy; if (!fullBodyBusy) { bool flag = this.pawn.jobs.jobQueue != null; if (!flag) { bool flag2 = this.pawn.Faction != null && this.pawn.jobs.curJob.def == WPJobDefOf.ArtyWaitCombat; if (flag2) { Verb currentEffectiveVerb = this.pawn.CurrentEffectiveVerb; bool flag3 = currentEffectiveVerb != null && !currentEffectiveVerb.verbProps.IsMeleeAttack; if (flag3) { TargetScanFlags targetScanFlags = TargetScanFlags.None; bool flag4 = currentEffectiveVerb.IsIncendiary(); if (flag4) { targetScanFlags |= TargetScanFlags.NeedNonBurning; } Thing thing = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(this.pawn, targetScanFlags, null, 0f, 9999f); bool flag5 = thing != null; if (flag5) { this.pawn.TryStartAttack(thing); this.collideWithPawns = true; } } } } } } }
private void CheckForAutoAttack() { if (this.pawn.Downed) { return; } if (this.pawn.stances.FullBodyBusy) { return; } this.collideWithPawns = false; bool flag = this.pawn.story == null || !this.pawn.story.WorkTagIsDisabled(WorkTags.Violent); bool flag2 = this.pawn.RaceProps.ToolUser && this.pawn.Faction == Faction.OfPlayer && !this.pawn.story.WorkTagIsDisabled(WorkTags.Firefighting); if (flag || flag2) { Fire fire = null; for (int i = 0; i < 9; i++) { IntVec3 c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[i]; if (c.InBounds(this.pawn.Map)) { List <Thing> thingList = c.GetThingList(base.Map); for (int j = 0; j < thingList.Count; j++) { if (flag) { Pawn pawn = thingList[j] as Pawn; if (pawn != null && !pawn.Downed && this.pawn.HostileTo(pawn)) { this.pawn.meleeVerbs.TryMeleeAttack(pawn, null, false); this.collideWithPawns = true; return; } } if (flag2) { Fire fire2 = thingList[j] as Fire; if (fire2 != null && (fire == null || fire2.fireSize < fire.fireSize || i == 8) && (fire2.parent == null || fire2.parent != this.pawn)) { fire = fire2; } } } } } if (fire != null && (!this.pawn.InMentalState || this.pawn.MentalState.def.allowBeatfire)) { this.pawn.natives.TryBeatFire(fire); return; } if (flag && this.pawn.Faction != null && this.job.def == JobDefOf.Wait_Combat && (this.pawn.drafter == null || this.pawn.drafter.FireAtWill)) { Verb currentEffectiveVerb = this.pawn.CurrentEffectiveVerb; if (currentEffectiveVerb != null && !currentEffectiveVerb.verbProps.IsMeleeAttack) { TargetScanFlags targetScanFlags = TargetScanFlags.NeedLOSToPawns | TargetScanFlags.NeedLOSToNonPawns | TargetScanFlags.NeedThreat; if (currentEffectiveVerb.IsIncendiary()) { targetScanFlags |= TargetScanFlags.NeedNonBurning; } Thing thing = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(this.pawn, targetScanFlags, null, 0f, 9999f); if (thing != null) { this.pawn.TryStartAttack(thing); this.collideWithPawns = true; return; } } } } }
private void CheckForAutoAttack() { if (pawn.Downed) { return; } //Don't auto-attack while warming up etc if (pawn.stances.FullBodyBusy) { return; } collideWithPawns = false; //Note: While bursting, there seems to be a gap where the pawn becomes mobile? bool canDoViolence = pawn.story == null || !pawn.story.WorkTagIsDisabled(WorkTags.Violent); bool shouldFightFires = pawn.RaceProps.ToolUser && pawn.Faction == Faction.OfPlayer && !pawn.story.WorkTagIsDisabled(WorkTags.Firefighting); if (canDoViolence || shouldFightFires) { //Melee attack adjacent enemy pawns //Barring that, put out fires Fire targetFire = null; for (int i = 0; i < 9; i++) { IntVec3 neigh = pawn.Position + GenAdj.AdjacentCellsAndInside[i]; if (!neigh.InBounds(pawn.Map)) { continue; } var things = neigh.GetThingList(Map); for (int j = 0; j < things.Count; j++) { if (canDoViolence) { //We just hit the first pawn we see (north first) Pawn otherPawn = things[j] as Pawn; if (otherPawn != null && !otherPawn.Downed && pawn.HostileTo(otherPawn)) { pawn.meleeVerbs.TryMeleeAttack(otherPawn); collideWithPawns = true; return; } } //Prioritize the fire we're standing on. //If there isn't one, prioritize the smallest fire //This algorithm assumes that the inside cell is last if (shouldFightFires) { Fire fire = things[j] as Fire; if (fire != null && (targetFire == null || fire.fireSize < targetFire.fireSize || i == 8) && (fire.parent == null || fire.parent != pawn)) { targetFire = fire; } } } } //We didn't do a melee attack, so see if we found a fire to beat if (targetFire != null && (!pawn.InMentalState || pawn.MentalState.def.allowBeatfire)) { pawn.natives.TryBeatFire(targetFire); return; } //Shoot at the closest enemy in range if (canDoViolence && pawn.Faction != null && job.def == JobDefOf.Wait_Combat && (pawn.drafter == null || pawn.drafter.FireAtWill)) { var attackVerb = pawn.CurrentEffectiveVerb; if (attackVerb != null && !attackVerb.verbProps.IsMeleeAttack) { //We increase the range because we can hit targets slightly outside range by shooting at their ShootableSquares //We could just put the range at int.MaxValue but this is slightly more optimized so whatever var flags = TargetScanFlags.NeedLOSToAll | TargetScanFlags.NeedThreat; if (attackVerb.IsIncendiary()) { flags |= TargetScanFlags.NeedNonBurning; } var curTarg = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(pawn, flags); if (curTarg != null) { pawn.TryStartAttack(curTarg); collideWithPawns = true; return; } } } } }
private void CheckForAutoAttack() { if (!base.pawn.Downed && !base.pawn.stances.FullBodyBusy) { bool flag = base.pawn.story == null || !base.pawn.story.WorkTagIsDisabled(WorkTags.Violent); bool flag2 = base.pawn.RaceProps.ToolUser && base.pawn.Faction == Faction.OfPlayer && !base.pawn.story.WorkTagIsDisabled(WorkTags.Firefighting); if (!flag && !flag2) { return; } Fire fire = null; for (int i = 0; i < 9; i++) { IntVec3 c = base.pawn.Position + GenAdj.AdjacentCellsAndInside[i]; if (c.InBounds(base.pawn.Map)) { List <Thing> thingList = c.GetThingList(base.Map); for (int j = 0; j < thingList.Count; j++) { if (flag) { Pawn pawn = thingList[j] as Pawn; if (pawn != null && !pawn.Downed && base.pawn.HostileTo(pawn)) { base.pawn.meleeVerbs.TryMeleeAttack(pawn, null, false); return; } } if (flag2) { Fire fire2 = thingList[j] as Fire; if (fire2 != null && (fire == null || fire2.fireSize < fire.fireSize || i == 8) && (fire2.parent == null || fire2.parent != base.pawn)) { fire = fire2; } } } } } if (fire != null && (!base.pawn.InMentalState || base.pawn.MentalState.def.allowBeatfire)) { base.pawn.natives.TryBeatFire(fire); } else if (flag && base.pawn.Faction != null && base.job.def == JobDefOf.WaitCombat) { if (base.pawn.drafter != null && !base.pawn.drafter.FireAtWill) { return; } bool allowManualCastWeapons = !base.pawn.IsColonist; Verb verb = base.pawn.TryGetAttackVerb(allowManualCastWeapons); if (verb != null && !verb.verbProps.MeleeRange) { TargetScanFlags targetScanFlags = TargetScanFlags.NeedLOSToPawns | TargetScanFlags.NeedLOSToNonPawns | TargetScanFlags.NeedThreat; if (verb.IsIncendiary()) { targetScanFlags |= TargetScanFlags.NeedNonBurning; } Thing thing = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(base.pawn, null, verb.verbProps.range, verb.verbProps.minRange, targetScanFlags); if (thing != null) { base.pawn.TryStartAttack(thing); } } } } }
private void CheckForAutoAttack() { if (base.pawn.Downed || base.pawn.stances.FullBodyBusy) { return; } collideWithPawns = false; bool flag = !base.pawn.WorkTagIsDisabled(WorkTags.Violent); bool flag2 = base.pawn.RaceProps.ToolUser && base.pawn.Faction == Faction.OfPlayer && !base.pawn.WorkTagIsDisabled(WorkTags.Firefighting); if (!(flag || flag2)) { return; } Fire fire = null; for (int i = 0; i < 9; i++) { IntVec3 c = base.pawn.Position + GenAdj.AdjacentCellsAndInside[i]; if (!c.InBounds(base.pawn.Map)) { continue; } List <Thing> thingList = c.GetThingList(base.Map); for (int j = 0; j < thingList.Count; j++) { if (flag) { Pawn pawn = thingList[j] as Pawn; if (pawn != null && !pawn.Downed && base.pawn.HostileTo(pawn) && GenHostility.IsActiveThreatTo(pawn, base.pawn.Faction)) { base.pawn.meleeVerbs.TryMeleeAttack(pawn); collideWithPawns = true; return; } } if (flag2) { Fire fire2 = thingList[j] as Fire; if (fire2 != null && (fire == null || fire2.fireSize < fire.fireSize || i == 8) && (fire2.parent == null || fire2.parent != base.pawn)) { fire = fire2; } } } } if (fire != null && (!base.pawn.InMentalState || base.pawn.MentalState.def.allowBeatfire)) { base.pawn.natives.TryBeatFire(fire); } else { if (!flag || !job.canUseRangedWeapon || base.pawn.Faction == null || job.def != JobDefOf.Wait_Combat || (base.pawn.drafter != null && !base.pawn.drafter.FireAtWill)) { return; } Verb currentEffectiveVerb = base.pawn.CurrentEffectiveVerb; if (currentEffectiveVerb != null && !currentEffectiveVerb.verbProps.IsMeleeAttack) { TargetScanFlags targetScanFlags = TargetScanFlags.NeedLOSToAll | TargetScanFlags.NeedThreat | TargetScanFlags.NeedAutoTargetable; if (currentEffectiveVerb.IsIncendiary()) { targetScanFlags |= TargetScanFlags.NeedNonBurning; } Thing thing = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(base.pawn, targetScanFlags); if (thing != null) { base.pawn.TryStartAttack(thing); collideWithPawns = true; } } } }