Skip to main content

ActionItem

A class in Root.Township, the global namespace.

Base for an item that belongs to one player and fades in and out with a materialize effect (the friend request token, the gymnasium teleport tablet). The server sets the owner and syncs it.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private float fadeDurationSeconds a fade takes. On fade out the server destroys the entity after this long.
private static Logger loggerClass logger, used for owner updates.
private RendererMaterializer materializerBacking field for Materializer, which runs the materialize and dematerialize effect.
private int ownerBacking field for Owner, the owning player's id.
private RendererGroup renderersToMaterializeBacking field for RenderersToMaterialize.
private MethodSyncStruct<bool> syncEffectMethod sync for fade requests, sent by the server to chunks.
private MethodSync syncOwnerMethod sync for the owner, sent to chunks on setup and to each player that connects.

Properties​

MemberWhat it is
bool IsLocalPlayer { get; private set; }True if the owner is the local player.
RendererMaterializer Materializer { get; }The materializer that plays the fade.
int Owner { get; }User id of the owning player.
RendererGroup RenderersToMaterialize { get; }The renderers the fade applies to.
protected bool HasReceivedOwnerMessage { get; private set; }True once a client has been told the owner.

Events​

MemberWhat it is
event Action<IPlayer> OwnerUpdatedRaised when the owner is set or received.

Methods​

MemberWhat it is
virtual void Fade(bool isFadingIn)Fades in or out. Server: syncs it, and destroys the entity after fading out.
override void Initialize()Sets up the owner and fade messages and the materializer targets.
override void OnConnected(Player player)Server: sends the owner to a joining player.
virtual void SetupOwner(IPlayer player)Sets the owner and syncs it to the chunk.
protected virtual void FinishFadeIn()Hook called when fading in finishes. Empty in the base class.
protected virtual void StartFade(bool isFadingIn)Hook called when a fade starts. Empty in the base class.
2 private and internal methods
MemberWhat it is
private void SyncEffect(IPlayer player, Stream stream, bool isFadingIn)Syncs a fade in or out. Clients that receive it run Fade locally.
private void SyncOwner(IPlayer player, Stream stream)Syncs the owner's player id. A remote client then sets IsLocalPlayer, marks the message received and raises OwnerUpdated.

Used in​

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