public new bool CanHitFromCellIgnoringRange(IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest) { if (targ.Thing != null) { if (targ.Thing.Map != this.Caster.Map) { goodDest = IntVec3.Invalid; return(false); } ShootLeanUtility.CalcShootableCellsOf(Verb_ShootCompMountedCE.tempDestList, targ.Thing); for (int i = 0; i < Verb_ShootCompMountedCE.tempDestList.Count; i++) { if (this.CanHitCellFromCellIgnoringRange(sourceCell, Verb_ShootCompMountedCE.tempDestList[i], targ.Thing.def.Fillage == FillCategory.Full)) { goodDest = Verb_ShootCompMountedCE.tempDestList[i]; return(true); } } } else if (this.CanHitCellFromCellIgnoringRange(sourceCell, targ.Cell, false)) { goodDest = targ.Cell; return(true); } goodDest = IntVec3.Invalid; return(false); }
private static bool CanHitFromCellIgnoringRange2(Verb __instance, IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest) { if (targ.Thing != null) { if (targ.Thing.Map != __instance.caster.Map) { goodDest = IntVec3.Invalid; return(false); } List <IntVec3> tempDestList = new List <IntVec3>(); ShootLeanUtility.CalcShootableCellsOf(tempDestList, targ.Thing); for (int i = 0; i < tempDestList.Count; i++) { if (CanHitCellFromCellIgnoringRange(__instance, sourceCell, tempDestList[i], targ.Thing.def.Fillage == FillCategory.Full)) { goodDest = tempDestList[i]; return(true); } } } else if (CanHitCellFromCellIgnoringRange(__instance, sourceCell, targ.Cell)) { goodDest = targ.Cell; return(true); } goodDest = IntVec3.Invalid; return(false); }
public static bool CanHitFromCellIgnoringRange(Verb __instance, ref bool __result, IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest) { if (targ.Thing != null) { if (targ.Thing.Map != __instance.caster.Map) { goodDest = IntVec3.Invalid; __result = false; return(false); } List <IntVec3> tempDestList = new List <IntVec3>(); ShootLeanUtility.CalcShootableCellsOf(tempDestList, targ.Thing); for (int index = 0; index < tempDestList.Count; ++index) { if (CanHitCellFromCellIgnoringRange(__instance, sourceCell, tempDestList[index], targ.Thing.def.Fillage == FillCategory.Full)) { goodDest = tempDestList[index]; __result = true; return(false); } } } else if (CanHitCellFromCellIgnoringRange(__instance, sourceCell, targ.Cell, false)) { goodDest = targ.Cell; __result = true; return(false); } goodDest = IntVec3.Invalid; __result = false; return(false); }
public static bool CanSee(ref bool __result, Thing seer, Thing target, Func <IntVec3, bool> validator = null) { List <IntVec3> tempDestList = new List <IntVec3>(); List <IntVec3> tempSourceList = new List <IntVec3>(); ShootLeanUtility.CalcShootableCellsOf(tempDestList, target); for (int index = 0; index < tempDestList.Count; ++index) { if (GenSight.LineOfSight(seer.Position, tempDestList[index], seer.Map, true, validator, 0, 0)) { __result = true; return(false); } } ShootLeanUtility.LeanShootingSourcesFromTo(seer.Position, target.Position, seer.Map, tempSourceList); for (int index1 = 0; index1 < tempSourceList.Count; ++index1) { for (int index2 = 0; index2 < tempDestList.Count; ++index2) { if (GenSight.LineOfSight(tempSourceList[index1], tempDestList[index2], seer.Map, true, validator, 0, 0)) { __result = true; return(false); } } } __result = false; return(false); }
private bool CanHitFromCellIgnoringRange(IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest) { if (targ.Thing != null) { if (targ.Thing.Map != this.caster.Map) { goodDest = IntVec3.Invalid; return(false); } // (ProfoundDarkness) I only ever see this code execute for the target, not the shooter... // (ProfoundDarkness) I don't know what I'm doing here so basically if the target has a structure next to them assume they will lean, rather than a more precise and accurate // test. // If the target is near something they might have to lean around to shoot then calculate their leans. // NOTE: CellsAdjacent8Way includes the check for if a location is in map bounds so can use CanBeSeenOverFast. The alternative is fast 8way and slow (bounds checking) CanBeSeenOver. if ((targ.Thing as Pawn)?.CurJob?.def != CE_JobDefOf.HunkerDown && GenAdjFast.AdjacentCells8Way(targ.Thing).FirstOrDefault(c => !c.CanBeSeenOver(targ.Thing.Map)) != null) { ShootLeanUtility.CalcShootableCellsOf(tempDestList, targ.Thing); } else // otherwise just assume that the target won't lean... { tempDestList.Clear(); tempDestList.Add(targ.Cell); } for (int i = 0; i < tempDestList.Count; i++) { if (this.CanHitCellFromCellIgnoringRange(sourceCell, tempDestList[i], targ.Thing, targ.Thing.def.Fillage == FillCategory.Full)) { // if any of the locations the target is at or can lean to for shooting can be shot by the shooter then lets have the shooter shoot. goodDest = tempDestList[i]; return(true); } } } else if (this.CanHitCellFromCellIgnoringRange(sourceCell, targ.Cell, targ.Thing)) { goodDest = targ.Cell; return(true); } goodDest = IntVec3.Invalid; return(false); }
public static bool CanSee(this Thing seer, Thing target, Func <IntVec3, bool> validator = null) { ShootLeanUtility.CalcShootableCellsOf(tempDestList, target); for (int i = 0; i < tempDestList.Count; i++) { if (GenSight.LineOfSight(seer.Position, tempDestList[i], seer.Map, skipFirstCell: true, validator)) { return(true); } } ShootLeanUtility.LeanShootingSourcesFromTo(seer.Position, target.Position, seer.Map, tempSourceList); for (int j = 0; j < tempSourceList.Count; j++) { for (int k = 0; k < tempDestList.Count; k++) { if (GenSight.LineOfSight(tempSourceList[j], tempDestList[k], seer.Map, skipFirstCell: true, validator)) { return(true); } } } return(false); }
public static bool CanSee(this Thing seer, Thing target, Func <IntVec3, bool> validator = null) { // Log.Messageage(seer+" CanSee "+ target+"?"); ShootLeanUtility.CalcShootableCellsOf(tempDestList, target); for (int i = 0; i < tempDestList.Count; i++) { if (GenSight.LineOfSight(seer.Position, tempDestList[i], seer.Map, skipFirstCell: true, validator)) { return(true); } } ShootLeanUtility.LeanShootingSourcesFromTo(seer.Position, target.Position, seer.Map, tempSourceList); if (seer is Building) { IntVec2 size = new IntVec2(seer.def.Size.x + 2, seer.def.Size.z + 2); foreach (IntVec3 intVec2 in GenAdj.OccupiedRect(seer.Position, seer.Rotation, size)) { if (!tempSourceList.Contains(intVec2)) { tempSourceList.Add(intVec2); } } } for (int j = 0; j < tempSourceList.Count; j++) { for (int k = 0; k < tempDestList.Count; k++) { if (GenSight.LineOfSight(tempSourceList[j], tempDestList[k], seer.Map, skipFirstCell: true, validator)) { return(true); } } } // Log.Messageage(seer + " CanSee " + target + ": FALSE"); return(false); }