Skip to content
Ashley Muncaster edited this page Apr 13, 2024 · 9 revisions

A state is an object held by each member that describes their current situation in the game. It can describe various properties about the member, but more importantly, it controls how each member sees and interacts with the room. A state has many parts to it, including theme, presets, and ui.

Creating a State Asset

To create a state asset, either go to AssetsCreateHackboxState Asset, or right-click in the assets window, and go to CreateHackboxState Asset, and then name the state asset appropriately:

image

Then edit the theme of the state by dropping in a theme asset object on the Theme property. From there, you can adjust the parameters of the header and main sections of the UI, and then you can specify the set of components that will appear in the state.

image

Parameters in the parameter list of each component will add/override the parameters specified in the preset that it derives from.

Creating a State in code

To create and configure a State object:

Hackbox.State someState = State.Create(myTheme);
someState.HeaderText = "Some header text";
someState.HeaderBackground = "#ffffff";

Hackbox.UI.UIComponent component = Hackbox.UI.UIComponent.Create("myComponent", myPreset);
component.Add("text", "Hello world!");
someState.Add(component);

Or with some more modern C# language features:

State newState = new(myTheme)
{
    HeaderText = "Some header text",
    HeaderBackground = "#ffffff",
    ["myComponent"] = new(myPreset)
    {
        { "text", "Hello world!" }
    }
};

Applying States to Members

To apply the state to members, you can do any of the following:

  • Apply to a specific member with Host.UpdateMemberState(state),
  • Apply to multiple members with Host.UpdateMemberStates(members, state), or
  • Apply to all members with Host.UpdateAllMemberStates(state)
Clone this wiki locally