public static bool IsSupplyShipCryptosleepBayAvailable(Pawn opener) { // We check if pawn can reach left or right supply ship cryptosleep bay because one of them can be blocked by a laser fence. List <Thing> leftBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayLeftDef); for (int bayIndex = 0; bayIndex < leftBaysList.Count; bayIndex++) { Building_SupplyShipCryptosleepBay bay = leftBaysList[bayIndex] as Building_SupplyShipCryptosleepBay; if ((bay.Faction != null) && (bay.Faction == opener.Faction)) { if (bay.ContainedThing == null) { if (opener.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly)) { return(true); } } } } List <Thing> rightBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayRightDef); for (int bayIndex = 0; bayIndex < rightBaysList.Count; bayIndex++) { Building_SupplyShipCryptosleepBay bay = rightBaysList[bayIndex] as Building_SupplyShipCryptosleepBay; if ((bay.Faction != null) && (bay.Faction == opener.Faction)) { if (bay.ContainedThing == null) { if (opener.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly)) { return(true); } } } } return(false); }
public static Thing FindFreeSupplyShipCryptosleepBay(Pawn rescuer) { List <Thing> leftBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayLeftDef); for (int bayIndex = 0; bayIndex < leftBaysList.Count; bayIndex++) { Thing potentialBay = leftBaysList[bayIndex]; if ((potentialBay.Faction != null) && (potentialBay.Faction == rescuer.Faction)) { Building_SupplyShipCryptosleepBay bay = potentialBay as Building_SupplyShipCryptosleepBay; if ((bay.GetContainer().Count == 0) && (rescuer.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly))) { return(bay); } } } List <Thing> rightBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayRightDef); for (int bayIndex = 0; bayIndex < rightBaysList.Count; bayIndex++) { Thing potentialBay = rightBaysList[bayIndex]; if ((potentialBay.Faction != null) && (potentialBay.Faction == rescuer.Faction)) { Building_SupplyShipCryptosleepBay bay = potentialBay as Building_SupplyShipCryptosleepBay; if ((bay.GetContainer().Count == 0) && (rescuer.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly))) { return(bay); } } } return(null); }