/// <summary> /// Set the Active hand of the Player to be the AttachedContainer passed in parameter. /// Do nothing if the parameter is the already active parameter. /// </summary> /// <param name="selectedContainer">This AttachedContainer should only be a hand.</param> public void SetActiveHand(AttachedContainer selectedContainer) { if (selectedContainer == SelectedHand) { return; } else { SelectedHandIndex = HandContainers.ToList().IndexOf(selectedContainer); if (SelectedHandIndex != -1) { HandChanged?.Invoke(SelectedHandIndex); CmdSetActiveHand(SelectedHandIndex); } else { Debug.LogError("selectedContainer is not in HandContainers."); return; } } }
public override void Update() { base.Update(); if (!isLocalPlayer) { return; } // Hand-related buttons if (Input.GetButtonDown("Swap Active") && HandContainers.Length > 0) { SelectedHandIndex = (SelectedHandIndex + 1) % HandContainers.Length; HandChanged?.Invoke(SelectedHandIndex); CmdSetActiveHand(SelectedHandIndex); } if (Input.GetButtonDown("Drop Item")) { CmdDropHeldItem(); } }
/// <summary> /// Method for HandChanged event triggering. /// </summary> /// <param name="args">HandChangedEventArgs object.</param> protected virtual void OnHandChanged(HandChangedEventArgs args) { // Uses null-conditional operator. HandChanged?.Invoke(this, args); }