public static bool AcceptableGameConditionsToStartParty(Map map) { if (!PartyUtility.AcceptableGameConditionsToContinueParty(map)) { return(false); } if (GenLocalDate.HourInteger(map) >= 4 && GenLocalDate.HourInteger(map) <= 21) { if (GatheringsUtility.AnyLordJobPreventsNewGatherings(map)) { return(false); } if (map.dangerWatcher.DangerRating != 0) { return(false); } int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount; if (freeColonistsSpawnedCount < 4) { return(false); } int num = 0; foreach (Pawn item in map.mapPawns.FreeColonistsSpawned) { if (item.health.hediffSet.BleedRateTotal > 0.0) { return(false); } if (item.Drafted) { num++; } } if ((float)num / (float)freeColonistsSpawnedCount >= 0.5) { return(false); } if (!PartyUtility.EnoughPotentialGuestsToStartParty(map, null)) { return(false); } return(true); } return(false); }
public static bool TryFindPartySpot(Pawn organizer, out IntVec3 result) { bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer, null); Map map = organizer.Map; Predicate <IntVec3> baseValidator = delegate(IntVec3 cell) { if (!cell.Standable(map)) { return(false); } if (cell.GetDangerFor(organizer, map) != Danger.None) { return(false); } if (!enjoyableOutside && !cell.Roofed(map)) { return(false); } if (cell.IsForbidden(organizer)) { return(false); } if (!organizer.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.None, 1, -1, null, false)) { return(false); } Room room = cell.GetRoom(map, RegionType.Set_Passable); bool flag = room != null && room.isPrisonCell; return(organizer.IsPrisoner == flag && PartyUtility.EnoughPotentialGuestsToStartParty(map, new IntVec3?(cell))); }; if ((from x in map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.PartySpot) where baseValidator(x.Position) select x.Position).TryRandomElement(out result)) { return(true); } Predicate <IntVec3> noPartySpotValidator = delegate(IntVec3 cell) { Room room = cell.GetRoom(map, RegionType.Set_Passable); return(room == null || room.IsHuge || room.PsychologicallyOutdoors || room.CellCount >= 10); }; foreach (CompGatherSpot current in map.gatherSpotLister.activeSpots.InRandomOrder(null)) { for (int i = 0; i < 10; i++) { IntVec3 intVec = CellFinder.RandomClosewalkCellNear(current.parent.Position, current.parent.Map, 4, null); if (baseValidator(intVec) && noPartySpotValidator(intVec)) { result = intVec; bool result2 = true; return(result2); } } } if (CellFinder.TryFindRandomCellNear(organizer.Position, organizer.Map, 25, (IntVec3 cell) => baseValidator(cell) && noPartySpotValidator(cell), out result, -1)) { return(true); } result = IntVec3.Invalid; return(false); }
public static bool AcceptableGameConditionsToStartParty(Map map) { bool result; if (!PartyUtility.AcceptableGameConditionsToContinueParty(map)) { result = false; } else if (GenLocalDate.HourInteger(map) < 4 || GenLocalDate.HourInteger(map) > 21) { result = false; } else if (GatheringsUtility.AnyLordJobPreventsNewGatherings(map)) { result = false; } else if (map.dangerWatcher.DangerRating != StoryDanger.None) { result = false; } else { int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount; if (freeColonistsSpawnedCount < 4) { result = false; } else { int num = 0; foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned) { if (pawn.health.hediffSet.BleedRateTotal > 0f) { return(false); } if (pawn.Drafted) { num++; } } result = ((float)num / (float)freeColonistsSpawnedCount < 0.5f && PartyUtility.EnoughPotentialGuestsToStartParty(map, null)); } } return(result); }