Exemple #1
0
        public static void SetupLights()
        {
            if (config.ready)
            {
                //Debug.Log("[ambient-lights] Setting up " + config.data.emitters.Count + " light sources for scene.");
                ALUtils.Log("Setting up " + config.data.emitters.Count + " light sources for scene.", false, true);

                foreach (AmbEmitter emitter in config.data.emitters)
                {
                    //Debug.Log("Emitter pos: " + emitter.position);

                    Vector3 newPos = ALUtils.StringToVector3(emitter.position);

                    AmbLight newLight = new AmbLight(newPos, emitter.orientation, emitter.size, emitter.cover);

                    lightList.Add(newLight);
                }

                lightsInit = true;
                MaybeUpdateLightsToPeriod(true);

                if (!GameLights.gameLightsReady)
                {
                    GameLights.AddGameLights();
                }
            }
            else
            {
                //Debug.Log("[ambient-lights] ERROR: Config isn't ready or not present.");
                ALUtils.Log("ERROR: Config isn't ready or not present.", false, true);
            }
        }
Exemple #2
0
        public static void MaybeUpdateLightsToPeriod(bool forceUpdate = false)
        {
            if (lightsInit && timeInit && weatherInit && config.ready)
            {
                //Generate lightsets for emitters based on time, weather and transition progress
                LightSet lightSet = config.GetCurrentLightSet();

                if (lightSet != null)
                {
                    currentLightSet = lightSet;
                    foreach (var light in lightList)
                    {
                        LightOrientation set = lightSet.orientations[light.orientation];

                        if (set != null)
                        {
                            light.SetLightParams(set, forceUpdate);
                        }
                        else
                        {
                            //MelonLoader.MelonLogger.Log("[AL] No set matches orientation.");
                            ALUtils.Log("ERROR: No set matches orientation.", false, true);
                        }
                    }
                }
                else
                {
                    //MelonLoader.MelonLogger.Log("[AL] No lightset defined");
                    ALUtils.Log("ERROR: No lightset defined.", false, true);
                }
            }
        }
            public static void Postfix(TimeOfDay __instance)
            {
                ALUtils.hourNow   = GameManager.GetTimeOfDayComponent().GetHour();
                ALUtils.minuteNow = GameManager.GetTimeOfDayComponent().GetMinutes();

                //Debug.Log("[ambient-lights] Initialized at: " + ALUtils.hourNow + ":" + ALUtils.minuteNow);
                ALUtils.Log("Initialized at: " + ALUtils.hourNow + ":" + ALUtils.minuteNow, false, true);

                AmbientLights.timeInit = true;
                AmbientLights.MaybeUpdateLightsToPeriod(true);
            }
        internal float GetLightshaftStrength()
        {
            float str = ALUtils.GetShadowStrength(TimeWeather.currentWeather);

            if (TimeWeather.currentWeatherPct < 1f)
            {
                float prevStr = ALUtils.GetShadowStrength(TimeWeather.previousWeather);

                str = Mathf.Lerp(prevStr, str, TimeWeather.currentWeatherPct);
            }

            return(str);
        }
        private void LoadSceneConfig()
        {
            string sceneFile = "scene_" + scene + ".json";

            if (File.Exists(Path.Combine(AmbientLights.MODS_FOLDER_PATH, sceneFile)))
            {
                data = JSON.Load(File.ReadAllText(Path.Combine(AmbientLights.MODS_FOLDER_PATH, sceneFile))).Make <SceneConfig>();
            }
            else
            {
                //Debug.Log("[ambient-lights] No lighting data for scene " + scene + " found. Using game default.");
                ALUtils.Log("No lighting data for scene " + scene + " found. Using game default.", false, true);
            }
        }
        /****** Lightset Utils ******/

        internal float GetShadowStrength()
        {
            float shadowStr = ALUtils.GetShadowStrength(TimeWeather.currentWeather);

            if (TimeWeather.currentWeatherPct < 1f)
            {
                float prevStr = ALUtils.GetShadowStrength(TimeWeather.previousWeather);

                shadowStr = Mathf.Lerp(prevStr, shadowStr, TimeWeather.currentWeatherPct);
            }

            if (TimeWeather.currentPeriod == "night")
            {
                shadowStr *= .5f;
            }

            return(shadowStr);
        }
Exemple #7
0
        public static void LoadConfigs()
        {
            currentScene = GameManager.m_ActiveScene;

            //Debug.Log("[ambient-lights] Loaded Scene: " + currentScene);
            ALUtils.Log("Loading Scene: " + currentScene, false, true);

            if (currentScene != "MainMenu")
            {
                config = new LightConfig();
                config.Load();

                if (config.ready)
                {
                    currentLightSet = config.GetCurrentLightSet();
                }

                SetupLights();
            }
        }
        private void LoadGlobalConfig()
        {
            if (File.Exists(Path.Combine(AmbientLights.MODS_FOLDER_PATH, "weather_sets.json")))
            {
                weathersConfig = JSON.Load(File.ReadAllText(Path.Combine(AmbientLights.MODS_FOLDER_PATH, "weather_sets.json"))).Make <Dictionary <string, WeatherMod> >();
            }
            else
            {
                //Debug.Log("[ambient-lights] ERROR: No weather sets data found");
                ALUtils.Log("ERROR: No weather sets data found.", false, true);
            }

            if (File.Exists(Path.Combine(AmbientLights.MODS_FOLDER_PATH, "global_sets.json")))
            {
                periodsConfig = JSON.Load(File.ReadAllText(Path.Combine(AmbientLights.MODS_FOLDER_PATH, "global_sets.json"))).Make <Dictionary <string, AmbPeriod> >();
            }
            else
            {
                //Debug.Log("[ambient-lights] ERROR: No light sets data found");
                ALUtils.Log("ERROR: No light sets data found.", false, true);
            }
        }
        internal static int GetWindows()
        {
            GameObject[] rObjs = ALUtils.GetRootObjects().ToArray();

            int wCount = 0;

            foreach (GameObject rootObj in rObjs)
            {
                Renderer   childRenderer = rootObj.GetComponent <Renderer>();
                Renderer[] allRenderers  = rootObj.GetComponentsInChildren <Renderer>();
                //allRenderers.Add(childRenderer);
                allRenderers.AddItem(childRenderer);

                foreach (Renderer renderer in allRenderers)
                {
                    if (!renderer.gameObject.name.Contains("_XPZ_Window"))
                    {
                        foreach (Material mat in renderer.materials)
                        {
                            if (mat.name.ToLower().Contains("glow") && !renderer.gameObject.name.ToLower().Contains("truck") && !renderer.gameObject.name.ToLower().Contains("car") && !renderer.gameObject.name.ToLower().Contains("lamp"))
                            {
                                gameWindows.Add(renderer);
                                renderer.gameObject.name += "_XPZ_Window";

                                WindowsCastShadow(renderer.gameObject);
                                renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                                renderer.receiveShadows    = false;

                                wCount++;
                                break;
                            }
                        }
                    }
                }
            }

            return(wCount);
        }
Exemple #10
0
        public static void Reset(bool firstPass = true)
        {
            debugVer = Settings.options.verbose;
            verbose  = Settings.options.verbose;

            ALUtils.Log("Scene reset.", false);

            lightList.Clear();

            config = null;

            lightsInit = false;

            lightOverride    = false;
            showGameLights   = false;
            enableGameLights = true;

            if (firstPass)
            {
                TimeWeather.Reset();
                timeInit    = false;
                weatherInit = false;
            }
        }
Exemple #11
0
        internal void SetLightParams(LightOrientation set, bool instantApply = false)
        {
            set.intensity *= ALUtils.GetIntensityModifier();
            set.range     *= ALUtils.GetRangeModifier();

            currentSet = set;

            if (set.intensity > 0)
            {
                light.enabled = true;
            }
            else
            {
                light.enabled = false;
            }

            if (!AmbientLights.lightOverride)
            {
                SetLightIntensity(set.intensity);
                SetLightRange(set.range);
                SetLightColor(set.color);
            }
            else
            {
                light.shadows = LightShadows.None;
            }

            if (AmbientLights.showGameLights)
            {
                eLightMark.SetActive(true);
            }
            else
            {
                eLightMark.SetActive(false);
            }
        }
        internal float GetFlickeringMod()
        {
            if (TimeWeather.currentWeather == "clear" || TimeWeather.currentWeather == "aurora" || TimeWeather.currentWeather == "lightfog" || TimeWeather.currentWeather == "densefog")
            {
                return(0f);
            }

            float flickerMod = 0f;

            if (flickChange)
            {
                flickChange   = false;
                flickPosition = 0;
                flickStart    = flickTarget;

                flickInc = GameManager.GetWindComponent().GetSpeedMPH() / 2000f;

                switch (TimeWeather.currentWeather)
                {
                case "partlycloudy":
                    if (flickTarget <= 0)
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.5, 1)) * 0.4f;
                    }
                    else
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.5, 1)) * -0.2f;
                    }

                    flickInc    = ((float)ALUtils.GetRandomNumber(0.05, 0.8)) * flickInc;
                    flickChance = 0.0005f;
                    break;

                case "cloudy":
                case "lightsnow":
                case "heavysnow":
                    if (flickTarget <= 0)
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.5, 1)) * 0.1f;
                    }
                    else
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.5, 1)) * -0.1f;
                    }

                    flickInc    = ((float)ALUtils.GetRandomNumber(0.5, 1)) * flickInc;
                    flickChance = 0.002f;
                    break;

                case "blizzard":
                    if (flickTarget <= 0)
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.5, 1)) * 0.04f;
                    }
                    else
                    {
                        flickTarget = ((float)ALUtils.GetRandomNumber(0.7, 1)) * -0.04f;
                    }

                    flickInc    = ((float)ALUtils.GetRandomNumber(0.3, 2)) * flickInc;
                    flickChance = 0.75f;
                    break;
                }
            }

            if (flickPosition < 1f)
            {
                flickerMod     = Mathf.Lerp(flickStart, flickTarget, flickPosition);
                flickPosition += flickInc;
            }
            else
            {
                flickerMod = flickTarget;

                if ((float)ALUtils.GetRandomNumber(0, 1) < flickChance)
                {
                    flickChange = true;
                }
            }

            return(flickerMod);
        }
        internal static void UpdateAmbience(TodAmbientLight TodLightInstance, ref float multiplier)
        {
            if (AmbientLights.lightOverride || Settings.options.alPreset == ALPresets.TLD_Default)
            {
                TodLightInstance.m_AmbientIndoorsDay   = defaultColorDay;
                TodLightInstance.m_AmbientIndoorsNight = defaultColorNight;

                return;
            }

            if (defaultColorDay == null)
            {
                defaultColorDay = TodLightInstance.m_AmbientIndoorsDay;
            }

            if (defaultColorNight == null)
            {
                defaultColorNight = TodLightInstance.m_AmbientIndoorsNight;
            }

            multiplier *= Settings.options.ambienceLevel * AmbientLights.currentLightSet.intMod * AmbientLights.config.data.options.ambient_intensity_multiplier * AmbientLights.globalAmbienceLevel * ALUtils.GetIntensityNightMod();

            TodLightInstance.m_AmbientIndoorsDay   = AmbientLights.currentLightSet.ambientDayColor;
            TodLightInstance.m_AmbientIndoorsNight = AmbientLights.currentLightSet.ambientNightColor;
        }
        /****** SETUP ******/

        internal static void AddGameLights()
        {
            if (AmbientLights.config == null || !AmbientLights.config.ready)
            {
                return;
            }

            //if (AmbientLights.debugVer)
            //    Debug.Log("[ambient-lights] InteriorLightingManager initialized.");

            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Game Lights init");

            ALUtils.Log("Game Lights Manager initialized.");

            if (gameLightsList != null)
            {
                gameLightsList.Clear();
            }

            if (gameExtraLightsList != null)
            {
                gameExtraLightsList.Clear();
            }

            if (gameSpotLightsList != null)
            {
                gameSpotLightsList.Clear();
            }

            if (gameExtraLightsColors != null)
            {
                gameExtraLightsColors.Clear();
            }

            if (gameExtraLightsIntensity != null)
            {
                gameExtraLightsIntensity.Clear();
            }

            if (gameWindows != null)
            {
                gameWindows.Clear();
            }

            theSun   = null;
            sunlight = null;

            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Add Game Lights");
            ALUtils.Log("Adding game lights.", false);

            gameLights = new GameObject();

            List <InteriorLightingGroup> lightGroups = new List <InteriorLightingGroup>();

            InteriorLightingGroup[] lightGroupsArr = null;

            if (mngr != null)
            {
                lightGroupsArr = mngr.m_LightGroupList.ToArray();

                foreach (InteriorLightingGroup lightGroup in lightGroupsArr)
                {
                    lightGroups.Add(lightGroup);
                }
            }

            int pCount = 0;
            int sCount = 0;
            int wCount = 0;
            int eCount = 0;
            int lCount = 0;

            //Add sun
            if (!AmbientLights.currentScene.ToLower().Contains("cave") && Settings.options.trueSun)
            {
                //if (AmbientLights.debugVer)
                //    MelonLoader.MelonLogger.Log("[AL] Add sun");
                ALUtils.Log("Creating sun", false);

                theSun                    = new GameObject();
                theSun.name               = "AmbientLightsSun";
                sunlight                  = theSun.AddComponent <Light>();
                sunlight.type             = LightType.Directional;
                sunlight.shadows          = LightShadows.Soft;
                sunlight.shadowStrength   = 1f;
                sunlight.shadowNormalBias = 0;
                sunlight.shadowBias       = 0;
                sunlight.shadowResolution = UnityEngine.Rendering.LightShadowResolution.VeryHigh;

                sunlight.cullingMask &= ~(1 << 7);


                sunlight.intensity = 1f;

                theSun.transform.position = new Vector3(0, 2f, 0);
                sunlight.transform.parent = theSun.transform;

                Vector3 sunRotation = new Vector3(10f, 10f, 0);
                theSun.transform.localRotation = Quaternion.Euler(sunRotation);

                PrepareSceneShadows();
            }

            //Window Lights
            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Window lights");

            ALUtils.Log("Adding window lights", false);

            foreach (InteriorLightingGroup group in lightGroups)
            {
                List <Light> lights      = new List <Light>();
                Light[]      groupLights = group.GetLights().ToArray();

                foreach (Light gLight in groupLights)
                {
                    if (gLight != null)
                    {
                        lights.Add(gLight);
                    }
                    else
                    {
                        //if (AmbientLights.debugVer)
                        //    Debug.Log("[ambient-lights] gLight is null.");
                        ALUtils.Log("gLight is null", false);
                    }
                }

                foreach (Light light in lights)
                {
                    GameObject lightMark;

                    //Add lights to list and to debug object
                    if (light.type == LightType.Point)
                    {
                        lightMark = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        (lightMark.GetComponent(UnhollowerRuntimeLib.Il2CppType.Of <SphereCollider>()).Cast <Collider>()).enabled = false;

                        light.gameObject.name += "_XPZ_GameLight";

                        gameLightsList.Add(light);

                        pCount++;
                    }
                    else if (light.type == LightType.Spot)
                    {
                        lightMark = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        lightMark.transform.rotation = light.gameObject.transform.rotation;

                        sCount++;

                        light.gameObject.name += "_XPZ_SpotLight";

                        gameSpotLightsList.Add(light);
                    }
                    else
                    {
                        lightMark = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                    }

                    lightMark.transform.localScale = new Vector3(0.15f, 0.15f, 0.15f);
                    lightMark.transform.position   = light.gameObject.transform.position;

                    lightMark.transform.parent = gameLights.transform;

                    foreach (Renderer rend in lightMark.GetComponentsInChildren <Renderer>())
                    {
                        rend.material.color = light.color;
                        rend.receiveShadows = false;
                    }
                }
            }

            //Main Ambient Light
            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Main Ambient Light");

            ALUtils.Log("Adding main ambient light", false);

            if (mngr != null)
            {
                gameAmbientLight = mngr.m_AmbientLight;
            }
            else
            {
                TodAmbientLight[] array = UnityEngine.Object.FindObjectsOfType <TodAmbientLight>();
                if (array.Length > 0)
                {
                    gameAmbientLight = array[0];
                }
            }

            if (gameAmbientLight != null)
            {
                defaultColorDay   = gameAmbientLight.m_AmbientIndoorsDay;
                defaultColorNight = gameAmbientLight.m_AmbientIndoorsNight;

                gameAmbientLight.name += "_XPZ_AmbientLight";
                //if (AmbientLights.debugVer)
                //    Debug.Log("[ambient-lights] Ambient light found.");
                ALUtils.Log("Main ambient light found", false);
            }
            else
            {
                //if (AmbientLights.debugVer)
                //    Debug.Log("[ambient-lights] Ambient light NOT found.");
                ALUtils.Log("Main ambient light missing", false);
            }

            //Loose Lights
            //With Manager
            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Managed Loose Lights");

            ALUtils.Log("Adding managed loose lights", false);

            List <Light> looseLights       = new List <Light>();
            List <Light> looseLightsMidday = new List <Light>();

            Light[] lLightsArr = null;
            if (mngr != null && mngr.m_LooseLightList != null)
            {
                lLightsArr = mngr.m_LooseLightList.ToArray();
            }

            Light[] lLightsMidArr = null;
            if (mngr != null && mngr.m_LooseLightsMiddayList != null)
            {
                lLightsMidArr = mngr.m_LooseLightsMiddayList.ToArray();
            }

            List <Light> extraLights      = new List <Light>();
            List <Color> extraLightsColor = new List <Color>();

            if (lLightsArr != null)
            {
                foreach (Light l in lLightsArr)
                {
                    if (!l.gameObject.name.Contains("XPZ_SpotLight") && !l.gameObject.name.Contains("XPZ_GameLight"))
                    {
                        l.gameObject.name += "_XPZ_GameLight";
                        extraLights.Add(l);
                        lCount++;
                    }
                }
            }

            if (lLightsMidArr != null)
            {
                foreach (Light l in lLightsMidArr)
                {
                    if (!l.gameObject.name.Contains("XPZ_SpotLight") && !l.gameObject.name.Contains("XPZ_GameLight"))
                    {
                        l.gameObject.name += "_XPZ_GameLight";
                        extraLights.Add(l);
                        lCount++;
                    }
                }
            }

            foreach (Light light in extraLights)
            {
                extraLightsColor.Add(light.color);

                gameExtraLightsColors.Add(light.color);
                gameExtraLightsIntensity.Add(light.intensity);
                gameExtraLightsList.Add(light);
            }


            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Unmanaged Loose Lights");

            ALUtils.Log("Adding unmanaged loose lights", false);

            //No Manager
            UnhollowerBaseLib.Il2CppReferenceArray <UnityEngine.Object> sclights = UnityEngine.Object.FindObjectsOfType(UnhollowerRuntimeLib.Il2CppType.Of <Light>());

            foreach (UnityEngine.Object lightItem in sclights)
            {
                Light light = lightItem.Cast <Light>();

                if (!light.gameObject.name.Contains("XPZ_GameLight") && !light.gameObject.name.Contains("XPZ_Light") && light.type == LightType.Point)
                {
                    light.gameObject.name += "_XPZ_GameLight";
                    gameExtraLightsList.Add(light);
                    gameExtraLightsColors.Add(light.color);
                    gameExtraLightsIntensity.Add(light.intensity);
                    eCount++;
                }
                else if (!light.gameObject.name.Contains("XPZ_SpotLight") && !light.gameObject.name.Contains("XPZ_GameLight") && light.type == LightType.Spot)
                {
                    if (light.cookie && light.cookie.ToString().Contains("Window"))
                    {
                        light.gameObject.name += "_XPZ_SpotLight";
                        gameSpotLightsList.Add(light);
                    }
                    else
                    {
                        light.gameObject.name += "_XPZ_GameLight";
                        gameExtraLightsList.Add(light);
                        gameExtraLightsColors.Add(light.color);
                        gameExtraLightsIntensity.Add(light.intensity);
                        eCount++;
                    }
                }
            }

            //Add fill lights to debug object
            //if (AmbientLights.debugVer)
            //    MelonLoader.MelonLogger.Log("[AL] Add to debug");

            ALUtils.Log("Adding fill lights to debug object", false);

            foreach (Light light in gameExtraLightsList)
            {
                GameObject eLightMark;

                eLightMark = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                //eLightMark.GetComponent(typeof(SphereCollider)).Cast<Collider>().enabled = false;
                eLightMark.transform.localScale = new Vector3(0.15f, 0.15f, 0.15f);
                eLightMark.transform.position   = light.gameObject.transform.position;

                eLightMark.transform.parent = gameLights.transform;

                foreach (Renderer rend in eLightMark.GetComponentsInChildren <Renderer>())
                {
                    rend.material.color = light.color;
                    rend.receiveShadows = false;
                }
            }

            int weCount = GetWindows();

            if (!AmbientLights.showGameLights)
            {
                gameLights.SetActive(false);
            }

            //MelonLoader.MelonModLogger.Log("[AL] Done Preparing");
            //if (AmbientLights.debugVer)
            //    Debug.Log("[ambient-lights] Gamelights setup done. Window Lights:" + pCount + ". Spotlights:" + sCount +  ". Loose Lights:" + lCount + ". Windows:" + wCount + ". Windows outside lighting groups:" + weCount + ". Extra Lights:" + eCount);

            ALUtils.Log("Gamelights setup complete. Window Lights:" + pCount + ". Spotlights:" + sCount + ". Loose Lights:" + lCount + ". Windows:" + wCount + ". Windows outside lighting groups:" + weCount + ". Extra Lights:" + eCount, false);

            AmbientLights.SetupGameLights();

            gameLightsReady = true;
        }
Exemple #15
0
        public static void Update()
        {
            MaybeUpdateLightsToPeriod();

            ALUtils.HandleHotkeys();
        }
Exemple #16
0
 internal void DebugLightSet()
 {
     //if (AmbientLights.debugVer)
     //Debug.Log("Intensity: " + light.intensity + ", Range: " + light.range + ", Color: " + light.color);
     ALUtils.Log("Current Lightset - Intensity: " + light.intensity + ", Range: " + light.range + ", Color: " + light.color, false);
 }
        /****** SCENE *****/
        internal static void PrepareSceneShadows()
        {
            GameObject[] rObjs = ALUtils.GetRootObjects().ToArray();

            foreach (GameObject rootObj in rObjs)
            {
                MeshRenderer   childRenderer = rootObj.GetComponent <MeshRenderer>();
                MeshRenderer[] allRenderers  = rootObj.GetComponentsInChildren <MeshRenderer>();
                //allRenderers.Add(childRenderer);
                allRenderers.AddItem(childRenderer);

                foreach (MeshRenderer renderer in allRenderers)
                {
                    //Remove glass from sun layer
                    Material[] mats = renderer.materials;

                    foreach (Material mat in mats)
                    {
                        if (mat.name.ToLower().Contains("glass"))
                        {
                            renderer.gameObject.layer = 7;
                            continue;
                        }
                    }

                    //Ignore
                    if (renderer == null || renderer.gameObject.name.Contains("XPZ_Wall") || renderer.gameObject.name.Contains("XPZ_BaseWindow") ||
                        (renderer.gameObject.name.StartsWith("OBJ_") && !renderer.gameObject.name.ToLower().Contains("door") && !renderer.gameObject.name.ToLower().Contains("curtain") && !renderer.gameObject.name.ToLower().Contains("car")) ||
                        renderer.gameObject.name.StartsWith("GEAR_") ||
                        renderer.gameObject.name.StartsWith("FX_") ||
                        renderer.gameObject.name.StartsWith("CONTAINER_") ||
                        renderer.gameObject.name.StartsWith("INTERACTIVE_")
                        )
                    {
                        continue;
                    }

                    //Hide
                    if (renderer.gameObject.name.ToLower().Contains("shadow_caster") ||
                        (renderer.gameObject.name.ToLower().Contains("cylinder") && !renderer.material.name.StartsWith("FX_")) ||
                        renderer.gameObject.name.ToLower().Contains("sphere")
                        )
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                        renderer.gameObject.SetActive(false);

                        continue;
                    }

                    //Glass-Glow
                    if ((renderer.gameObject.name.ToLower().Contains("glass") || renderer.gameObject.name.ToLower().Contains("glow")) && (!renderer.gameObject.name.ToLower().Contains("shadow") && !renderer.gameObject.name.ToLower().Contains("truck") && !renderer.gameObject.name.ToLower().Contains("car") && !renderer.gameObject.name.ToLower().Contains("xpz_window")))
                    {
                        renderer.gameObject.name += "_XPZ_BaseWindow";

                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

                        continue;
                    }
                    else if (renderer.gameObject.name.ToLower().Contains("glow") && renderer.gameObject.name.ToLower().Contains("shadow"))
                    {
                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                        renderer.gameObject.SetActive(false);

                        continue;
                    }

                    if (renderer.gameObject.name.ToLower().Contains("decal"))
                    {
                        renderer.receiveShadows = true;
                        qd_Decal decalInst = renderer.GetComponent <qd_Decal>();

                        vp_Layer.Set(renderer.gameObject, 7, false);

                        continue;
                    }

                    //Rest - Cast shadows if not transparent
                    if (renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.Off || renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On)
                    {
                        //Material[] mats = renderer.materials;

                        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.TwoSided;

                        /*foreach (Material mat in mats)
                         * {
                         *  if (mat.name.ToLower().Contains("glass"))
                         *  {
                         *      renderer.gameObject.layer = 7;
                         *      continue;
                         *  }
                         * }*/
                    }
                    else if (renderer.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly)
                    {
                        FlipMesh(renderer.gameObject);
                    }
                }
            }
        }