Console command helpers for the Easter-egg system. Provides commands to list all EE flags, set a single flag, reset flags, and run a self-test that builds two EggStep instances and exercises availability, rewards, exclusion and the general DoorLinks bridge.
using System.Linq;
using Sandbox;
namespace NZombies;
/// <summary>
/// Console access to the Easter-egg flag pool while there is no editor UI yet — the same role the
/// wall-buy and time commands play. Lets the flag core and <see cref="EggStep"/> be exercised and
/// verified over MCP before any interactable exists to drive them.
/// </summary>
public static class EggCommands
{
/// <summary>`nz_egg` — dump every EE flag: index, name, and whether it is active.</summary>
[ConCmd( "nz_egg" )]
public static void Dump()
{
var flags = EggFlags.Snapshot().ToList();
Log.Info( $"[nz-egg] {flags.Count} flag(s) · General(open): {DoorLinks.Summary}" );
foreach ( var (flag, value, index) in flags )
Log.Info( $"[nz-egg] #{index,-3} {(value ? "ON " : "off")} {flag}" );
if ( flags.Count == 0 )
Log.Info( "[nz-egg] (none yet — nz_egg_set <flag> 1, or load a map with EE steps)" );
}
/// <summary>`nz_egg_set <flag> [0|1]` — set an EE flag by hand, for testing.</summary>
[ConCmd( "nz_egg_set" )]
public static void SetFlag( string flag = "", int value = 1 )
{
if ( string.IsNullOrWhiteSpace( flag ) ) { Log.Warning( "[nz-egg] usage: nz_egg_set <flag> [0|1]" ); return; }
EggFlags.Set( flag, value != 0 );
Log.Info( $"[nz-egg] {flag} = {(value != 0 ? "ON" : "off")} (#{EggFlags.IndexOf( flag )})" );
}
/// <summary>`nz_egg_reset` — clear all flag values (indices stay, as the tie-break needs).</summary>
[ConCmd( "nz_egg_reset" )]
public static void ResetFlags()
{
EggFlags.Reset();
Log.Info( "[nz-egg] flag values cleared" );
}
/// <summary>
/// `nz_egg_selftest` — build a two-step branch in code and walk it, proving availability,
/// reward, exclusion lock-out and the General-flag bridge without needing a placed interactable.
/// </summary>
[ConCmd( "nz_egg_selftest" )]
public static void SelfTest()
{
EggFlags.Reset();
// Step A: available from the start, rewards flag "a" and opens General link "power".
var a = new EggStep { Reward = { "a" }, GeneralReward = "power" };
// Step B: needs "a", excluded once "b_locked" is set. Rewards "b".
var b = new EggStep { Required = { "a" }, Excluded = { "b_locked" }, Reward = { "b" } };
a.RegisterFlags(); b.RegisterFlags();
Log.Info( $"[nz-egg] start A avail={a.IsAvailable()} (exp True) B avail={b.IsAvailable()} (exp False — needs 'a')" );
a.Complete();
Log.Info( $"[nz-egg] after A a={EggFlags.IsSet( "a" )} (exp True) power open={DoorLinks.IsOpen( "power" )} (exp True) B avail={b.IsAvailable()} (exp True)" );
EggFlags.Set( "b_locked", true );
Log.Info( $"[nz-egg] lock B B avail={b.IsAvailable()} (exp False — excluded)" );
EggFlags.Set( "b_locked", false );
b.Complete();
Log.Info( $"[nz-egg] after B b={EggFlags.IsSet( "b" )} (exp True) B avail={b.IsAvailable()} (exp False — completed)" );
Dump();
}
}