Ejemplo n.º 1
0
        public static void EnableNightVisionEffect(AbstractActor source)
        {
            // Skip if the green effect is disabled
            if (!Mod.Config.Toggles.ShowNightVision)
            {
                return;
            }

            ModState.IsNightVisionMode = true;

            MoodController mc = ModState.GetMoodController();

            Traverse uppT = Traverse.Create(mc).Field("unityPostProcess");
            PostProcessingBehaviour ppb = uppT.GetValue <PostProcessingBehaviour>();

            // Enable grain and set the intensity
            Traverse       grainT = Traverse.Create(ppb).Field("m_Grain");
            GrainComponent gc     = grainT.GetValue <GrainComponent>();

            GrainModel.Settings gms = gc.model.settings;
            gms.intensity     = 0.8f;
            gms.size          = 1.0f;
            gc.model.settings = gms;

            Traverse   sunlightBTT = Traverse.Create(mc).Field("sunlightBT");
            BTSunlight sunlightBT  = sunlightBTT.GetValue <BTSunlight>();

            // Disable shadows from sunlight
            //BTSunlight.SunlightSettings sunlightS = sunlightBT.sunSettings;
            //sunlightS.castShadows = false;
            //sunlightBT.sunSettings = sunlightS;
            Traverse sunlightT = Traverse.Create(sunlightBT).Field("sunLight");
            Light    sunlight  = sunlightT.GetValue <Light>();

            sunlight.shadows = LightShadows.None;

            // Set the sunlight color
            Color lightVision = Color.green;

            lightVision.a = 0.8f;
            Shader.SetGlobalColor(Shader.PropertyToID("_BT_SunlightColor"), lightVision);

            // Disable opacity from the clouds
            Shader.SetGlobalFloat(Shader.PropertyToID("_BT_CloudOpacity"), 0f);

            // Make the sunlight point straight down
            Shader.SetGlobalVector(Shader.PropertyToID("_BT_SunlightDirection"), sunlightBT.transform.up);
        }
Ejemplo n.º 2
0
        public static void DisableNightVisionEffect()
        {
            // Skip if the green effect is disabled
            if (!Mod.Config.Toggles.ShowNightVision)
            {
                return;
            }

            ModState.IsNightVisionMode = false;

            MoodController mc = ModState.GetMoodController();

            // Grain will disable automatically

            // Re-enable shadows
            Traverse   sunlightBTT = Traverse.Create(mc).Field("sunlightBT");
            BTSunlight sunlightBT  = sunlightBTT.GetValue <BTSunlight>();

            // Re-enable shadows from sunlight
            BTSunlight.SunlightSettings sunlightS = sunlightBT.sunSettings;
            //sunlightS.castShadows = false;
            //sunlightBT.sunSettings = sunlightS;
            Traverse sunlightT = Traverse.Create(sunlightBT).Field("sunLight");
            Light    sunlight  = sunlightT.GetValue <Light>();

            sunlight.shadows = (sunlightS.castShadows) ? LightShadows.None : LightShadows.Soft;

            // Reset the sunlight color
            Shader.SetGlobalColor(Shader.PropertyToID("_BT_SunlightColor"), mc.currentMood.sunlight.sunColor);

            // Re-enable opacity from the clouds
            Shader.SetGlobalFloat(Shader.PropertyToID("_BT_CloudOpacity"), mc.currentMood.sunlight.cloudOpacity);

            // Point sunlight forward
            Shader.SetGlobalVector(Shader.PropertyToID("_BT_SunlightDirection"), sunlightBT.transform.forward);
        }