Skip to main content

ActionItemsManager

A class in Root.Township, Alta.QuickAccessActions.

Network singleton (Instance) that spawns and removes summoned quick access items, one per player per action. Clients ask, the server spawns.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private ActionItemData[] actionItemsThe summonable items (ActionItemData), set in the prefab.
private IActionItemHandlerCollection itemCollectionHandler store: a per player map on the server, the local collection on clients.
private MethodSyncStruct<ActionItemsManager.SpawnedItemInfo> syncSpawnedToClientSync that tells clients about spawned and removed items.
private MethodSyncStruct<int> syncSpawnRequestToServerSync for toggle requests from clients.

Properties​

MemberWhat it is
static ActionItemsManager Instance { get; private set; }The one manager in the scene.

Methods​

MemberWhat it is
override void Initialize()Makes a per player handler map on the server or a single collection on a client, and sets up the two syncs.
bool ItemIsActiveForLocalPlayer(SummonActionItemQuickAccess action)True if the local player has that summon action's item out.
override void OnDisconnected(Player player)Removes the player's handlers.
void UpdateActionItemStatusForPlayer(SummonActionItemQuickAccess action, IPlayer player)Toggles a summon action's item: a client sends the request, the server toggles directly.
12 private and internal methods
MemberWhat it is
private void Awake()Sets Instance, or destroys this copy if one already exists.
private void DestroyActionItem(int index, IPlayer player)Destroy callback for handlers. Server destroys and tells clients; a client disposes its handler and sends a toggle request.
private void DestroyPlayersActionItem(IPlayer player, int itemIndex)Server: disposes the player's handler for that item and tells clients it went.
private void FadeActionItemOnRemotePlayer(ActionItemsManager.SpawnedItemInfo arguments)Client: waits for the item to spawn and fades it in or out (skipped when headless).
private static ValueTuple<Vector3, Quaternion> GetTargetPositionAndRotation(IPlayer player, ActionItemData data)Spot in front of the player's head at the item's distance, facing the head's flat forward.
private static void PlayItemEffects(ActionItemsManager.SpawnedItemInfo arguments, ActionItemData actionItemData)Plays the spawn or disappear effects at the item's position, but only when headless, which looks inverted.
private void ProcessSpawnDestroyArgumentsForLocalPlayer(ActionItemsManager.SpawnedItemInfo arguments, IPlayer owner)Client: hooks the spawned item into the local handler, or disposes it on removal.
private void SpawnActionItemForPlayer(IPlayer player, int dataIndex)Server: spawns the item unsaved in front of the player, sets its owner, puts it in the player's chunk and tells clients.
private void SyncSpawnedItemInfoToClient(IPlayer player, Stream stream, ActionItemsManager.SpawnedItemInfo arguments)Message handler (EffectRequest) telling clients an item spawned or went; sets up or fades it and plays effects.
private void SyncSpawnRequestToServer(IPlayer player, Stream stream, int index)Message handler for a client's toggle request (SyncA); the server toggles that item.
private bool TryGetActionIndex(SummonActionItemQuickAccess summonAction, out int index)Finds the index of a summon action in actionItems; logs an error if missing.
private void UpdateActionItemStatusForPlayerOnServer(IPlayer player, int index)Server: destroys the player's item if spawned, otherwise spawns it.