// WeatherControl.cs // Changes a dynamic sky's weather for everybody in the world (the scene's Sky must be Dynamic sky in Scene Settings). // Click this object to change to Weather; click Clear Button (optional) to go back to the scene's own weather. Lightning // Button (optional) makes lightning strike now. Night Button (optional) jumps the sky's clock to Night Hour. // Everyone sees the same, and players who join later see it too. using IHXR.Simulation; public class WeatherControl : ScriptBase { [Tooltip("The weather to change to.")] public WeatherPreset Weather = WeatherPreset.Thunderstorm; [Tooltip("How long the change takes, in seconds.")] public float BlendSeconds = 15f; public string ClickHint = "Change the weather"; [Tooltip("Optional: an object that puts the scene's own weather back.")] public SceneObject ClearButton; [Tooltip("Optional: an object that makes lightning strike now.")] public SceneObject LightningButton; [Tooltip("Optional: an object that jumps the sky's clock to Night Hour (click again for the scene's own time).")] public SceneObject NightButton; public float NightHour = 23f; bool night; public override void Start() { MakeInteractable(click => SetWeather(Weather, BlendSeconds), true, null, true, 10f, ClickHint); if (ClearButton != null && !ClearButton.IsNull) MakeInteractable(ClearButton, click => ClearWeather(BlendSeconds), true, null, true, 10f, "Back to the usual weather"); if (LightningButton != null && !LightningButton.IsNull) MakeInteractable(LightningButton, click => TriggerLightning(), true, null, true, 10f, "Lightning!"); if (NightButton != null && !NightButton.IsNull) MakeInteractable(NightButton, click => { night = !night; if (night) SetTimeOfDay(NightHour); else ResetTimeOfDay(); }, true, null, true, 10f, "Day / night"); } }