/// <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="spareTimeBehavior">A behavior that provides simulation info for the citizens spare time.</param> /// <param name="timeInfo">An object that provides the game time information.</param> /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception> public CitizenProcessor(RealTimeResidentAI <TAI, TCitizen> residentAI, SpareTimeBehavior spareTimeBehavior, ITimeInfo timeInfo) { this.residentAI = residentAI ?? throw new ArgumentNullException(nameof(residentAI)); this.spareTimeBehavior = spareTimeBehavior ?? throw new ArgumentNullException(nameof(spareTimeBehavior)); this.timeInfo = timeInfo ?? throw new ArgumentNullException(nameof(timeInfo)); cycleStartFrame = int.MinValue; }
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); }
private static void SetupCustomAI( TimeInfo timeInfo, RealTimeConfig config, GameConnections <Citizen> gameConnections, RealTimeEventManager eventManager) { var realTimeResidentAI = new RealTimeResidentAI <ResidentAI, Citizen>( config, gameConnections, ResidentAIHook.GetResidentAIConnection(), eventManager); ResidentAIHook.RealTimeAI = realTimeResidentAI; var realTimeTouristAI = new RealTimeTouristAI <TouristAI, Citizen>( config, gameConnections, TouristAIHook.GetTouristAIConnection(), eventManager); TouristAIHook.RealTimeAI = realTimeTouristAI; var realTimePrivateBuildingAI = new RealTimePrivateBuildingAI( config, timeInfo, new ToolManagerConnection()); PrivateBuildingAIHook.RealTimeAI = realTimePrivateBuildingAI; }
/// <summary>Enables the vehicle info panel customization. Can return null on failure.</summary> /// <param name="residentAI">The custom resident AI.</param> /// <param name="localizationProvider">The localization provider to use for text translation.</param> /// <returns>An instance of the <see cref="CustomVehicleInfoPanel"/> object that can be used for disabling /// the customization, or null when the customization fails.</returns> /// /// <exception cref="ArgumentNullException">Thrown when <paramref name="residentAI"/> is <c>null</c>.</exception> public static CustomVehicleInfoPanel Enable(RealTimeResidentAI <ResidentAI, Citizen> residentAI, ILocalizationProvider localizationProvider) { if (residentAI == null) { throw new ArgumentNullException(nameof(residentAI)); } if (localizationProvider == null) { throw new ArgumentNullException(nameof(localizationProvider)); } var result = new CustomVehicleInfoPanel(GameInfoPanelName, residentAI, localizationProvider); return(result.Initialize() ? result : null); }
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 realTimeResidentAI = new RealTimeResidentAI <ResidentAI, Citizen>( config, gameConnections, residentAIConnection, eventManager); ResidentAIPatch.RealTimeAI = realTimeResidentAI; TouristAIConnection <TouristAI, Citizen> touristAIConnection = TouristAIPatch.GetTouristAIConnection(); if (touristAIConnection == null) { return(false); } var realTimeTouristAI = new RealTimeTouristAI <TouristAI, Citizen>( config, gameConnections, touristAIConnection, eventManager); TouristAIPatch.RealTimeAI = realTimeTouristAI; var realTimePrivateBuildingAI = new RealTimePrivateBuildingAI( config, timeInfo, gameConnections.BuildingManager, new ToolManagerConnection()); BuildingAIPatches.RealTimeAI = realTimePrivateBuildingAI; return(true); }
private CustomVehicleInfoPanel(string panelName, RealTimeResidentAI <ResidentAI, Citizen> residentAI, ILocalizationProvider localizationProvider) : base(panelName, residentAI, localizationProvider) { try { passengerCarAIGetDriverInstance = FastDelegateFactory.Create <GetDriverInstanceDelegate <PassengerCarAI> >( typeof(PassengerCarAI), GetDriverInstanceMethodName, true); bicycleAIGetDriverInstance = FastDelegateFactory.Create <GetDriverInstanceDelegate <BicycleAI> >( typeof(BicycleAI), GetDriverInstanceMethodName, true); } catch (Exception ex) { Debug.LogError("The 'Real Time' mod failed to obtain at least one of the GetDriverInstance methods. Error message: " + ex); } }
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); }
/// <summary>Initializes a new instance of the <see cref="RealTimeInfoPanelBase{T}"/> class.</summary> /// <param name="panelName">Name of the game's panel object.</param> /// <param name="residentAI">The custom resident AI.</param> /// <param name="localizationProvider">The localization provider to use for text translation.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown when <paramref name="residentAI"/> or <paramref name="localizationProvider"/> is null. /// </exception> /// <exception cref="System.ArgumentException"> /// Thrown when <paramref name="panelName"/> is null or an empty string. /// </exception> protected RealTimeInfoPanelBase(string panelName, RealTimeResidentAI <ResidentAI, Citizen> residentAI, ILocalizationProvider localizationProvider) : base(panelName) { this.residentAI = residentAI ?? throw new System.ArgumentNullException(nameof(residentAI)); this.localizationProvider = localizationProvider ?? throw new System.ArgumentNullException(nameof(localizationProvider)); }
/// <summary>Enables the citizen info panel customization. Can return null on failure.</summary> /// <param name="residentAI">The custom resident AI.</param> /// <param name="localizationProvider">The localization provider to use for text translation.</param> /// <returns>An instance of the <see cref="CustomCitizenInfoPanel"/> object that can be used for disabling /// the customization, or null when the customization fails.</returns> public static CustomCitizenInfoPanel Enable(RealTimeResidentAI <ResidentAI, Citizen> residentAI, ILocalizationProvider localizationProvider) { var result = new CustomCitizenInfoPanel(GameInfoPanelName, residentAI, localizationProvider); return(result.Initialize() ? result : null); }
private CustomCitizenInfoPanel(string panelName, RealTimeResidentAI <ResidentAI, Citizen> residentAI, ILocalizationProvider localizationProvider) : base(panelName, residentAI, localizationProvider) { }
/// <summary>Initializes a new instance of the <see cref="CitizenProcessor"/> class.</summary> /// <param name="residentAI">The custom resident AI implementation.</param> /// <param name="spareTimeBehavior">A behavior that provides simulation info for the citizens spare time.</param> /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception> public CitizenProcessor(RealTimeResidentAI <ResidentAI, Citizen> residentAI, SpareTimeBehavior spareTimeBehavior) { this.residentAI = residentAI ?? throw new ArgumentNullException(nameof(residentAI)); this.spareTimeBehavior = spareTimeBehavior ?? throw new ArgumentNullException(nameof(spareTimeBehavior)); dayStartFrame = int.MinValue; }