public static void SetCooldown(IActionGUI iActionGUI, float cooldown, GameObject recipient) { SetActionUIMessage.SetAction(recipient, iActionGUI, cooldown); }
/// <summary> /// Set the action button visibility for the given player, with network sync /// </summary> public static void Toggle(IActionGUI iActionGUI, bool show, GameObject recipient) { SetActionUIMessage.SetAction(recipient, iActionGUI, show); }
private static SetActionUIMessage _Send(GameObject recipient, IActionGUI action, UpdateType ProposedAction, bool show = false, float cooldown = 0, int location = 0) { //SO action singleton ID if (action is UIActionScriptableObject actionFromSO) { SetActionUIMessage msg = new SetActionUIMessage { actionListID = UIActionSOSingleton.ActionsTOID[actionFromSO], showAlert = show, cooldown = cooldown, SpriteLocation = location, ProposedAction = ProposedAction, ComponentType = actionFromSO.GetType() }; msg.SendTo(recipient); return(msg); } //SpellList singleton index else if (action is Spell spellAction) { SetActionUIMessage msg = new SetActionUIMessage { spellListIndex = spellAction.SpellData.Index, showAlert = show, cooldown = cooldown, SpriteLocation = location, ProposedAction = ProposedAction, ComponentType = spellAction.GetType() }; msg.SendTo(recipient); return(msg); } else { //Action pre-placed on a networked object var netObject = (action as Component).GetComponent <NetworkIdentity>(); var type = action.GetType(); var foundActions = netObject.GetComponentsInChildren(type); var componentLocation = 0; bool isFound = false; foreach (var foundAction in foundActions) { if ((foundAction as IActionGUI) == action) { isFound = true; break; } componentLocation++; } if (isFound) { SetActionUIMessage msg = new SetActionUIMessage { NetObject = netObject.netId, ComponentLocation = componentLocation, ComponentType = type, cooldown = cooldown, showAlert = show, SpriteLocation = location, ProposedAction = ProposedAction }; msg.SendTo(recipient); return(msg); } else { Logger.LogError("Failed to find IActionGUI on NetworkIdentity"); } } return(null); }