Runtime console command helper for the map's SkyBox2D components. It finds SkyBox2D in the active scene and lets you toggle enabled state, adjust tint brightness, yaw rotation, and whether it contributes indirect lighting, logging results to console.
using Sandbox;
using System.Linq;
namespace NZombies;
/// <summary>
/// The map's own sky: a <see cref="SkyBox2D"/> placed in its map scene (Laketown's aurora,
/// 2026-10-02). A map without one shows the camera's clear colour above it.
///
/// ⚠️ LIVE ONLY, NOTHING IS SAVED. The sky belongs to the map scene, so a change that should stay
/// is made there; this exists so the sky can be judged, and tuned, in play.
/// </summary>
public static class MapSky
{
/// <summary>
/// `nz_sky` — the skies on this map. `nz_sky off|on`; `nz_sky bright <x>` sets the tint
/// (1 = as authored); `nz_sky turn <degrees>` yaws it, since the sky follows its object's
/// rotation; `nz_sky light 1|0` lets it light the map as well (SkyIndirectLighting: a
/// world-sized cubemap of the sky, which shiny surfaces and water reflect).
/// </summary>
[ConCmd( "nz_sky" )]
public static void Sky( string part = "", float value = float.NaN )
{
// ⚠️ DISABLED ONES TOO: `nz_sky off` disables the component, and `on` has to find it again.
var skies = Game.ActiveScene?.Components
.GetAll<SkyBox2D>( FindMode.EverythingInSelfAndDescendants ).ToList();
if ( skies is null || skies.Count == 0 )
{
Log.Info( "[nz-sky] no SkyBox2D on this map - the sky is the camera's clear colour" );
return;
}
var verb = part.ToLowerInvariant();
if ( ( verb == "bright" || verb == "turn" || verb == "light" ) && float.IsNaN( value ) )
{
Log.Warning( $"[nz-sky] nz_sky {verb} <number>" );
return;
}
foreach ( var s in skies )
{
switch ( verb )
{
case "": break;
case "on": s.Enabled = true; break;
case "off": s.Enabled = false; break;
case "bright": s.Tint = new Color( value, value, value, 1f ); break;
case "turn": s.WorldRotation = Rotation.FromYaw( value ); break;
case "light": s.SkyIndirectLighting = value != 0f; break;
default:
Log.Warning( $"[nz-sky] no such part '{part}' - on, off, bright, turn, light" );
return;
}
// ⚠️ "material none" IS A REFUSED MATERIAL. SkyBox2D silently drops one whose shader is
// not a sky shader, or that failed to load, and then draws nothing.
Log.Info( $"[nz-sky] '{s.GameObject.Name}' {( s.Enabled ? "on" : "OFF" )}"
+ $" material {s.SkyMaterial?.Name ?? "none"}"
+ $" tint {s.Tint.r:0.##},{s.Tint.g:0.##},{s.Tint.b:0.##}"
+ $" yaw {s.WorldRotation.Yaw():0}"
+ ( s.SkyIndirectLighting ? " lights the map too" : " look only, the lighting is the map's" ) );
}
if ( verb != "" )
Log.Info( "[nz-sky] live only - the map scene keeps its own sky" );
}
}