Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }