Skip to main content

DarknessReader

A class in Root.Township, the global namespace.

On the player: the local client checks how dark it is around the player and asks the server to spawn darkness for them. The server spawns them through DarknessSpawnerSettings.

Constructors​

MemberWhat it is
DarknessReader()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private static Logger loggerNLog logger for this class.
private PlayerController playerCharacterThe player this reader belongs to.
private DarknessReaderMethod readingMethodThe darkness reading method in use (compute shader based), local player only.
private MethodSync syncRequestMessage used to send the spawn request.

Methods​

MemberWhat it is
override void Initialize()Sets up the spawn request message and disables the component.
5 private and internal methods
MemberWhat it is
private void IInitializeAsLocalPlayer.InitializeAsLocalPlayer(PlayerController playerController)Local player: creates the compute shader darkness reader and turns it on or off as darkness triggers change.
private void OnDestroy()Unhooks from darkness triggers and turns the reader off.
private void RequestSpawn()Local player: sends a spawn request to the server if the reader is on. Called by the reader.
private void SyncRequest(IPlayer player, Stream stream)Server: on a spawn request, spawns darkness for this player.
private void UpdateEnabled(bool isEnabled)Turns the reader on or off. Hooked to DarknessTrigger.OnChanged.

Used in​

Members of other types that take, return or hold a DarknessReader: