public static bool TryGetAirTemperatureAroundThing(Thing t, out float temperature) { float num = 0f; int num2 = 0; List <IntVec3> list = GenAdjFast.AdjacentCells8Way(t); for (int i = 0; i < list.Count; i++) { float num3; if (list[i].InBounds(t.Map) && GenTemperature.TryGetDirectAirTemperatureForCell(list[i], t.Map, out num3)) { num += num3; num2++; } } bool result; if (num2 > 0) { temperature = num / (float)num2; result = true; } else { temperature = 21f; result = false; } return(result); }
public static List <IntVec3> AdjacentCellsCardinal(LocalTargetInfo pack) { if (pack.HasThing) { return(GenAdjFast.AdjacentCellsCardinal((Thing)pack)); } return(GenAdjFast.AdjacentCellsCardinal((IntVec3)pack)); }
public static List <IntVec3> AdjacentCells8Way(IntVec3 thingCenter, Rot4 thingRot, IntVec2 thingSize) { if (thingSize.x == 1 && thingSize.z == 1) { return(GenAdjFast.AdjacentCells8Way(thingCenter)); } if (GenAdjFast.working) { throw new InvalidOperationException("GenAdjFast is already working."); } GenAdjFast.resultList.Clear(); GenAdjFast.working = true; GenAdj.AdjustForRotation(ref thingCenter, ref thingSize, thingRot); int num = thingCenter.x - (thingSize.x - 1) / 2 - 1; int num2 = num + thingSize.x + 1; int num3 = thingCenter.z - (thingSize.z - 1) / 2 - 1; int num4 = num3 + thingSize.z + 1; IntVec3 item = new IntVec3(num - 1, 0, num3); while (true) { item.x++; GenAdjFast.resultList.Add(item); if (item.x >= num2) { break; } } while (true) { item.z++; GenAdjFast.resultList.Add(item); if (item.z >= num4) { break; } } while (true) { item.x--; GenAdjFast.resultList.Add(item); if (item.x <= num) { break; } } while (true) { item.z--; GenAdjFast.resultList.Add(item); if (item.z <= num3 + 1) { break; } } GenAdjFast.working = false; return(GenAdjFast.resultList); }
public static List <IntVec3> AdjacentCellsCardinal(LocalTargetInfo pack) { List <IntVec3> result; if (pack.HasThing) { result = GenAdjFast.AdjacentCellsCardinal((Thing)pack); } else { result = GenAdjFast.AdjacentCellsCardinal((IntVec3)pack); } return(result); }
public static List <IntVec3> AdjacentCellsCardinal(IntVec3 thingCenter, Rot4 thingRot, IntVec2 thingSize) { List <IntVec3> result; if (thingSize.x == 1 && thingSize.z == 1) { result = GenAdjFast.AdjacentCellsCardinal(thingCenter); } else { if (GenAdjFast.working) { throw new InvalidOperationException("GenAdjFast is already working."); } GenAdjFast.resultList.Clear(); GenAdjFast.working = true; GenAdj.AdjustForRotation(ref thingCenter, ref thingSize, thingRot); int num = thingCenter.x - (thingSize.x - 1) / 2 - 1; int num2 = num + thingSize.x + 1; int num3 = thingCenter.z - (thingSize.z - 1) / 2 - 1; int num4 = num3 + thingSize.z + 1; IntVec3 item = new IntVec3(num, 0, num3); do { item.x++; GenAdjFast.resultList.Add(item); }while (item.x < num2 - 1); item.x++; do { item.z++; GenAdjFast.resultList.Add(item); }while (item.z < num4 - 1); item.z++; do { item.x--; GenAdjFast.resultList.Add(item); }while (item.x > num + 1); item.x--; do { item.z--; GenAdjFast.resultList.Add(item); }while (item.z > num3 + 1); GenAdjFast.working = false; result = GenAdjFast.resultList; } return(result); }
public static void AdjacentThings8Way(Thing thing, List <Thing> outThings) { outThings.Clear(); if (thing.Spawned) { Map map = thing.Map; List <IntVec3> list = GenAdjFast.AdjacentCells8Way(thing); for (int i = 0; i < list.Count; i++) { List <Thing> thingList = list[i].GetThingList(map); for (int j = 0; j < thingList.Count; j++) { if (!outThings.Contains(thingList[j])) { outThings.Add(thingList[j]); } } } } }
public static bool TryGetAirTemperatureAroundThing(Thing t, out float temperature) { float num = 0f; int num2 = 0; List <IntVec3> list = GenAdjFast.AdjacentCells8Way(t); for (int i = 0; i < list.Count; i++) { if (list[i].InBounds(t.Map) && TryGetDirectAirTemperatureForCell(list[i], t.Map, out float temperature2)) { num += temperature2; num2++; } } if (num2 > 0) { temperature = num / (float)num2; return(true); } temperature = 21f; return(false); }
public static IntVec3 InteractionCellWhenAt(ThingDef def, IntVec3 center, Rot4 rot, Map map) { if (def.hasInteractionCell) { IntVec3 b = def.interactionCellOffset.RotatedBy(rot); return(center + b); } if (def.Size.x == 1 && def.Size.z == 1) { for (int i = 0; i < 8; i++) { IntVec3 intVec = center + GenAdj.AdjacentCells[i]; if (intVec.Standable(map) && intVec.GetDoor(map) == null && ReachabilityImmediate.CanReachImmediate(intVec, center, map, PathEndMode.Touch, null)) { return(intVec); } } for (int j = 0; j < 8; j++) { IntVec3 intVec2 = center + GenAdj.AdjacentCells[j]; if (intVec2.Standable(map) && ReachabilityImmediate.CanReachImmediate(intVec2, center, map, PathEndMode.Touch, null)) { return(intVec2); } } for (int k = 0; k < 8; k++) { IntVec3 intVec3 = center + GenAdj.AdjacentCells[k]; if (intVec3.Walkable(map) && ReachabilityImmediate.CanReachImmediate(intVec3, center, map, PathEndMode.Touch, null)) { return(intVec3); } } return(center); } List <IntVec3> list = GenAdjFast.AdjacentCells8Way(center, rot, def.size); CellRect rect = GenAdj.OccupiedRect(center, rot, def.size); for (int l = 0; l < list.Count; l++) { if (list[l].Standable(map) && list[l].GetDoor(map) == null && ReachabilityImmediate.CanReachImmediate(list[l], rect, map, PathEndMode.Touch, null)) { return(list[l]); } } for (int m = 0; m < list.Count; m++) { if (list[m].Standable(map) && ReachabilityImmediate.CanReachImmediate(list[m], rect, map, PathEndMode.Touch, null)) { return(list[m]); } } for (int n = 0; n < list.Count; n++) { if (list[n].Walkable(map) && ReachabilityImmediate.CanReachImmediate(list[n], rect, map, PathEndMode.Touch, null)) { return(list[n]); } } return(center); }
private static List <IntVec3> AdjacentCells8Way(Thing t) { return(GenAdjFast.AdjacentCells8Way(t.Position, t.Rotation, t.def.size)); }