-
Notifications
You must be signed in to change notification settings - Fork 2
States
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.
To create a state asset, either go to Assets → Create → Hackbox → State Asset, or right-click in the assets window, and go to Create → Hackbox → State Asset, and then name the state asset appropriately:
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.
Parameters in the parameter list of each component will add/override the parameters specified in the preset that it derives from.
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!" }
}
};
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)