public static void Prefix()
 {
     if (!InterfaceManager.IsMainMenuActive())
     {
         AmbientLightControl.ResetAmbientLights();
     }
 }
        public static void Postfix(TimeOfDay __instance)
        {
            AmbientLightUtils.hour_now   = GameManager.GetTimeOfDayComponent().GetHour();
            AmbientLightUtils.minute_now = GameManager.GetTimeOfDayComponent().GetMinutes();

            Debug.Log("[ambient-lights] Initialized at: " + AmbientLightUtils.hour_now + ":" + AmbientLightUtils.minute_now);

            AmbientLightControl.scene_time_init = true;
            AmbientLightControl.MaybeUpdateLightsToPeriod(true);
        }
        protected override void OnConfirm()
        {
            AmbientLightsOptions.enable_shadows         = false;
            AmbientLightsOptions.intensity_multiplier   = intensity_multiplier;
            AmbientLightsOptions.range_multiplier       = range_multiplier;
            AmbientLightsOptions.aurora_intensity       = aurora_intensity;
            AmbientLightsOptions.disable_aurora_flicker = disable_aurora_flicker;
            AmbientLightsOptions.night_brightness       = night_brightness;
            AmbientLightsOptions.enable_debug_key       = enable_debug_key;

            AmbientLightControl.light_override = false;
            AmbientLightControl.MaybeUpdateLightsToPeriod(true);

            string json_opts = FastJson.Serialize(this);

            File.WriteAllText(Path.Combine(AmbientLightControl.mod_data_folder, "config.json"), json_opts);
        }
 public static void Postfix(TimeOfDay __instance)
 {
     AmbientLightControl.Update();
 }
 public static void Postfix(Weather __instance)
 {
     AmbientLightControl.scene_weather_init = true;
     AmbientLightControl.MaybeUpdateLightsToPeriod(true);
 }
 private static void Postfix(MissionServicesManager __instance)
 {
     AmbientLightControl.RegisterLights();
 }
Exemple #7
0
        public static void RegisterCommands()
        {
            uConsole.RegisterCommand("light_int", new uConsole.DebugCommand(() =>
            {
                float intensity = uConsole.GetFloat();
                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsIntensity(intensity);
            }));

            uConsole.RegisterCommand("lightset_int", new uConsole.DebugCommand(() =>
            {
                string set      = uConsole.GetString();
                float intensity = uConsole.GetFloat();

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsIntensity(intensity, set);
            }));

            uConsole.RegisterCommand("light_range", new uConsole.DebugCommand(() =>
            {
                float range = uConsole.GetFloat();

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsRange(range);
            }));

            uConsole.RegisterCommand("lightset_range", new uConsole.DebugCommand(() =>
            {
                string set  = uConsole.GetString();
                float range = uConsole.GetFloat();

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsRange(range, set);
            }));

            uConsole.RegisterCommand("light_color", new uConsole.DebugCommand(() =>
            {
                string colorR = uConsole.GetString();
                string colorG = uConsole.GetString();
                string colorB = uConsole.GetString();

                Color32 color = AmbientLightUtils.ParseColor32(colorR + "," + colorG + "," + colorB);

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsColor(color);
            }));

            uConsole.RegisterCommand("lightset_color", new uConsole.DebugCommand(() =>
            {
                string set = uConsole.GetString();

                string colorR = uConsole.GetString();
                string colorG = uConsole.GetString();
                string colorB = uConsole.GetString();

                Color32 color = AmbientLightUtils.ParseColor32(colorR + "," + colorG + "," + colorB);

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsColor(color, set);
            }));

            uConsole.RegisterCommand("light_shadow", new uConsole.DebugCommand(() =>
            {
                string shadow = uConsole.GetString();

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsShadow(shadow);
            }));

            uConsole.RegisterCommand("lightset_shadow", new uConsole.DebugCommand(() =>
            {
                string set    = uConsole.GetString();
                string shadow = uConsole.GetString();

                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsShadow(shadow, set);
            }));

            uConsole.RegisterCommand("light_on", new uConsole.DebugCommand(() =>
            {
                AmbientLightControl.light_override = false;
                AmbientLightControl.MaybeUpdateLightsToPeriod(true);
            }));

            uConsole.RegisterCommand("light_off", new uConsole.DebugCommand(() =>
            {
                AmbientLightControl.light_override = true;
                AmbientLightControl.SetLightsIntensity(0f);
            }));

            uConsole.RegisterCommand("debug_config", new uConsole.DebugCommand(() =>
            {
                Debug.Log(Utils.SerializeObject(AmbientLightControl.config));
                Debug.Log(Utils.SerializeObject(AmbientLightControl.global_periods_config));
            }));

            uConsole.RegisterCommand("p", new uConsole.DebugCommand(() =>
            {
                GetPoint();
            }));

            uConsole.RegisterCommand("lobj", new uConsole.DebugCommand(() =>
            {
                string obj_name = uConsole.GetString();
                GetObjectsWithName(obj_name);
            }));
        }
Exemple #8
0
        public void SetLightParams(AmbientConfigPeriodSet set, bool instant_apply = false)
        {
            start_set = target_set;

            target_set = new AmbientConfigPeriodSet
            {
                intensity = set.intensity * AmbientLightControl.GetIntensityModifier(),
                range     = set.range * AmbientLightControl.GetRangeModifier(),
                color     = set.color,
                shadows   = set.shadows
            };

            if (start_set == null)
            {
                start_set     = target_set;
                instant_apply = true;
            }

            if (set.intensity != 0)
            {
                light_source.enabled = true;
            }
            else
            {
                light_source.enabled = false;
            }

            if (AmbientLightControl.config.options.override_shadows != "")
            {
                set.shadows = AmbientLightControl.config.options.override_shadows;
            }

            if (!AmbientLightsOptions.enable_shadows)
            {
                light_source.shadows = LightShadows.None;
            }
            else
            {
                if (set.shadows.ToLower() == "hard")
                {
                    //Hard shadows don't work well
                    //light_source.shadows = LightShadows.Hard;
                    light_source.shadows = LightShadows.Soft;
                }
                else if (set.shadows.ToLower() == "soft")
                {
                    light_source.shadows = LightShadows.Soft;
                }
                else
                {
                    light_source.shadows = LightShadows.None;
                }
            }


            if (instant_apply && !AmbientLightControl.light_override)
            {
                SetLightIntensity(target_set.intensity);
                SetLightRange(target_set.range);
                SetLightColor(AmbientLightUtils.ParseColor32(target_set.color));

                if (AmbientLightsOptions.verbose)
                {
                    DebugLightSet();
                }
            }
        }