public static IEnumerable <IntVec3> CellsAdjacent8Way(IntVec3 thingCenter, Rot4 thingRot, IntVec2 thingSize) { GenAdj.AdjustForRotation(ref thingCenter, ref thingSize, thingRot); int minX = thingCenter.x - (thingSize.x - 1) / 2 - 1; int maxX = minX + thingSize.x + 1; int minZ = thingCenter.z - (thingSize.z - 1) / 2 - 1; int maxZ = minZ + thingSize.z + 1; IntVec3 cur = new IntVec3(minX - 1, 0, minZ); do { cur.x++; yield return(cur); }while (cur.x < maxX); do { cur.z++; yield return(cur); }while (cur.z < maxZ); do { cur.x--; yield return(cur); }while (cur.x > minX); do { cur.z--; yield return(cur); }while (cur.z > minZ + 1); }
public static IEnumerable <IntVec3> CellsAdjacentCardinal(IntVec3 center, Rot4 rot, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rot); int minX = center.x - (size.x - 1) / 2 - 1; int maxX = minX + size.x + 1; int minZ = center.z - (size.z - 1) / 2 - 1; int maxZ = minZ + size.z + 1; IntVec3 cur = new IntVec3(minX, 0, minZ); do { cur.x++; yield return(cur); }while (cur.x < maxX - 1); cur.x++; do { cur.z++; yield return(cur); }while (cur.z < maxZ - 1); cur.z++; do { cur.x--; yield return(cur); }while (cur.x > minX + 1); cur.x--; do { cur.z--; yield return(cur); }while (cur.z > minZ + 1); }
public static IEnumerable <IntVec3> CellsAdjacent8WayAndInside(this Thing thing) { IntVec3 center = thing.Position; IntVec2 size = thing.def.size; Rot4 rotation = thing.Rotation; GenAdj.AdjustForRotation(ref center, ref size, rotation); int minX = center.x - (size.x - 1) / 2 - 1; int minZ = center.z - (size.z - 1) / 2 - 1; int maxX = minX + size.x + 1; int maxZ = minZ + size.z + 1; int j = minX; int i; while (true) { if (j <= maxX) { i = minZ; if (i <= maxZ) { break; } j++; continue; } yield break; } yield return(new IntVec3(j, 0, i)); /*Error: Unable to find new state assignment for yield return*/; }
public static IEnumerable <IntVec3> CellsOccupiedBy(IntVec3 center, Rot4 rotation, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rotation); int minX = center.x - (size.x - 1) / 2; int minZ = center.z - (size.z - 1) / 2; int maxX = minX + size.x - 1; int maxZ = minZ + size.z - 1; int j = minX; int i; while (true) { if (j <= maxX) { i = minZ; if (i <= maxZ) { break; } j++; continue; } yield break; } yield return(new IntVec3(j, 0, i)); /*Error: Unable to find new state assignment for yield return*/; }
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 bool IsInside(IntVec3 root, IntVec3 center, Rot4 rot, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rot); int num = center.x - (size.x - 1) / 2; int num2 = center.z - (size.z - 1) / 2; int num3 = num + size.x - 1; int num4 = num2 + size.z - 1; return(root.x >= num && root.x <= num3 && root.z >= num2 && root.z <= num4); }
public static bool TryFindRandomAdjacentCell8WayWithRoomGroup(IntVec3 center, Rot4 rot, IntVec2 size, Map map, out IntVec3 result) { GenAdj.AdjustForRotation(ref center, ref size, rot); GenAdj.validCells.Clear(); foreach (IntVec3 item in GenAdj.CellsAdjacent8Way(center, rot, size)) { if (item.InBounds(map) && item.GetRoomGroup(map) != null) { GenAdj.validCells.Add(item); } } return(((IEnumerable <IntVec3>)GenAdj.validCells).TryRandomElement <IntVec3>(out result)); }
public static bool TryFindRandomAdjacentCell8WayWithRoomGroup(IntVec3 center, Rot4 rot, IntVec2 size, Map map, out IntVec3 result) { GenAdj.AdjustForRotation(ref center, ref size, rot); GenAdj.validCells.Clear(); foreach (IntVec3 current in GenAdj.CellsAdjacent8Way(center, rot, size)) { if (current.InBounds(map) && current.GetRoomGroup(map) != null) { GenAdj.validCells.Add(current); } } return(GenAdj.validCells.TryRandomElement(out result)); }
public static IEnumerable <IntVec3> CellsAdjacent8Way(IntVec3 thingCenter, Rot4 thingRot, IntVec2 thingSize) { GenAdj.AdjustForRotation(ref thingCenter, ref thingSize, thingRot); int minX = thingCenter.x - (thingSize.x - 1) / 2 - 1; int num = minX + thingSize.x + 1; int minZ = thingCenter.z - (thingSize.z - 1) / 2 - 1; int num2 = minZ + thingSize.z + 1; IntVec3 cur = new IntVec3(minX - 1, 0, minZ); cur.x++; yield return(cur); /*Error: Unable to find new state assignment for yield return*/; }
public static bool AdjacentTo8WayOrInside(this IntVec3 root, IntVec3 center, Rot4 rot, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rot); int num = center.x - (size.x - 1) / 2 - 1; int num2 = center.z - (size.z - 1) / 2 - 1; int num3 = num + size.x + 1; int num4 = num2 + size.z + 1; if (root.x >= num && root.x <= num3 && root.z >= num2 && root.z <= num4) { return(true); } return(false); }
public static IEnumerable <IntVec3> CellsAdjacentCardinal(IntVec3 center, Rot4 rot, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rot); int minX = center.x - (size.x - 1) / 2 - 1; int num = minX + size.x + 1; int minZ = center.z - (size.z - 1) / 2 - 1; int num2 = minZ + size.z + 1; IntVec3 cur = new IntVec3(minX, 0, minZ); cur.x++; yield return(cur); /*Error: Unable to find new state assignment for yield return*/; }
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 IEnumerable <IntVec3> CellsAdjacentAlongEdge(IntVec3 thingCent, Rot4 thingRot, IntVec2 thingSize, LinkDirections dir) { GenAdj.AdjustForRotation(ref thingCent, ref thingSize, thingRot); int minX = thingCent.x - (thingSize.x - 1) / 2 - 1; int minZ = thingCent.z - (thingSize.z - 1) / 2 - 1; int maxX = minX + thingSize.x + 1; int maxZ = minZ + thingSize.z + 1; if (dir == LinkDirections.Down) { int x2 = minX; if (x2 <= maxX) { yield return(new IntVec3(x2, thingCent.y, minZ - 1)); /*Error: Unable to find new state assignment for yield return*/; } } if (dir == LinkDirections.Up) { int x = minX; if (x <= maxX) { yield return(new IntVec3(x, thingCent.y, maxZ + 1)); /*Error: Unable to find new state assignment for yield return*/; } } if (dir == LinkDirections.Left) { int z2 = minZ; if (z2 <= maxZ) { yield return(new IntVec3(minX - 1, thingCent.y, z2)); /*Error: Unable to find new state assignment for yield return*/; } } if (dir == LinkDirections.Right) { int z = minZ; if (z <= maxZ) { yield return(new IntVec3(maxX + 1, thingCent.y, z)); /*Error: Unable to find new state assignment for yield return*/; } } }
public static IEnumerable <IntVec3> CellsOccupiedBy(IntVec3 center, Rot4 rotation, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rotation); int minX = center.x - (size.x - 1) / 2; int minZ = center.z - (size.z - 1) / 2; int maxX = minX + size.x - 1; int maxZ = minZ + size.z - 1; for (int i = minX; i <= maxX; i++) { for (int j = minZ; j <= maxZ; j++) { yield return(new IntVec3(i, 0, j)); } } }
public static IEnumerable <IntVec3> CellsAdjacent8WayAndInside(this Thing thing) { IntVec3 center = thing.Position; IntVec2 size = thing.def.size; Rot4 rotation = thing.Rotation; GenAdj.AdjustForRotation(ref center, ref size, rotation); int minX = center.x - (size.x - 1) / 2 - 1; int minZ = center.z - (size.z - 1) / 2 - 1; int maxX = minX + size.x + 1; int maxZ = minZ + size.z + 1; for (int i = minX; i <= maxX; i++) { for (int j = minZ; j <= maxZ; j++) { yield return(new IntVec3(i, 0, j)); } } }
public static IEnumerable <IntVec3> CellsAdjacentAlongEdge(IntVec3 thingCent, Rot4 thingRot, IntVec2 thingSize, LinkDirections dir) { GenAdj.AdjustForRotation(ref thingCent, ref thingSize, thingRot); int minX = thingCent.x - (thingSize.x - 1) / 2 - 1; int minZ = thingCent.z - (thingSize.z - 1) / 2 - 1; int maxX = minX + thingSize.x + 1; int maxZ = minZ + thingSize.z + 1; if (dir == LinkDirections.Down) { for (int x = minX; x <= maxX; x++) { yield return(new IntVec3(x, thingCent.y, minZ - 1)); } } if (dir == LinkDirections.Up) { for (int x2 = minX; x2 <= maxX; x2++) { yield return(new IntVec3(x2, thingCent.y, maxZ + 1)); } } if (dir == LinkDirections.Left) { for (int z = minZ; z <= maxZ; z++) { yield return(new IntVec3(minX - 1, thingCent.y, z)); } } if (dir == LinkDirections.Right) { for (int z2 = minZ; z2 <= maxZ; z2++) { yield return(new IntVec3(maxX + 1, thingCent.y, z2)); } } }
public static CellRect OccupiedRect(IntVec3 center, Rot4 rot, IntVec2 size) { GenAdj.AdjustForRotation(ref center, ref size, rot); return(new CellRect(center.x - (size.x - 1) / 2, center.z - (size.z - 1) / 2, size.x, size.z)); }