private static bool SetupCustomAI( TimeInfo timeInfo, RealTimeConfig config, GameConnections <Citizen> gameConnections, RealTimeEventManager eventManager) { ResidentAIConnection <ResidentAI, Citizen> residentAIConnection = ResidentAIPatch.GetResidentAIConnection(); if (residentAIConnection == null) { return(false); } var spareTimeBehavior = new SpareTimeBehavior(config, timeInfo); var travelBehavior = new TravelBehavior(gameConnections.BuildingManager); var workBehavior = new WorkBehavior(config, gameConnections.Random, gameConnections.BuildingManager, timeInfo, travelBehavior); var realTimePrivateBuildingAI = new RealTimeBuildingAI( config, timeInfo, gameConnections.BuildingManager, new ToolManagerConnection(), workBehavior, travelBehavior); BuildingAIPatches.RealTimeAI = realTimePrivateBuildingAI; BuildingAIPatches.WeatherInfo = gameConnections.WeatherInfo; TransferManagerPatch.RealTimeAI = realTimePrivateBuildingAI; var realTimeResidentAI = new RealTimeResidentAI <ResidentAI, Citizen>( config, gameConnections, residentAIConnection, eventManager, realTimePrivateBuildingAI, workBehavior, spareTimeBehavior, travelBehavior); ResidentAIPatch.RealTimeAI = realTimeResidentAI; SimulationHandler.CitizenProcessor = new CitizenProcessor <ResidentAI, Citizen>( realTimeResidentAI, timeInfo, spareTimeBehavior, travelBehavior); TouristAIConnection <TouristAI, Citizen> touristAIConnection = TouristAIPatch.GetTouristAIConnection(); if (touristAIConnection == null) { return(false); } var realTimeTouristAI = new RealTimeTouristAI <TouristAI, Citizen>( config, gameConnections, touristAIConnection, eventManager, spareTimeBehavior); TouristAIPatch.RealTimeAI = realTimeTouristAI; return(true); }
/// <summary>Initializes a new instance of the <see cref="CitizenProcessor{TAI, TCitizen}"/> class.</summary> /// <param name="residentAI">The custom resident AI implementation.</param> /// <param name="timeInfo">An object that provides the game time information.</param> /// <param name="spareTimeBehavior">A behavior that provides simulation info for the citizens spare time.</param> /// <param name="travelBehavior">A behavior that provides simulation info for citizens travelling.</param> /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception> public CitizenProcessor( RealTimeResidentAI <TAI, TCitizen> residentAI, ITimeInfo timeInfo, SpareTimeBehavior spareTimeBehavior, TravelBehavior travelBehavior) { this.residentAI = residentAI ?? throw new ArgumentNullException(nameof(residentAI)); this.spareTimeBehavior = spareTimeBehavior ?? throw new ArgumentNullException(nameof(spareTimeBehavior)); this.travelBehavior = travelBehavior ?? throw new ArgumentNullException(nameof(travelBehavior)); this.timeInfo = timeInfo ?? throw new ArgumentNullException(nameof(timeInfo)); cycleStartFrame = int.MinValue; }
private static bool SetupCustomAI( TimeInfo timeInfo, RealTimeConfig config, GameConnections <Citizen> gameConnections, RealTimeEventManager eventManager, Compatibility compatibility) { var residentAIConnection = ResidentAIPatch.GetResidentAIConnection(); if (residentAIConnection == null) { return(false); } float travelDistancePerCycle = compatibility.IsAnyModActive(WorkshopMods.RealisticWalkingSpeed) ? Constants.AverageTravelDistancePerCycle * 0.583f : Constants.AverageTravelDistancePerCycle; var spareTimeBehavior = new SpareTimeBehavior(config, timeInfo); var travelBehavior = new TravelBehavior(gameConnections.BuildingManager, travelDistancePerCycle); var workBehavior = new WorkBehavior(config, gameConnections.Random, gameConnections.BuildingManager, timeInfo, travelBehavior); ParkPatch.SpareTimeBehavior = spareTimeBehavior; OutsideConnectionAIPatch.SpareTimeBehavior = spareTimeBehavior; var realTimePrivateBuildingAI = new RealTimeBuildingAI( config, timeInfo, gameConnections.BuildingManager, new ToolManagerConnection(), workBehavior, travelBehavior); BuildingAIPatch.RealTimeAI = realTimePrivateBuildingAI; BuildingAIPatch.WeatherInfo = gameConnections.WeatherInfo; TransferManagerPatch.RealTimeAI = realTimePrivateBuildingAI; var realTimeResidentAI = new RealTimeResidentAI <ResidentAI, Citizen>( config, gameConnections, residentAIConnection, eventManager, realTimePrivateBuildingAI, workBehavior, spareTimeBehavior, travelBehavior); ResidentAIPatch.RealTimeAI = realTimeResidentAI; SimulationHandler.CitizenProcessor = new CitizenProcessor <ResidentAI, Citizen>( realTimeResidentAI, timeInfo, spareTimeBehavior, travelBehavior); var touristAIConnection = TouristAIPatch.GetTouristAIConnection(); if (touristAIConnection == null) { return(false); } var realTimeTouristAI = new RealTimeTouristAI <TouristAI, Citizen>( config, gameConnections, touristAIConnection, eventManager, spareTimeBehavior); TouristAIPatch.RealTimeAI = realTimeTouristAI; return(true); }