Exemplo n.º 1
0
        public override void OnLevelUnloading()
        {
            // First disable dynamic sign updates
            RenderingManager.instance.disableTimer();
            ModSettings.SaveSettings();

            DynamicSignConfig.SaveVmsMsgList();
            MarkARouteOptions.mInGame = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads all custom sprites
        /// </summary>
        private void LoadSprites()
        {
            bool spriteSuccess = true;

            //TODO: Replace with a loader function( JSON mapping available )

            //We probably need this before we load any displays
            DynamicSignConfig.LoadVmsMsgList();

            RouteShieldConfig.LoadRouteShieldInfo();
            String[] files = Directory.GetFiles(FileUtils.GetModPath() + Path.DirectorySeparatorChar + "Icons");
            foreach (string file in files)
            {
                string[] splitValues = file[0] == Path.DirectorySeparatorChar ? file.Substring(1).Split(Path.DirectorySeparatorChar) : file.Split(Path.DirectorySeparatorChar);
                string   fileName    = splitValues[splitValues.Length - 1];
                string   fileKey     = fileName.Split('.')[0];
                spriteSuccess = SpriteUtils.AddTexture(file, fileKey) && spriteSuccess;
                if (!RouteShieldConfig.Instance().routeShieldDictionary.ContainsKey(fileKey))
                {
                    RouteShieldConfig.Instance().routeShieldDictionary[fileKey] = new RouteShieldInfo(fileKey);
                }
            }

            //TODO: When we need it, load a json descriptor file for relevant shaders here
            ShaderUtils.AddShader("Shaders/font", "font");

            //TODO: When we need it, load a json descriptor file for relevant fonts here
            FontUtils.AddFonts();

            if (!spriteSuccess)
            {
                LoggerUtils.LogError("Failed to load some sprites!");
            }
            else
            {
                RouteShieldConfig.SaveRouteShieldInfo();
            }
        }
Exemplo n.º 3
0
        protected override void BeginOverlayImpl(RenderManager.CameraInfo cameraInfo)
        {
            NetManager      netManager      = NetManager.instance;
            DistrictManager districtManager = DistrictManager.instance;

            cameraInfo.m_height = 100;
            if (m_lastCount != RouteManager.Instance().m_routeDict.Count)
            {
                m_lastCount = RouteManager.Instance().m_routeDict.Count;

                try
                {
                    RenderText();
                }
                catch (Exception ex)
                {
                    LoggerUtils.LogException(ex);
                }
            }

            if (!textHidden && cameraInfo.m_height > m_renderHeight)
            {
                foreach (RouteContainer route in RouteManager.Instance().m_routeDict.Values)
                {
                    route.m_shieldMesh.GetComponent <Renderer>().enabled = false;
                    route.m_numMesh.GetComponent <Renderer>().enabled    = false;
                }

                foreach (SignContainer sign in RouteManager.Instance().m_signList)
                {
                    /*sign.m_destinationMesh.GetComponent<Renderer>().enabled = false;
                     * sign.m_shieldMesh.GetComponent<Renderer>().enabled = false;
                     * sign.m_numMesh.GetComponent<Renderer>().enabled = false;*/
                    sign.m_sign.GetComponent <Renderer>().enabled = false;
                }
                textHidden = true;
            }
            else if (textHidden && cameraInfo.m_height <= m_renderHeight)  //This is a mess, and I'll sort it soon :)
            {
                if (m_routeEnabled)
                {
                    foreach (RouteContainer route in RouteManager.Instance().m_routeDict.Values)
                    {
                        route.m_shieldMesh.GetComponent <Renderer>().enabled = true;
                        route.m_numMesh.GetComponent <Renderer>().enabled    = true;
                    }

                    foreach (SignContainer sign in RouteManager.Instance().m_signList)
                    {
                        /*sign.m_destinationMesh.GetComponent<Renderer>().enabled = true;
                         * sign.m_shieldMesh.GetComponent<Renderer>().enabled = true;
                         * sign.m_numMesh.GetComponent<Renderer>().enabled = true;*/
                        sign.m_sign.GetComponent <Renderer>().enabled = true;
                    }
                }
                textHidden = false;
            }

            if (m_updateDynamicSignFlag)
            {
                m_updateDynamicSignFlag = false;
                float  avg;
                float  lowTrafficMsgChance;
                String msgText;
                foreach (DynamicSignContainer sign in RouteManager.Instance().m_dynamicSignList)
                {
                    avg  = (float)sign.m_trafficDensity;
                    avg -= sign.m_trafficDensity / 3;
                    avg += netManager.m_segments.m_buffer[sign.m_segment].m_trafficDensity / 3;
                    sign.m_trafficDensity = avg;
                    msgText = (sign.m_route == null ? "Traffic" : (sign.m_routePrefix + '-' + sign.m_route)) +
                              String.Format(" moving {0}", sign.m_trafficDensity > 65 ? "slowly" : "well");

                    if (sign.m_trafficDensity < 35)
                    {
                        lowTrafficMsgChance = 0.8f;
                    }
                    else
                    {
                        lowTrafficMsgChance = 0.1f;
                    }

                    sign.m_messageTextMesh.text = (messageRandom.NextDouble() > lowTrafficMsgChance) ? msgText :
                                                  DynamicSignConfig.Instance().msgStrings[messageRandom.Next(DynamicSignConfig.Instance().msgStrings.Count)];
                }
            }
        }