public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            if (_terminated)
            {
                return;
            }

            if (!_helper.GameLoaded)
            {
                return;
            }

            try
            {
                if (!_initialized)
                {
                    if (!IsOverwatched())
                    {
                        _helper.NotifyPlayer("Skylines Overwatch not found. Terminating...");
                        _terminated = true;

                        return;
                    }

                    SkylinesOverwatch.Settings.Instance.Enable.BuildingMonitor = true;
                    SkylinesOverwatch.Settings.Instance.Enable.VehicleMonitor  = true;

                    _cemeteries = new Dictionary <ushort, Cemetery>();
                    _master     = new Dictionary <ushort, Claimant>();
                    _stopped    = new HashSet <ushort>();

                    _initialized = true;

                    _helper.NotifyPlayer("Initialized");
                }
                else if (!_baselined)
                {
                    CreateBaseline();
                }
                else
                {
                    ProcessNewCemeteries();
                    ProcessRemovedCemeteries();

                    ProcessNewPickups();

                    UpdateHearses();

                    /*
                     * if (SimulationManager.instance.SimulationPaused)
                     * {
                     *  foreach (ushort id in _master.Keys)
                     *  {
                     *      string name = Singleton<BuildingManager>.instance.GetBuildingName(id, new InstanceID { Building = id });
                     *
                     *      if (!name.Contains("##"))
                     *          continue;
                     *
                     *      _helper.NotifyPlayer(String.Format("{0} ({1}) {2}/{3}", _master[id].Hearse, Math.Sqrt(_master[id].Distance), _master[id].IsValid, _master[id].IsChallengable));
                     *  }
                     * }
                     */
                }
            }
            catch (Exception e)
            {
                string error = String.Format("Failed to {0}\r\n", !_initialized ? "initialize" : "update");
                error += String.Format("Error: {0}\r\n", e.Message);
                error += "\r\n";
                error += "==== STACK TRACE ====\r\n";
                error += e.StackTrace;

                _helper.Log(error);

                if (!_initialized)
                {
                    _terminated = true;
                }
            }

            base.OnUpdate(realTimeDelta, simulationTimeDelta);
        }
Пример #2
0
        public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            if (_terminated)
            {
                return;
            }

            if (!_helper.GameLoaded)
            {
                return;
            }

            try
            {
                if (!_initialized)
                {
                    if (!IsOverwatched())
                    {
                        _helper.NotifyPlayer("Skylines Overwatch not found. Terminating...");
                        _terminated = true;

                        return;
                    }

                    SkylinesOverwatch.Settings.Instance.Enable.BuildingMonitor = true;
                    SkylinesOverwatch.Settings.Instance.Enable.VehicleMonitor  = true;

                    _cemeteries = new Dictionary <ushort, Cemetery>();
                    _master     = new Dictionary <ushort, float>();
                    _stopped    = new HashSet <ushort>();

                    _initialized = true;

                    _helper.NotifyPlayer("Initialized");
                }
                else if (!_baselined)
                {
                    CreateBaseline();
                }
                else
                {
                    ProcessNewCemeteries();
                    ProcessRemovedCemeteries();

                    ProcessNewPickups();

                    UpdateHearses();
                }
            }
            catch (Exception e)
            {
                string error = String.Format("Failed to {0}\r\n", !_initialized ? "initialize" : "updated");
                error += String.Format("Error: {0}\r\n", e.Message);
                error += "\r\n";
                error += "==== STACK TRACE ====\r\n";
                error += e.StackTrace;

                _helper.Log(error);

                if (!_initialized)
                {
                    _terminated = true;
                }
            }

            base.OnUpdate(realTimeDelta, simulationTimeDelta);
        }
Пример #3
0
        public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            if (_terminated)
            {
                return;
            }

            if (!_helper.GameLoaded)
            {
                return;
            }

            try
            {
                if (!_initialized)
                {
                    if (!Helper.IsOverwatched())
                    {
                        _helper.NotifyPlayer("Skylines Overwatch not found. Terminating...");
                        _terminated = true;

                        return;
                    }

                    SkylinesOverwatch.Settings.Instance.Enable.BuildingMonitor = true;
                    SkylinesOverwatch.Settings.Instance.Enable.VehicleMonitor  = true;

                    _cemeteries      = new Dictionary <ushort, Cemetery>();
                    _master          = new Dictionary <ushort, Claimant>();
                    _stopped         = new HashSet <ushort>();
                    _updated         = new HashSet <ushort>();
                    _oldtargets      = new Dictionary <ushort, HashSet <ushort> >();
                    _lasttargets     = new Dictionary <ushort, ushort>();
                    _lastchangetimes = new Dictionary <ushort, DateTime>();
                    _PathfindCount   = new Dictionary <ushort, ushort>();

                    RedirectionHelper.RedirectCalls(Loader.m_redirectionStates, typeof(HearseAI), typeof(CustomHearseAI), "SetTarget", 3);

                    _initialized = true;

                    _helper.NotifyPlayer("Initialized");
                }
                else if (!_baselined)
                {
                    CreateBaseline();
                }
                else
                {
                    ProcessNewCemeteries();
                    ProcessRemovedCemeteries();

                    ProcessNewPickups();

                    if (!SimulationManager.instance.SimulationPaused && Identity.ModConf.MinimizeHearses)
                    {
                        ProcessIdleHearses();
                    }
                    UpdateHearses();
                    _lastProcessedFrame = Singleton <SimulationManager> .instance.m_currentFrameIndex;
                }
            }
            catch (Exception e)
            {
                string error = String.Format("Failed to {0}\r\n", !_initialized ? "initialize" : "update");
                error += String.Format("Error: {0}\r\n", e.Message);
                error += "\r\n";
                error += "==== STACK TRACE ====\r\n";
                error += e.StackTrace;

                _helper.Log(error);

                if (!_initialized)
                {
                    _terminated = true;
                }
            }

            base.OnUpdate(realTimeDelta, simulationTimeDelta);
        }