Ejemplo n.º 1
0
        public override void OnBeforeSimulationTick()
        {
            base.OnBeforeSimulationTick();

            geoMan.SimulationStep();
            routeMan.SimulationStep();
        }
Ejemplo n.º 2
0
        public override void OnBeforeSimulationFrame()
        {
            base.OnBeforeSimulationFrame();
#if BENCHMARK
            using (var bm = new Benchmark(null, "RoutingManager.SimulationStep")) {
#endif
            routeMan.SimulationStep();
#if BENCHMARK
        }
#endif

#if BENCHMARK
            using (var bm = new Benchmark(null, "TrafficLightSimulationManager.SimulationStep")) {
#endif

            if (Options.timedLightsEnabled)
            {
                //try {
                tlsMan.SimulationStep();

                /*} catch (Exception ex) {
                 *      Log.Warning($"Error occured while simulating traffic lights: {ex.ToString()}");
                 * }*/
            }
#if BENCHMARK
        }
#endif
        }
Ejemplo n.º 3
0
        public override void OnAfterSimulationFrame()
        {
            try {
                routeMan.SimulationStep();
            } catch (Exception e) {
                Log.Error($"Error occured while performing first update: " + e.ToString());
            }

            ++ticksSinceLastMinuteUpdate;
            if (ticksSinceLastMinuteUpdate > 60 * 60)
            {
                ticksSinceLastMinuteUpdate = 0;
                GlobalConfig.Instance.SimulationStep();
#if DEBUG
                DebugMenuPanel.PrintTransportStats();
#endif
            }

            ++ticksSinceLastSecondUpdate;
            if (ticksSinceLastSecondUpdate > 60)
            {
                ticksSinceLastSecondUpdate = 0;
                utilMan.SimulationStep();
            }
        }
        public override void OnBeforeSimulationTick()
        {
            base.OnBeforeSimulationTick();

            geoMan.SimulationStep();
            routeMan.SimulationStep();
            Custom.AssetManager.ProvisionalDataLoader.SimulationStep();
        }
Ejemplo n.º 5
0
        public override void OnBeforeSimulationFrame()
        {
            base.OnBeforeSimulationFrame();

            if (firstFrame)
            {
                firstFrame = false;
                Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours.");

                List <string> missingDetours = new List <string>();
                foreach (Detour detour in LoadingExtension.Detours)
                {
                    if (!RedirectionHelper.IsRedirected(detour.OriginalMethod, detour.CustomMethod))
                    {
                        missingDetours.Add($"{detour.OriginalMethod.DeclaringType.Name}.{detour.OriginalMethod.Name} with {detour.OriginalMethod.GetParameters().Length} parameters ({detour.OriginalMethod.DeclaringType.AssemblyQualifiedName})");
                    }
                }

                Log.Info($"ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Detours checked. Result: {missingDetours.Count} missing detours");

                if (missingDetours.Count > 0)
                {
                    string error = "Traffic Manager: President Edition detected an incompatibility with another mod! You can continue playing but it's NOT recommended. Traffic Manager will not work as expected. See TMPE.log for technical details.";
                    Log.Error(error);
                    string log = "The following methods were overriden by another mod:";
                    foreach (string missingDetour in missingDetours)
                    {
                        log += $"\n\t{missingDetour}";
                    }
                    Log.Info(log);
                    if (GlobalConfig.Instance.Main.ShowCompatibilityCheckErrorMessage)
                    {
                        Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => {
                            UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true);
                        });
                    }
                }
            }

            routeMan.SimulationStep();

            if (Options.timedLightsEnabled)
            {
                tlsMan.SimulationStep();
            }
        }