public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine) { if (targ.HasThing && targ.Thing.Map != caster.Map) { resultingLine = default(ShootLine); return(false); } if (verbProps.IsMeleeAttack || verbProps.range <= 1.42f) { resultingLine = new ShootLine(root, targ.Cell); return(ReachabilityImmediate.CanReachImmediate(root, targ, caster.Map, PathEndMode.Touch, null)); } CellRect cellRect = targ.HasThing ? targ.Thing.OccupiedRect() : CellRect.SingleCell(targ.Cell); float num = verbProps.EffectiveMinRange(targ, caster); float num2 = cellRect.ClosestDistSquaredTo(root); if (num2 > verbProps.range * verbProps.range || num2 < num * num) { resultingLine = new ShootLine(root, targ.Cell); return(false); } if (!verbProps.requireLineOfSight) { resultingLine = new ShootLine(root, targ.Cell); return(true); } IntVec3 goodDest; if (CasterIsPawn) { if (CanHitFromCellIgnoringRange(root, targ, out goodDest)) { resultingLine = new ShootLine(root, goodDest); return(true); } ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), caster.Map, tempLeanShootSources); for (int i = 0; i < tempLeanShootSources.Count; i++) { IntVec3 intVec = tempLeanShootSources[i]; if (CanHitFromCellIgnoringRange(intVec, targ, out goodDest)) { resultingLine = new ShootLine(intVec, goodDest); return(true); } } } else { foreach (IntVec3 item in caster.OccupiedRect()) { if (CanHitFromCellIgnoringRange(item, targ, out goodDest)) { resultingLine = new ShootLine(item, goodDest); return(true); } } } resultingLine = new ShootLine(root, targ.Cell); return(false); }
public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine) { if (targ.HasThing && targ.Thing.Map != this.caster.Map) { resultingLine = default(ShootLine); return(false); } if (this.verbProps.IsMeleeAttack || this.verbProps.range <= 1.42f) { resultingLine = new ShootLine(root, targ.Cell); return(ReachabilityImmediate.CanReachImmediate(root, targ, this.caster.Map, PathEndMode.Touch, null)); } CellRect cellRect = (!targ.HasThing) ? CellRect.SingleCell(targ.Cell) : targ.Thing.OccupiedRect(); float num = this.verbProps.EffectiveMinRange(targ, this.caster); float num2 = cellRect.ClosestDistSquaredTo(root); if (num2 > this.verbProps.range * this.verbProps.range || num2 < num * num) { resultingLine = new ShootLine(root, targ.Cell); return(false); } if (!this.verbProps.requireLineOfSight) { resultingLine = new ShootLine(root, targ.Cell); return(true); } if (this.CasterIsPawn) { IntVec3 dest; if (this.CanHitFromCellIgnoringRange(root, targ, out dest)) { resultingLine = new ShootLine(root, dest); return(true); } ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), this.caster.Map, Verb.tempLeanShootSources); for (int i = 0; i < Verb.tempLeanShootSources.Count; i++) { IntVec3 intVec = Verb.tempLeanShootSources[i]; if (this.CanHitFromCellIgnoringRange(intVec, targ, out dest)) { resultingLine = new ShootLine(intVec, dest); return(true); } } } else { CellRect.CellRectIterator iterator = this.caster.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 intVec2 = iterator.Current; IntVec3 dest; if (this.CanHitFromCellIgnoringRange(intVec2, targ, out dest)) { resultingLine = new ShootLine(intVec2, dest); return(true); } iterator.MoveNext(); } } resultingLine = new ShootLine(root, targ.Cell); return(false); }