protected static bool IsValidLot(Lot lot, FoodTruckBase truck) { if (lot == null) return false; FoodTruckBase existing = TruckController.GetTruck(lot); if (existing != null) { if (existing != truck) return false; } if (lot.StreetParking == null) return false; if (lot.IsWorldLot) return false; if (!lot.IsCommunityLot) { if (lot.Household == null) return false; if (!Traffic.Settings.mAllowIceCreamResidential) return false; if (lot.Household.IsActive) { if (!Traffic.Settings.mAllowIceCreamActiveLot) return false; } } return true; }
public static void Update() { List <Lot> lotChoices = new List <Lot>(); foreach (Lot lot in LotManager.AllLots) { if (!IsValidLot(lot, null)) { continue; } lotChoices.Add(lot); } List <FoodTruck> truckList = new List <FoodTruck>(Sims3.Gameplay.Queries.GetObjects <FoodTruck>()); int trucksToSpawn = 0x0; int count = truckList.Count; if (count < Traffic.Settings.mMaxFoodTrucks) { if (lotChoices.Count > FoodTruckManager.kMinWideParkingSpaceRequired) { trucksToSpawn = 0x1; } else if (lotChoices.Count < FoodTruckManager.kMinWideParkingSpaceRequired) { trucksToSpawn = lotChoices.Count - FoodTruckManager.kMinWideParkingSpaceRequired; } } else if (count > Traffic.Settings.mMaxFoodTrucks) { trucksToSpawn = Traffic.Settings.mMaxFoodTrucks - count; } else if ((Traffic.Settings.mRequireFoodParkingSpace) && (lotChoices.Count < FoodTruckManager.kMinWideParkingSpaceRequired)) { trucksToSpawn = lotChoices.Count - FoodTruckManager.kMinWideParkingSpaceRequired; } if ((trucksToSpawn > 0x0) && (lotChoices.Count > 0x0)) { Lot randomObjectFromList = RandomUtil.GetRandomObjectFromList(lotChoices); lotChoices.Remove(randomObjectFromList); FoodTruck truck = FoodTruckManager.AddTruckIntoWorld(randomObjectFromList); if (truck != null) { truckList.Add(truck); } } if (Common.kDebugging) { Common.DebugNotify("Food Truck Manager: " + truckList.Count + " " + trucksToSpawn + " " + lotChoices.Count); } if (truckList.Count > 0x0) { RandomUtil.RandomizeListOfObjects <FoodTruck>(truckList); foreach (FoodTruck truck in truckList) { if ((trucksToSpawn < 0x0) || (lotChoices.Count == 0) || ((SimClock.IsNightTime()) && (!Traffic.Settings.mAllowFoodTruckAtNight))) { truck.FadeOut(false, true); trucksToSpawn++; } else if (lotChoices.Count > 0x0) { bool moveToNewLot = FoodTruckEx.MoveToNewLot(truck); if ((moveToNewLot) || (!IsValidLot(TruckController.GetLot(truck), truck))) { Lot item = RandomUtil.GetRandomObjectFromList(lotChoices); lotChoices.Remove(item); FoodTruckEx.RouteToNewLot(truck, item); Common.DebugNotify("Food Truck: ", truck.ObjectId, item.ObjectId); TruckController.AddTruck(truck); } } FoodTruckEx.AddMapTags(truck); } } }
protected static bool IsValidLot(Lot lot, FoodTruckBase truck) { if (lot == null) { return(false); } FoodTruckBase existing = TruckController.GetTruck(lot); if (existing != null) { if (existing != truck) { return(false); } } if (lot.StreetParking == null) { return(false); } if (lot.IsWorldLot) { return(false); } if (Traffic.Settings.mRequireFoodParkingSpace) { List <FoodTruckBase> trucks = new List <FoodTruckBase>(lot.GetObjects <FoodTruckBase>()); trucks.Remove(truck); if ((lot.CountObjects <WideParkingSpace>() == 0x0) || (trucks.Count > 0x0)) { return(false); } } if (lot.IsCommunityLot) { float openHour = 0f; float closingHour = 0f; if ((Bartending.TryGetHoursOfOperation(lot, ref openHour, ref closingHour)) && (!SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, openHour, closingHour))) { return(false); } } else { if (lot.Household == null) { return(false); } if (!Traffic.Settings.mAllowFoodTruckResidential) { return(false); } if (lot.Household.IsActive) { if (!Traffic.Settings.mAllowFoodTruckActiveLot) { return(false); } } } return(true); }
public static void Update(IceCreamTruckManager ths) { bool winter = SeasonsManager.Enabled && (SeasonsManager.CurrentSeason == Season.Winter); int[] numArray = (SeasonsManager.Enabled && (SeasonsManager.CurrentSeason == Season.Summer)) ? IceCreamTruckManager.kHoursOfOperationSummer : IceCreamTruckManager.kHoursOfOperation; if ((winter || !SimClock.IsTimeBetweenTimes((float)numArray[0], (float)numArray[1])) || ((SimClock.IsNightTime()) && (!Traffic.Settings.mAllowIceCreamAtNight))) { foreach (IceCreamTruck truck in new List<IceCreamTruck>(ths.mIceCreamTrucks)) { truck.EndService(); } ths.mIceCreamTrucks.Clear(); } else { List<IceCreamTruckManager.LotData> data = null; if (data == null) { data = new List<IceCreamTruckManager.LotData>(); PopulateLotList(data); } if ((data.Count > 0) && (ths.mIceCreamTrucks.Count < Traffic.Settings.mMaxIceCreamTrucks)) { IceCreamTruckManager.LotData randomObjectFromList = RandomUtil.GetRandomObjectFromList(data); data.Remove(randomObjectFromList); AddTruckIntoWorld(ths, randomObjectFromList.mLot); } else if ((ths.mIceCreamTrucks.Count > 0) && ((data.Count == 0) || (ths.mIceCreamTrucks.Count > Traffic.Settings.mMaxIceCreamTrucks))) { IceCreamTruck truck = RandomUtil.GetRandomObjectFromList(ths.mIceCreamTrucks); ths.mIceCreamTrucks.Remove(truck); truck.FadeOut(false, true); } //Common.DebugNotify("Ice Cream Trucks " + ths.mIceCreamTrucks.Count); foreach (IceCreamTruck truck in ths.mIceCreamTrucks) { if ((truck.MoveToNewLot()) || (!IsValidLot(TruckController.GetLot(truck), truck))) { if (data.Count == 0) continue; ths.PopulateLotListDistanceAndScore(truck, data); ths.RouteToNextBestSpot(truck, data); for (int i = 0; i < data.Count; i++) { if (data[i].mLot == truck.mDestinationLot) { data.RemoveAt(i); break; } } Common.DebugNotify("Ice Cream Truck", truck.ObjectId, truck.mDestinationLot.ObjectId); TruckController.AddTruck(truck); } } } }