Beam
public static class BeamNamespace 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 blinkvar ov = Beam.BeginOverride("MyMod"); // scoped, per-field overrideov.SetIntensity(1f).SetSpotAngle(28f); // dim + narrow while in a zoneov.Dispose(); // release -> beam returns to the player's own settingsIntensity 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);Properties
Section titled “Properties”Available
Section titled “Available”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.
AbiVersion
Section titled “AbiVersion”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.
Intensity
Section titled “Intensity”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.
SpotAngle
Section titled “SpotAngle”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.
IsMultiplayer
Section titled “IsMultiplayer”public static bool IsMultiplayer { get; }True while in a session with at least one other player.
LocalSteamId
Section titled “LocalSteamId”public static ulong LocalSteamId { get; }The local player’s SteamID64, or 0 when it is not known yet.
RemoteIds
Section titled “RemoteIds”public static ulong[] RemoteIds { get; }Every other player whose beam is being tracked. Never null; empty when alone or absent.
Events
Section titled “Events”OnToggled
Section titled “OnToggled”public static event Action<bool> OnToggledFires whenever the flashlight actually transitions on/off (player key or any mod’s SetOn/Toggle).
OnRemoteToggled
Section titled “OnRemoteToggled”public static event Action<ulong, bool> OnRemoteToggledFires when ANOTHER player’s beam goes on or off: (steamId, isOn).
Methods
Section titled “Methods”GetColor
Section titled “GetColor”public static void GetColor( out float r, out float g, out float b, out float a)The colour the beam shows this frame.
| Parameter | |
|---|---|
r | Red, 0 to 1. |
g | Green, 0 to 1. |
b | Blue, 0 to 1. |
a | Alpha, 0 to 1. All four are 0 when TightBeam is absent. |
TurnOn
Section titled “TurnOn”public static void TurnOn()Turns the flashlight on, like SetOn(true).
TurnOff
Section titled “TurnOff”public static void TurnOff()Turns the flashlight off, like SetOn(false).
Toggle
Section titled “Toggle”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 | |
|---|---|
on | true turns it on, false off. |
SetIntensity
Section titled “SetIntensity”public static void SetIntensity(float value)Sets the base intensity the beam rests at.
| Parameter | |
|---|---|
value | The Unity light intensity, e.g. 7. It is clamped to MinIntensity (1) and MaxIntensity (20) from the preferences. |
SetRange
Section titled “SetRange”public static void SetRange(float meters)Pins the base range. The pin holds until the player changes the focus with the scroll wheel.
| Parameter | |
|---|---|
meters | The range in metres, e.g. 20. It is clamped to 2 to 60. |
SetSpotAngle
Section titled “SetSpotAngle”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 | |
|---|---|
degrees | The full cone angle in degrees, e.g. 30. It is clamped to 8 to 90. |
SetColor
Section titled “SetColor”public static void SetColor(float r, float g, float b, float a = 1f)Sets the base beam colour.
| Parameter | |
|---|---|
r | Red, 0 to 1. |
g | Green, 0 to 1. |
b | Blue, 0 to 1. |
a | Alpha, 0 to 1. The default is 1. |
SetColorHex
Section titled “SetColorHex”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 | |
|---|---|
times | How many blinks, from 1 to 20. Higher counts blink 20 times; 0 or less does nothing. |
intervalSeconds | Seconds for each dark and each lit half, at least 0.02. The default is 0.12. |
Flicker
Section titled “Flicker”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 | |
|---|---|
strength01 | 0 to 1. The intensity drops by up to this share: 0.8 dims it down to 20 percent at the lowest. |
durationSeconds | How long it runs, at least 0.05 seconds. |
frequencyHz | How fast the noise changes, at least 0.1. The default is 14. |
StopFlicker
Section titled “StopFlicker”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 | |
|---|---|
amplitude01 | 0 to 1. The intensity swings by this share both ways: 0.3 runs from 70 to 130 percent. |
periodSeconds | Seconds for one full swing, at least 0.1. |
durationSeconds | How long it runs, at least 0.05 seconds. float.PositiveInfinity runs until StopPulse. |
StopPulse
Section titled “StopPulse”public static void StopPulse()SetTemporaryIntensity
Section titled “SetTemporaryIntensity”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 | |
|---|---|
value | The Unity light intensity. It is not held to MinIntensity and MaxIntensity; below 0 shows as 0. |
seconds | How long it holds, at least 0.05. |
fadeSeconds | Not passed to TightBeam; the value switches without a fade. |
SetTemporaryColor
Section titled “SetTemporaryColor”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 | |
|---|---|
r | Red, 0 to 1. |
g | Green, 0 to 1. |
b | Blue, 0 to 1. |
seconds | How long it holds, at least 0.05. |
a | Alpha, 0 to 1. The default is 1. |
fadeSeconds | Not passed to TightBeam; the colour switches without a fade. |
RemoteHasTightBeam
Section titled “RemoteHasTightBeam”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 | |
|---|---|
steamId | The player’s SteamID64, e.g. from RemoteIds. |
IsRemoteRendered
Section titled “IsRemoteRendered”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 | |
|---|---|
steamId | The player’s SteamID64, e.g. from RemoteIds. |
TryGetRemote
Section titled “TryGetRemote”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 | |
|---|---|
steamId | The player’s SteamID64, e.g. from RemoteIds. |
state | The beam; default when the method returns false. |
TryGetRemotePose
Section titled “TryGetRemotePose”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 | |
|---|---|
steamId | The player’s SteamID64, e.g. from RemoteIds. |
px | World x of the beam’s start, in metres. |
py | World y of the beam’s start, in metres. |
pz | World z of the beam’s start, in metres. |
fx | World x of the unit direction the beam points. |
fy | World y of the unit direction the beam points. |
fz | World 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;}BeginOverride
Section titled “BeginOverride”public static OverrideHandle BeginOverride(string ownerId)Types: OverrideHandle
Begin a scoped, per-field override for one owner. Dispose() (or scope exit) releases it.
| Parameter | |
|---|---|
ownerId | A 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.