From 7dce6f29cb6f99f05ec729b25450497a97d8709c Mon Sep 17 00:00:00 2001 From: Fernando Cortez Date: Thu, 16 Jan 2025 13:17:59 -0500 Subject: [PATCH] whitespace fixes --- .../Gameplay/Action/Input/AoeActionInput.cs | 3 +- .../DebugCheats/DebugCheatsManager.cs | 10 +++- Assets/Scripts/Gameplay/UI/HeroActionBar.cs | 10 +++- .../Scripts/Gameplay/UI/UITooltipDetector.cs | 2 +- .../Gameplay/UserInput/ClientInputSender.cs | 57 ++++++++++--------- .../Utils/NetworkSimulatorUIMediator.cs | 17 ++++-- .../Net/RNSM/NetStatsMonitorCustomization.cs | 4 +- 7 files changed, 60 insertions(+), 43 deletions(-) diff --git a/Assets/Scripts/Gameplay/Action/Input/AoeActionInput.cs b/Assets/Scripts/Gameplay/Action/Input/AoeActionInput.cs index f441f6c50..9e6b6b0e7 100644 --- a/Assets/Scripts/Gameplay/Action/Input/AoeActionInput.cs +++ b/Assets/Scripts/Gameplay/Action/Input/AoeActionInput.cs @@ -19,7 +19,7 @@ public class AoeActionInput : BaseActionInput [SerializeField] GameObject m_OutOfRangeVisualization; - + [SerializeField] InputActionReference m_PointAction; @@ -82,6 +82,7 @@ void Update() }; m_SendInput(data); } + Destroy(gameObject); return; } diff --git a/Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs b/Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs index 7f4482bd0..3cdda5104 100644 --- a/Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs +++ b/Assets/Scripts/Gameplay/DebugCheats/DebugCheatsManager.cs @@ -29,10 +29,10 @@ public class DebugCheatsManager : NetworkBehaviour [SerializeField] [Tooltip("Boss to spawn. Make sure this is included in the NetworkManager's list of prefabs!")] NetworkObject m_BossPrefab; - + [SerializeField] InputActionReference m_ToggleCheatsAction; - + SwitchedDoor m_SwitchedDoor; SwitchedDoor SwitchedDoor @@ -43,6 +43,7 @@ SwitchedDoor SwitchedDoor { m_SwitchedDoor = FindAnyObjectByType(); } + return m_SwitchedDoor; } } @@ -160,7 +161,6 @@ void ServerKillTargetRpc(RpcParams serverRpcParams = default) UnityEngine.Debug.Log($"Target {targetId} has no IDamageable component or cannot be damaged."); } } - } } @@ -177,6 +177,7 @@ void ServerKillAllEnemiesRpc(RpcParams serverRpcParams = default) } } } + PublishCheatUsedMessage(serverRpcParams.Receive.SenderClientId, "KillAllEnemies"); } @@ -211,6 +212,7 @@ void ServerHealPlayerRpc(RpcParams serverRpcParams = default) damageable.ReceiveHP(null, baseHp); } } + PublishCheatUsedMessage(serverRpcParams.Receive.SenderClientId, "HealPlayer"); } } @@ -227,6 +229,7 @@ void ServerToggleSuperSpeedRpc(RpcParams serverRpcParams = default) break; } } + PublishCheatUsedMessage(clientId, "ToggleSuperSpeed"); } @@ -242,6 +245,7 @@ void ServerToggleTeleportModeRpc(RpcParams serverRpcParams = default) break; } } + PublishCheatUsedMessage(serverRpcParams.Receive.SenderClientId, "ToggleTeleportMode"); } diff --git a/Assets/Scripts/Gameplay/UI/HeroActionBar.cs b/Assets/Scripts/Gameplay/UI/HeroActionBar.cs index 1fc2edfcb..850703ef6 100644 --- a/Assets/Scripts/Gameplay/UI/HeroActionBar.cs +++ b/Assets/Scripts/Gameplay/UI/HeroActionBar.cs @@ -133,6 +133,7 @@ void RegisterInputSender(ClientPlayerAvatar clientPlayerAvatar) { GameDataSource.Instance.TryGetActionPrototypeByID(m_InputSender.actionState1.actionID, out action1); } + UpdateActionButton(m_ButtonInfo[ActionButtonType.BasicAction], action1); Action action2 = null; @@ -140,6 +141,7 @@ void RegisterInputSender(ClientPlayerAvatar clientPlayerAvatar) { GameDataSource.Instance.TryGetActionPrototypeByID(m_InputSender.actionState2.actionID, out action2); } + UpdateActionButton(m_ButtonInfo[ActionButtonType.Special1], action2); Action action3 = null; @@ -147,6 +149,7 @@ void RegisterInputSender(ClientPlayerAvatar clientPlayerAvatar) { GameDataSource.Instance.TryGetActionPrototypeByID(m_InputSender.actionState3.actionID, out action3); } + UpdateActionButton(m_ButtonInfo[ActionButtonType.Special2], action3); } @@ -165,6 +168,7 @@ void DeregisterInputSender() { m_InputSender.action1ModifiedCallback -= Action1ModifiedCallback; } + m_InputSender = null; } @@ -177,7 +181,7 @@ void Awake() [ActionButtonType.Special2] = new ActionButtonInfo(ActionButtonType.Special2, m_SpecialAction2Button, this), [ActionButtonType.EmoteBar] = new ActionButtonInfo(ActionButtonType.EmoteBar, m_EmoteBarButton, this), }; - + m_ToggleEmoteBarAction.action.performed += OnToggleEmoteBarPerformed; ClientPlayerAvatar.LocalClientSpawned += RegisterInputSender; @@ -203,13 +207,13 @@ void OnDisable() void OnDestroy() { DeregisterInputSender(); - + m_ToggleEmoteBarAction.action.performed -= OnToggleEmoteBarPerformed; ClientPlayerAvatar.LocalClientSpawned -= RegisterInputSender; ClientPlayerAvatar.LocalClientDespawned -= DeregisterInputSender; } - + void OnToggleEmoteBarPerformed(InputAction.CallbackContext obj) { if (obj.performed) diff --git a/Assets/Scripts/Gameplay/UI/UITooltipDetector.cs b/Assets/Scripts/Gameplay/UI/UITooltipDetector.cs index 7ef98d7ff..03f281127 100644 --- a/Assets/Scripts/Gameplay/UI/UITooltipDetector.cs +++ b/Assets/Scripts/Gameplay/UI/UITooltipDetector.cs @@ -18,7 +18,7 @@ public class UITooltipDetector : MonoBehaviour, IPointerEnterHandler, IPointerEx { [SerializeField] InputActionReference m_PointAction; - + [SerializeField] [Tooltip("The actual Tooltip that should be triggered")] UITooltipPopup m_TooltipPopup; diff --git a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs index 7ddee6f76..dcd6a1411 100644 --- a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs +++ b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs @@ -24,7 +24,7 @@ public class ClientInputSender : NetworkBehaviour //upstream network conservation. This matters when holding down your mouse button to move. const float k_MoveSendRateSeconds = 0.04f; //25 fps. - const float k_TargetMoveTimeout = 0.45f; //prevent moves for this long after targeting someone (helps prevent walking to the guy you clicked). + const float k_TargetMoveTimeout = 0.45f; //prevent moves for this long after targeting someone (helps prevent walking to the guy you clicked). float m_LastSentMove; @@ -75,12 +75,12 @@ public class ClientInputSender : NetworkBehaviour /// public enum SkillTriggerStyle { - None, //no skill was triggered. - MouseClick, //skill was triggered via mouse-click implying you should do a raycast from the mouse position to find a target. - Keyboard, //skill was triggered via a Keyboard press, implying target should be taken from the active target. + None, //no skill was triggered. + MouseClick, //skill was triggered via mouse-click implying you should do a raycast from the mouse position to find a target. + Keyboard, //skill was triggered via a Keyboard press, implying target should be taken from the active target. KeyboardRelease, //represents a released key. - UI, //skill was triggered from the UI, and similar to Keyboard, target should be inferred from the active target. - UIRelease, //represents letting go of the mouse-button on a UI button + UI, //skill was triggered from the UI, and similar to Keyboard, target should be inferred from the active target. + UIRelease, //represents letting go of the mouse-button on a UI button } bool IsReleaseStyle(SkillTriggerStyle style) @@ -150,6 +150,7 @@ public override void OnNetworkSpawn() if (!IsClient || !IsOwner) { enabled = false; + // dont need to do anything else if not the owner return; } @@ -162,17 +163,19 @@ public override void OnNetworkSpawn() { actionState1 = new ActionState() { actionID = action1.ActionID, selectable = true }; } + if (CharacterClass.Skill2 && GameDataSource.Instance.TryGetActionPrototypeByID(CharacterClass.Skill2.ActionID, out var action2)) { actionState2 = new ActionState() { actionID = action2.ActionID, selectable = true }; } + if (CharacterClass.Skill3 && GameDataSource.Instance.TryGetActionPrototypeByID(CharacterClass.Skill3.ActionID, out var action3)) { actionState3 = new ActionState() { actionID = action3.ActionID, selectable = true }; } - + m_Action1.action.started += OnAction1Started; m_Action1.action.canceled += OnAction1Canceled; m_Action2.action.started += OnAction2Started; @@ -202,7 +205,7 @@ public override void OnNetworkDespawn() { m_TargetServerCharacter.NetLifeState.LifeState.OnValueChanged -= OnTargetLifeStateChanged; } - + m_Action1.action.started -= OnAction1Started; m_Action1.action.canceled -= OnAction1Canceled; m_Action2.action.started -= OnAction2Started; @@ -468,7 +471,7 @@ void PopulateSkillRequest(Vector3 hitPoint, ActionID actionID, ref ActionRequest //there is a bug where the direction is flipped if the hitPos and current position are almost the same, //so we use the character's direction instead. float directionLength = offset.magnitude; - Vector3 direction = 1.0f/*epsilon*/ <= directionLength ? (offset / directionLength) : m_PhysicsWrapper.Transform.forward; + Vector3 direction = 1.0f /*epsilon*/ <= directionLength ? (offset / directionLength) : m_PhysicsWrapper.Transform.forward; switch (actionConfig.Logic) { @@ -518,52 +521,52 @@ public void RequestAction(ActionID actionID, SkillTriggerStyle triggerStyle, ulo m_ActionRequestCount++; } } - + void OnAction1Started(InputAction.CallbackContext obj) { RequestAction(actionState1.actionID, SkillTriggerStyle.Keyboard); } - + void OnAction1Canceled(InputAction.CallbackContext obj) { RequestAction(actionState1.actionID, SkillTriggerStyle.KeyboardRelease); } - + void OnAction2Started(InputAction.CallbackContext obj) { RequestAction(actionState2.actionID, SkillTriggerStyle.Keyboard); } - + void OnAction2Canceled(InputAction.CallbackContext obj) { RequestAction(actionState2.actionID, SkillTriggerStyle.KeyboardRelease); } - + void OnAction3Started(InputAction.CallbackContext obj) { RequestAction(actionState3.actionID, SkillTriggerStyle.Keyboard); } - + void OnAction3Canceled(InputAction.CallbackContext obj) { RequestAction(actionState3.actionID, SkillTriggerStyle.KeyboardRelease); } - + void OnAction5Performed(InputAction.CallbackContext obj) { RequestAction(GameDataSource.Instance.Emote1ActionPrototype.ActionID, SkillTriggerStyle.Keyboard); } - + void OnAction6Performed(InputAction.CallbackContext obj) { RequestAction(GameDataSource.Instance.Emote2ActionPrototype.ActionID, SkillTriggerStyle.Keyboard); } - + void OnAction7Performed(InputAction.CallbackContext obj) { RequestAction(GameDataSource.Instance.Emote3ActionPrototype.ActionID, SkillTriggerStyle.Keyboard); } - + void OnAction8Performed(InputAction.CallbackContext obj) { RequestAction(GameDataSource.Instance.Emote4ActionPrototype.ActionID, SkillTriggerStyle.Keyboard); @@ -580,7 +583,7 @@ void Update() { RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick); } - + if (m_TargetAction.action.WasPressedThisFrame()) { RequestAction(GameDataSource.Instance.GeneralTargetActionPrototype.ActionID, SkillTriggerStyle.MouseClick); @@ -609,19 +612,19 @@ void UpdateAction1() actionState1.actionID = GameDataSource.Instance.DropActionPrototype.ActionID; } else if ((m_ServerCharacter.TargetId.Value != 0 - && selection != null - && selection.TryGetComponent(out PickUpState pickUpState)) - ) + && selection != null + && selection.TryGetComponent(out PickUpState pickUpState)) + ) { // special case: targeting a pickup-able item or holding a pickup object actionState1.actionID = GameDataSource.Instance.PickUpActionPrototype.ActionID; } else if (m_ServerCharacter.TargetId.Value != 0 - && selection != null - && selection.NetworkObjectId != m_ServerCharacter.NetworkObjectId - && selection.TryGetComponent(out ServerCharacter charState) - && !charState.IsNpc) + && selection != null + && selection.NetworkObjectId != m_ServerCharacter.NetworkObjectId + && selection.TryGetComponent(out ServerCharacter charState) + && !charState.IsNpc) { // special case: when we have a player selected, we change the meaning of the basic action // we have another player selected! In that case we want to reflect that our basic Action is a Revive, not an attack! diff --git a/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs b/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs index 6dacdd96e..a03338580 100644 --- a/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs +++ b/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs @@ -63,6 +63,7 @@ void Awake() #if UNITY_EDITOR || DEVELOPMENT_BUILD InitializeUI(); #endif + // Hide UI until ready Hide(); } @@ -80,10 +81,10 @@ void Start() { NetworkManager.Singleton.OnClientStarted += OnNetworkManagerStarted; NetworkManager.Singleton.OnServerStarted += OnNetworkManagerStarted; - + m_ToggleNetworkSimulatorAction.action.performed += OnToggleNetworkSimulatorActionPerformed; } - + void OnDestroy() { if (NetworkManager.Singleton is not null) @@ -91,7 +92,7 @@ void OnDestroy() NetworkManager.Singleton.OnClientStarted -= OnNetworkManagerStarted; NetworkManager.Singleton.OnServerStarted -= OnNetworkManagerStarted; } - + m_ToggleNetworkSimulatorAction.action.performed -= OnToggleNetworkSimulatorActionPerformed; } @@ -125,6 +126,7 @@ void OnScenarioChanged(int optionIndex) { connectionsCyleScenario.Configurations.Add(configuration); } + m_PresetsDropdown.captionText.color = m_PresetsDropdown.colors.disabledColor; m_PresetsDropdown.interactable = false; scenario = connectionsCyleScenario; @@ -136,6 +138,7 @@ void OnScenarioChanged(int optionIndex) { randomConnectionsSwapScenario.Configurations.Add(configuration); } + m_PresetsDropdown.captionText.color = m_PresetsDropdown.colors.disabledColor; m_PresetsDropdown.interactable = false; scenario = randomConnectionsSwapScenario; @@ -146,6 +149,7 @@ void OnScenarioChanged(int optionIndex) m_PresetsDropdown.interactable = true; break; } + m_NetworkSimulator.Scenario = scenario; if (m_NetworkSimulator.Scenario != null) { @@ -180,12 +184,14 @@ void InitializeUI() { // Initialize connection presets dropdown var optionData = new List(); + // Adding all available presets foreach (var networkSimulatorPreset in NetworkSimulatorPresets.Values) { m_SimulatorPresets[networkSimulatorPreset.Name] = networkSimulatorPreset; optionData.Add(new TMP_Dropdown.OptionData(networkSimulatorPreset.Name)); } + m_PresetsDropdown.AddOptions(optionData); m_PresetsDropdown.onValueChanged.AddListener(OnPresetChanged); @@ -220,7 +226,6 @@ void Update() } } } - } else { @@ -230,12 +235,12 @@ void Update() } } } - + void OnToggleNetworkSimulatorActionPerformed(InputAction.CallbackContext obj) { ToggleVisibility(); } - + public void SimulateDisconnect() { m_NetworkSimulator.Disconnect(); diff --git a/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/NetStatsMonitorCustomization.cs b/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/NetStatsMonitorCustomization.cs index 6312e6f5b..28e316032 100644 --- a/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/NetStatsMonitorCustomization.cs +++ b/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/NetStatsMonitorCustomization.cs @@ -9,14 +9,14 @@ public class NetStatsMonitorCustomization : MonoBehaviour { [SerializeField] RuntimeNetStatsMonitor m_Monitor; - + [SerializeField] InputActionReference m_ToggleNetworkStatsAction; void Start() { m_Monitor.Visible = false; - + m_ToggleNetworkStatsAction.action.performed += OnToggleNetworkStatsActionperformed; }