using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; public class WeaponVisualHandler : MonoBehaviour { public List visualWeaponSlots = new List(); PhotonView owner; CastingStateController stateController; private void Awake() { owner = GetComponentInParent(); stateController = owner.GetComponentInChildren(); } // Start is called before the first frame update void Start() { if(owner.IsMine) stateController.OnAbilityQueued.AddListener(ToggleCorrectWeapon); } private void ToggleCorrectWeapon(BaseAbility ability) { for (int i = 0; i < visualWeaponSlots.Count; i++) { if(visualWeaponSlots[i].animationTypes.Contains(ability.animationType)) { owner.RPC(nameof(RPC_ToggleCorrectWeapon), RpcTarget.All, i); return; } } } [PunRPC] private void RPC_ToggleCorrectWeapon(int index) { for (int i = 0; i < visualWeaponSlots.Count; i++) { for (int j = 0; j < visualWeaponSlots[i].weapons.Count; j++) { visualWeaponSlots[i].weapons[j].SetActive(i == index); } } } } [System.Serializable] public class WeaponVisualSlot { public List animationTypes = new List(); public List weapons = new List(); }