Environment/NightEnvironmentController.cs

A small Scene Component that runs each update and disables any DirectionalLight or SkyBox2D components whose GameObject name does not match the expected night scene names. It keeps only the "Sun" directional light enabled and only the "2D Skybox" skybox enabled so map-provided daylight does not conflict with the demo moonlight.

using Sandbox;

namespace AdaptiveDirectorDemo.Environment;

/// <summary>
/// Ensures the map-provided daylight does not compete with the demo's moonlight
/// and dark sky. MapInstance creates its environment after the scene starts, so
/// this policy is enforced at runtime instead of relying on load order.
/// </summary>
[Title( "Night Environment Controller" )]
[Category( "Adaptive Director Demo" )]
public sealed class NightEnvironmentController : Component
{
	protected override void OnUpdate()
	{
		foreach ( var light in Scene.GetAllComponents<DirectionalLight>() )
			light.Enabled = light.GameObject.Name == "Sun";

		foreach ( var sky in Scene.GetAllComponents<SkyBox2D>() )
			sky.Enabled = sky.GameObject.Name == "2D Skybox";
	}
}