Skip to content

Beam

public static class Beam

Namespace TightBeam.Api

TightBeam’s cross-mod control API for the player’s flashlight. Reference TightBeam.Api.dll OR drop this single file into your mod. Drive the beam from any mod: on/off, brightness, range, colour, plus Blink/Flicker/Pulse and scoped per-field overrides (e.g. dim it in a dark room, flicker it near power).

Every call is a zero-overhead no-op when TightBeam is not installed and lights up automatically when it is, so you can ship this unconditionally with no hard dependency. All calls MUST be on the Unity main thread.

using TightBeam.Api;
Beam.Blink(3); // event blink
var ov = Beam.BeginOverride("MyMod"); // scoped, per-field override
ov.SetIntensity(1f).SetSpotAngle(28f); // dim + narrow while in a zone
ov.Dispose(); // release -> beam returns to the player's own settings

Intensity is the Unity light intensity. The player’s base rests at 7 and is held between MinIntensity (1) and MaxIntensity (20) from the TightBeam preferences. Range is in metres and the drawn beam stays between 2 and 60. The spot angle is the full cone angle in degrees and stays between 8 and 90. Without a pinned value both follow the player’s focus: 34 m at 16 degrees fully narrow, 8 m at 66 degrees fully wide, with the default preferences. Colour channels run from 0 to 1; the default beam colour is #E6F2FF. Times are in seconds of game time. Effects (blink, flicker, pulse) scale the intensity on top of the base and the overrides.

Example

A red, flickering beam for three seconds after an explosion:

Beam.SetTemporaryColor(1f, 0.2f, 0.2f, 3f);
Beam.Flicker(0.8f, 3f);
public static bool Available { get; }

True only when the TightBeam host is installed AND bound. You rarely need this - the API is a safe no-op when absent.

public static int AbiVersion { get; }

ABI version of the host that is installed: 0 when absent, 1 for local-only builds, 2 and up once the other players’ beams can be read.

public static bool IsOn { get; }

Whether the local flashlight is on.

Value Follows the game’s own phone flashlight, so it is false while the player sits in a vehicle. False when TightBeam is absent.

public static float Intensity { get; }

The intensity the beam shows this frame.

Value The Unity light intensity, with overrides and effects applied, e.g. 7 at rest. 0 when TightBeam is absent.

public static float Range { get; }

The range the beam shows this frame.

Value In metres, from 2 to 60. 0 when TightBeam is absent.

public static float SpotAngle { get; }

The cone angle the beam shows this frame.

Value The full cone angle in degrees, from 8 to 90. 0 when TightBeam is absent.

public static bool IsMultiplayer { get; }

True while in a session with at least one other player.

public static ulong LocalSteamId { get; }

The local player’s SteamID64, or 0 when it is not known yet.

public static ulong[] RemoteIds { get; }

Every other player whose beam is being tracked. Never null; empty when alone or absent.

public static event Action<bool> OnToggled

Fires whenever the flashlight actually transitions on/off (player key or any mod’s SetOn/Toggle).

public static event Action<ulong, bool> OnRemoteToggled

Fires when ANOTHER player’s beam goes on or off: (steamId, isOn).

public static void GetColor(
out float r,
out float g,
out float b,
out float a)

The colour the beam shows this frame.

Parameter
rRed, 0 to 1.
gGreen, 0 to 1.
bBlue, 0 to 1.
aAlpha, 0 to 1. All four are 0 when TightBeam is absent.
public static void TurnOn()

Turns the flashlight on, like SetOn(true).

public static void TurnOff()

Turns the flashlight off, like SetOn(false).

public static void Toggle()

Switches the game’s flashlight to the other state, with its sound.

public static void SetOn(bool on)

Switches the game’s own flashlight, with its sound. It does nothing when the state already matches.

Parameter
ontrue turns it on, false off.
public static void SetIntensity(float value)

Sets the base intensity the beam rests at.

Parameter
valueThe Unity light intensity, e.g. 7. It is clamped to MinIntensity (1) and MaxIntensity (20) from the preferences.
public static void SetRange(float meters)

Pins the base range. The pin holds until the player changes the focus with the scroll wheel.

Parameter
metersThe range in metres, e.g. 20. It is clamped to 2 to 60.
public static void SetSpotAngle(float degrees)

Pins the base cone angle. The pin holds until the player changes the focus with the scroll wheel.

Parameter
degreesThe full cone angle in degrees, e.g. 30. It is clamped to 8 to 90.
public static void SetColor(float r, float g, float b, float a = 1f)

Sets the base beam colour.

Parameter
rRed, 0 to 1.
gGreen, 0 to 1.
bBlue, 0 to 1.
aAlpha, 0 to 1. The default is 1.
public static void SetColorHex(string hex)

Sets the base beam colour from a hex string.

Parameter
hex“#RRGGBB” or “#RRGGBBAA”, the ”#” optional, e.g. “#E6F2FF”. Without AA the alpha is 1. Null, fewer than 6 digits or a value that is not hex changes nothing.
public static void Blink(int times, float intervalSeconds = 0.12f)

Blinks the beam dark and back. It does nothing while the beam is off, and a started blink cannot be stopped.

Parameter
timesHow many blinks, from 1 to 20. Higher counts blink 20 times; 0 or less does nothing.
intervalSecondsSeconds for each dark and each lit half, at least 0.02. The default is 0.12.
public static void Flicker(
float strength01,
float durationSeconds,
float frequencyHz = 14f)

Flickers the beam with smooth noise. A new flicker or a pulse replaces the running one.

Parameter
strength010 to 1. The intensity drops by up to this share: 0.8 dims it down to 20 percent at the lowest.
durationSecondsHow long it runs, at least 0.05 seconds.
frequencyHzHow fast the noise changes, at least 0.1. The default is 14.
public static void StopFlicker()
public static void Pulse(
float amplitude01,
float periodSeconds,
float durationSeconds)

Swells the beam brighter and darker along a sine wave. A new pulse or a flicker replaces the running one.

Parameter
amplitude010 to 1. The intensity swings by this share both ways: 0.3 runs from 70 to 130 percent.
periodSecondsSeconds for one full swing, at least 0.1.
durationSecondsHow long it runs, at least 0.05 seconds. float.PositiveInfinity runs until StopPulse.
public static void StopPulse()
public static void SetTemporaryIntensity(
float value,
float seconds,
float fadeSeconds = 0.25f)

Overrides the intensity for a while, then the beam returns to its own value.

Parameter
valueThe Unity light intensity. It is not held to MinIntensity and MaxIntensity; below 0 shows as 0.
secondsHow long it holds, at least 0.05.
fadeSecondsNot passed to TightBeam; the value switches without a fade.
public static void SetTemporaryColor(
float r,
float g,
float b,
float seconds,
float a = 1f,
float fadeSeconds = 0.25f)

Overrides the colour for a while, then the beam returns to its own colour.

Parameter
rRed, 0 to 1.
gGreen, 0 to 1.
bBlue, 0 to 1.
secondsHow long it holds, at least 0.05.
aAlpha, 0 to 1. The default is 1.
fadeSecondsNot passed to TightBeam; the colour switches without a fade.
public static bool RemoteHasTightBeam(ulong steamId)

Whether this player is running TightBeam and sharing their beam. False means TryGetRemote still answers, but with local defaults rather than their real settings.

Parameter
steamIdThe player’s SteamID64, e.g. from RemoteIds.
public static bool IsRemoteRendered(ulong steamId)

Whether that player’s beam is actually being drawn, as opposed to lit but culled by distance or the beam cap.

Parameter
steamIdThe player’s SteamID64, e.g. from RemoteIds.
public static bool TryGetRemote(ulong steamId, out RemoteBeamState state)

Types: RemoteBeamState

One player’s beam as it is being drawn. False when that player is unknown.

Parameter
steamIdThe player’s SteamID64, e.g. from RemoteIds.
stateThe beam; default when the method returns false.
public static bool TryGetRemotePose(
ulong steamId,
out float px,
out float py,
out float pz,
out float fx,
out float fy,
out float fz)

Where one player’s beam starts and which way it points, for questions like “is that beam on me”. False when the beam is not currently drawn.

Parameter
steamIdThe player’s SteamID64, e.g. from RemoteIds.
pxWorld x of the beam’s start, in metres.
pyWorld y of the beam’s start, in metres.
pzWorld z of the beam’s start, in metres.
fxWorld x of the unit direction the beam points.
fyWorld y of the unit direction the beam points.
fzWorld z of the unit direction the beam points.

Example

Whether another player’s beam points at a spot within 10 degrees:

if (Beam.TryGetRemotePose(id, out var px, out var py, out var pz, out var fx, out var fy, out var fz))
{
var to = (target - new Vector3(px, py, pz)).normalized;
bool onMe = Vector3.Angle(new Vector3(fx, fy, fz), to) < 10f;
}
public static OverrideHandle BeginOverride(string ownerId)

Types: OverrideHandle

Begin a scoped, per-field override for one owner. Dispose() (or scope exit) releases it.

Parameter
ownerIdA name for your override, e.g. “MyMod”. Null becomes ”?”.

Returns The handle to set and clear fields on. Each call opens a new override; the newest one with a value for a field wins.