Skip to content

ControlProfile

public sealed class ControlProfile

Namespace Chassis.Api

Added in 1.2.0

One switch in the cockpit a seated player can use in first person: look at it and click, or turn a knob with the mouse wheel. Everyone within reach (about 0.9 m from the eyes) can use it; the click goes through the host to every peer, and Chassis keeps and saves the state of toggles and knobs.

Example

A toggle for the headlights and a button for a mod’s own action:

profile.Controls.Add(new ControlProfile { Name = "lights", Kind = "toggle", Path = "Dash/LightSwitch", Action = "lights", Source = "lights" });
profile.Controls.Add(new ControlProfile { Name = "siren", Kind = "button", Path = "Dash/SirenButton", Action = "mymod.siren" });
public string Name = string.Empty

Added in 1.2.0

Name of the switch, unique in the profile; the saved state and ChassisApi.ControlValue use it.

public string Label = string.Empty

Added in 1.2.0

The name the player reads under the centre dot while looking at the switch.

Value For example “Hazard lights”. Empty shows Name with a capital first letter and spaces for ”_”.

public string Kind = "button"

Added in 1.2.0

“button”, “toggle” or “knob”.

Value “button” fires its action on a click and springs back. “toggle” flips between 0 and 1 on a click. “knob” steps between Min and Max with the mouse wheel; a click puts it back to Default.

public string Path = string.Empty

Added in 1.2.0

The transform that moves and that the player aims at, below the vehicle’s frame.

Value A path or one name, searched as GaugeProfile.Path. Its renderers give the area to aim at unless BoxSize is set.

public string Action = string.Empty

Added in 1.2.0

What the switch does.

Value A built-in action: “lights” (headlights on/off), “hazard” (hazard lights on/off), “indicator” (a knob from -1 left to 1 right), “indicator_left”, “indicator_right”, “horn” or “trip_reset”. Any other name is a mod’s own action from ChassisApi.RegisterControlAction; empty does nothing but keep the state.

public string Source = string.Empty

Added in 1.2.0

A source whose value the switch shows instead of its own state, or empty.

Value For switches whose state can change without them: “lights” for a light switch (the light key also switches), “hazard”, “indicator”. Any source from ChassisApi.GaugeSources works.

public Vector3 Axis = Vector3.right

Added in 1.2.0

The axis the switch turns about (toggle, knob) or moves along (button), in its own space.

Value A direction, e.g. (1, 0, 0) for a rocker switch that tips forward and back, (0, 0, 1) for a button pushed forward.

public float Angle = 30f

Added in 1.2.0

Toggle: degrees between off and on. Knob: degrees from Min to Max.

Value The rest pose is the middle: a toggle stands at -Angle/2 off and +Angle/2 on.

public float Press = 0.004f

Added in 1.2.0

Button: how far it moves along Axis while pressed, in metres.

public float Min

Added in 1.2.0

Knob: lowest value.

public float Max = 1f

Added in 1.2.0

Knob: highest value.

public float Step = 0.1f

Added in 1.2.0

Knob: change per notch of the mouse wheel.

public float Default

Added in 1.2.0

Toggle and knob: the value before anyone touched it, and a knob’s value after a click.

public Vector3 BoxCenter

Added in 1.2.0

Centre of the area to aim at, in the switch transform’s own space; used when BoxSize is set.

public Vector3 BoxSize

Added in 1.2.0

Size of the area to aim at in metres, in the switch transform’s own space; zero uses its renderers.

Value Set it for a switch with no renderer of its own, or to make a small one easier to hit.