From b595286b51e7e9fc62cd939170e5e167ebef0180 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:38:11 +0300 Subject: [PATCH 01/52] Battle: Added command for give up #1467 --- .../Battle/Scripts/Game/Commands.meta | 8 ++++++++ .../Scripts/Game/Commands/CommandGiveUp.cs | 16 ++++++++++++++++ .../Scripts/Game/Commands/CommandGiveUp.cs.meta | 11 +++++++++++ .../QuantumUser/Simulation/CommandSetup.User.cs | 17 ++++++++++++----- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta new file mode 100644 index 0000000000..06557d59e1 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4014e72160e714b4ba8b85880650d6ba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs new file mode 100644 index 0000000000..0b439cf418 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs @@ -0,0 +1,16 @@ +// Quantum usings +using Quantum; +using Photon.Deterministic; + +namespace Battle.QSimulation.Player +{ + public class CommandGiveUp : DeterministicCommand + { + public override void Serialize(BitStream stream) { } + + public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + { + BattlePlayerQSystem.HandleGiveUp(f, playerHandle); + } + } +} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta new file mode 100644 index 0000000000..de36029d29 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 01220694059157d46a165f1b29c1993e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index cdd0c1f055..948ea805a3 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -1,14 +1,21 @@ -namespace Quantum -{ - using System.Collections.Generic; - using Photon.Deterministic; +// System usings +using System.Collections.Generic; +using Battle.QSimulation.Player; + + +// Quantum usings +using Photon.Deterministic; +namespace Quantum +{ public static partial class DeterministicCommandSetup { static partial void AddCommandFactoriesUser(ICollection factories, RuntimeConfig gameConfig, SimulationConfig simulationConfig) { // Add or remove commands to the collection. // factories.Add(new NavMeshAgentTestSystem.RunTest()); + + factories.Add(new CommandGiveUp()); } } -} \ No newline at end of file +} From 70870d402a24d39588a649fe195adf53df0e4459 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:40:39 +0300 Subject: [PATCH 02/52] Battle: Updated give up to use command instead of input #1467 --- .../Scripts/Player/BattlePlayerQSystem.cs | 23 +++++++++++-------- .../Scripts/Game/BattleGameViewController.cs | 5 +++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 41ae84293e..4d009e39f9 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -174,9 +174,14 @@ public override void Update(Frame f) playerTransform = f.Unsafe.GetPointer(playerEntity); } + if (f.GetPlayerCommand(playerData->PlayerRef) is CommandGiveUp giveUpCommand) + { + giveUpCommand.Execute(f, playerHandle); + continue; + } + input = GetInput(f, playerHandle, playerData, &stackInputStorage); - if (HandleGiveUpInput(f, input, playerHandle)) continue; if (HandleCharacterSwapping(f, input, playerHandle)) continue; if (HandleOutOfPlay(f, playerHandle)) continue; @@ -257,6 +262,7 @@ private enum SoundEffectTypeCharacter input = stackInputStorage; *stackInputStorage = new Input { + IsValid = true, MovementInput = BattleMovementInputType.None, MovementDirectionIsNormalized = false, MovementPositionTarget = new BattleGridPosition { Col = 0, Row = 0 }, @@ -265,7 +271,6 @@ private enum SoundEffectTypeCharacter RotationInput = false, RotationValue = FP._0, PlayerCharacterNumber = -1, - GiveUpInput = false, AbilityActivate = false }; } @@ -281,7 +286,7 @@ private enum SoundEffectTypeCharacter /// /// Current simulation frame. /// Handle of the player. - private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + private static void HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerSlot slot = playerHandle.Slot; BattleTeamNumber team = BattlePlayerManager.PlayerHandle.GetTeamNumber(playerHandle.Slot); @@ -289,7 +294,7 @@ private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle if (!playerHandle.PlayerGiveUpState) { f.Events.BattleGiveUpStateChange(team, slot, BattleGiveUpStateUpdate.GiveUpVoteCancel); - return false; + return; } BattlePlayerManager.PlayerHandle teammateHandle = BattlePlayerManager.PlayerHandle.GetTeammateHandle(f, slot); @@ -303,7 +308,7 @@ private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle { f.Events.BattleGiveUpStateChange(team, slot, BattleGiveUpStateUpdate.Abandoned); } - if (!teammateHandle.PlayerGiveUpState) return false; + if (!teammateHandle.PlayerGiveUpState) return; } else { @@ -319,7 +324,7 @@ private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle }; BattleGameControlQSystem.OnGameOver(f, winningTeam); - return true; + return; } /// @@ -363,15 +368,13 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i /// Handle of the player. /// /// True if the give up input was processed. - private bool HandleGiveUpInput(Frame f, Input* input, BattlePlayerManager.PlayerHandle playerHandle) + public static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { - if (!input->GiveUpInput) return false; - playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; s_debugLogger.LogFormat(f, "({0}) Give up input received, new state: {1}", playerHandle.Slot, playerHandle.PlayerGiveUpState); - return HandleGiveUpLogic(f, playerHandle); + HandleGiveUpLogic(f, playerHandle); } /// diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index bc2138f635..7b3ded7ae4 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -129,7 +129,10 @@ public static void AssignProjectileReference(GameObject projectileReference) public void UiInputOnLocalPlayerGiveUp() { _debugLogger.Log("Give up button pressed"); - _playerInput.OnGiveUp(); + PlayerRef playerRef; + playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; + QuantumRunner.Default.Game.SendCommand(playerRef, new CommandGiveUp()); + _debugLogger.Log("Give up button pressed, command sent"); } /// From b7ea9b552812f0797dd74fab2fbfdc319d3cd1d1 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:41:10 +0300 Subject: [PATCH 03/52] Battle: Removed GiveUpInput #1467 --- .../Battle/Qtn/Player/BattlePlayerInput.qtn | 1 - .../Simulation/Battle/Scripts/BattleDebugUtils.cs | 10 +--------- .../Scripts/Player/BattlePlayerBotController.cs | 5 ++--- .../Battle/Scripts/Player/BattlePlayerInput.cs | 15 +-------------- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn index 2aef1c85a6..d0831ef262 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn @@ -11,7 +11,6 @@ input FP RotationValue; bool AbilityActivate; int PlayerCharacterNumber; - bool GiveUpInput; } enum BattleMovementInputType diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs index b08b042e22..43ed2a2c36 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs @@ -79,12 +79,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) inputDebugSummary += "Character Swap"; inputNotEmpty = true; } - if (input->GiveUpInput != false) - { - if (inputDebugSummary != "") inputDebugSummary += ", "; - inputDebugSummary += "Give Up"; - inputNotEmpty = true; - } if (inputNotEmpty) { @@ -101,7 +95,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) " RotationValue: {6},\n" + " AbilityActivate: {7},\n" + " PlayerCharacterNumber: {8},\n" + - " GiveUpInput: {9}\n" + "}}", input->MovementInput, input->MovementDirectionIsNormalized, @@ -111,8 +104,7 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) input->RotationInput, input->RotationValue, input->AbilityActivate, - input->PlayerCharacterNumber, - input->GiveUpInput + input->PlayerCharacterNumber ) ); } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs index 81eeec2120..a62655ee56 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs @@ -48,7 +48,7 @@ public static BattleCharacterBase[] GetBotCharacters(Frame f) BattleCharacterBase[] botCharacters = new BattleCharacterBase[Constants.BATTLE_PLAYER_CHARACTER_COUNT]; for (int i = 0; i < botCharacters.Length; i++) - { + { int selectedCharacter; do { @@ -56,7 +56,7 @@ public static BattleCharacterBase[] GetBotCharacters(Frame f) } while (selectedBotCharacters.Contains(selectedCharacter)); selectedBotCharacters[i] = selectedCharacter; - botCharacters[i] = playerBotSpec.BotCharacterSelection[selectedCharacter]; + botCharacters[i] = playerBotSpec.BotCharacterSelection[selectedCharacter]; } return botCharacters; } @@ -174,7 +174,6 @@ public static void GetBotInput(Frame f, bool isInPlay, BattlePlayerDataQComponen RotationInput = false, RotationValue = FP._0, PlayerCharacterNumber = -1, - GiveUpInput = false, AbilityActivate = false }; } diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 2a45708b9e..d9b7d87b8f 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -76,14 +76,6 @@ public void OnCharacterSelected(int characterNumber) _characterNumber = characterNumber; } - /// - /// Called when the player presses the give up button. - /// - public void OnGiveUp() - { - _onGiveUp = true; - } - /// @} /// @@ -156,9 +148,6 @@ public RotationInputInfo(bool rotationInput, FP rotationValue) /// Saved character number from character swapping input. private int _characterNumber = -1; - /// Give up button state - private bool _onGiveUp = false; - /// Bool to block screen input private bool _blockScreenInput = false; @@ -263,7 +252,7 @@ private void PollInput(CallbackPollInput callback) RotationInputInfo rotationInputInfo = new(false, FP._0); // check button input - if (_characterNumber > -1 || _onGiveUp) _blockScreenInput = true; + if (_characterNumber > -1) _blockScreenInput = true; Vector2 clickPosition = Vector2.zero; Vector3 unityPosition = Vector3.zero; @@ -300,7 +289,6 @@ private void PollInput(CallbackPollInput callback) RotationValue = rotationInputInfo.RotationValue, AbilityActivate = Time.time - _lastTapTime < DoubleTapInterval && mouseClick && Vector3.Distance(_lastTapPosition, unityPosition) < DoubleTapDistance, PlayerCharacterNumber = _characterNumber, - GiveUpInput = _onGiveUp }; DeterministicInputFlags inputFlags = DeterministicInputFlags.Repeatable; @@ -338,7 +326,6 @@ private void PollInput(CallbackPollInput callback) _inputDebugNumber++; // reset - _onGiveUp = false; _characterNumber = -1; } From 6310f58710e6722e2b5d47a5a1a3ce358b6cd287 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:41:26 +0300 Subject: [PATCH 04/52] Battle: Ran quantum codegen #1467 --- .../Simulation/Generated/Quantum.CodeGen.Core.cs | 13 ++++--------- .../Generated/Quantum.CodeGen.Prototypes.cs | 2 -- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs index 214598d333..e0c924ad90 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs @@ -979,21 +979,21 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { public unsafe partial struct Input { public const Int32 SIZE = 80; public const Int32 ALIGNMENT = 8; - [FieldOffset(20)] + [FieldOffset(16)] public QBoolean IsValid; [FieldOffset(4)] public Int32 DebugNumber; [FieldOffset(0)] public BattleMovementInputType MovementInput; - [FieldOffset(24)] + [FieldOffset(20)] public QBoolean MovementDirectionIsNormalized; - [FieldOffset(32)] + [FieldOffset(28)] public BattleGridPosition MovementPositionTarget; [FieldOffset(64)] public FPVector2 MovementPositionMove; [FieldOffset(48)] public FPVector2 MovementDirection; - [FieldOffset(28)] + [FieldOffset(24)] public QBoolean RotationInput; [FieldOffset(40)] public FP RotationValue; @@ -1001,8 +1001,6 @@ public unsafe partial struct Input { public QBoolean AbilityActivate; [FieldOffset(8)] public Int32 PlayerCharacterNumber; - [FieldOffset(16)] - public QBoolean GiveUpInput; public override Int32 GetHashCode() { unchecked { var hash = 19249; @@ -1017,7 +1015,6 @@ public override Int32 GetHashCode() { hash = hash * 31 + RotationValue.GetHashCode(); hash = hash * 31 + AbilityActivate.GetHashCode(); hash = hash * 31 + PlayerCharacterNumber.GetHashCode(); - hash = hash * 31 + GiveUpInput.GetHashCode(); return hash; } } @@ -1040,7 +1037,6 @@ static partial void SerializeCodeGen(void* ptr, FrameSerializer serializer) { serializer.Stream.Serialize(&p->DebugNumber); serializer.Stream.Serialize(&p->PlayerCharacterNumber); QBoolean.Serialize(&p->AbilityActivate, serializer); - QBoolean.Serialize(&p->GiveUpInput, serializer); QBoolean.Serialize(&p->IsValid, serializer); QBoolean.Serialize(&p->MovementDirectionIsNormalized, serializer); QBoolean.Serialize(&p->RotationInput, serializer); @@ -1937,7 +1933,6 @@ partial void SetPlayerInputCodeGen(PlayerRef player, Input input) { i->RotationValue = input.RotationValue; i->AbilityActivate = input.AbilityActivate; i->PlayerCharacterNumber = input.PlayerCharacterNumber; - i->GiveUpInput = input.GiveUpInput; } public Input* GetPlayerInput(PlayerRef player) { if ((int)player >= (int)_globals->input.Length) { throw new System.ArgumentOutOfRangeException("player"); } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs index b9e813a2a8..74bdf1fb65 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs @@ -559,7 +559,6 @@ public unsafe partial class InputPrototype : StructPrototype { public FP RotationValue; public QBoolean AbilityActivate; public Int32 PlayerCharacterNumber; - public QBoolean GiveUpInput; partial void MaterializeUser(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context); public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context = default) { result.IsValid = this.IsValid; @@ -573,7 +572,6 @@ public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMater result.RotationValue = this.RotationValue; result.AbilityActivate = this.AbilityActivate; result.PlayerCharacterNumber = this.PlayerCharacterNumber; - result.GiveUpInput = this.GiveUpInput; MaterializeUser(frame, ref result, in context); } } From f8487b3e1e68c53a5b5f012b413e6ca8078d5a8e Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 14:27:51 +0300 Subject: [PATCH 05/52] Battle: Added command for character swapping #1467 --- .../Battle/Scripts/Player/Commands.meta | 8 +++++++ .../Player/Commands/CommandSwapCharacter.cs | 21 +++++++++++++++++++ .../Commands/CommandSwapCharacter.cs.meta | 11 ++++++++++ .../Simulation/CommandSetup.User.cs | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta new file mode 100644 index 0000000000..0bfa8dc0d6 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f035f2d0828dae84bbfb95c08032e2a8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs new file mode 100644 index 0000000000..3804889540 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs @@ -0,0 +1,21 @@ +// Quantum usings +using Quantum; +using Photon.Deterministic; + +namespace Battle.QSimulation.Player +{ + public class CommandSwapCharacter : DeterministicCommand + { + public int CharacterNumber; + + public override void Serialize(BitStream stream) + { + stream.Serialize(ref CharacterNumber); + } + + public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + { + BattlePlayerQSystem.HandleCharacterSwapping(f, playerHandle, CharacterNumber); + } + } +} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta new file mode 100644 index 0000000000..52f5aedf90 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5774abcd7250818408c2eade11ad5548 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index 948ea805a3..7120b2bc40 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Battle.QSimulation.Player; - // Quantum usings using Photon.Deterministic; @@ -16,6 +15,7 @@ static partial void AddCommandFactoriesUser(ICollection Date: Fri, 24 Apr 2026 14:29:51 +0300 Subject: [PATCH 06/52] Battle: Updated character swapping to use command instead of input #1467 --- .../Scripts/Player/BattlePlayerQSystem.cs | 20 +++++++++---------- .../Scripts/Game/BattleGameViewController.cs | 8 ++++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 4d009e39f9..39359dc13c 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -180,9 +180,14 @@ public override void Update(Frame f) continue; } + if (f.GetPlayerCommand(playerData->PlayerRef) is CommandSwapCharacter swapCharacterCommand) + { + swapCharacterCommand.Execute(f, playerHandle); + continue; + } + input = GetInput(f, playerHandle, playerData, &stackInputStorage); - if (HandleCharacterSwapping(f, input, playerHandle)) continue; if (HandleOutOfPlay(f, playerHandle)) continue; HandleInPlay(f, input, playerHandle, playerData, playerEntity, playerTransform); @@ -270,7 +275,6 @@ private enum SoundEffectTypeCharacter MovementDirection = FPVector2.Zero, RotationInput = false, RotationValue = FP._0, - PlayerCharacterNumber = -1, AbilityActivate = false }; } @@ -387,23 +391,19 @@ public static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle player /// Handle of the player. /// /// True if character swapped. - private bool HandleCharacterSwapping(Frame f, Input* input, BattlePlayerManager.PlayerHandle playerHandle) + public static void HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { - if (input->PlayerCharacterNumber < 0) return false; - s_debugLogger.LogFormat(f, "({0}) Character swap input received", playerHandle.Slot); if (!playerHandle.AllowCharacterSwapping) { s_debugLogger.LogFormat(f, "({0}) Character swap input rejected, as AllowCharacterSwapping == false", playerHandle.Slot); - return false; + return; } - s_debugLogger.LogFormat(f, "({0}) Swapping to character number: {1}", playerHandle.Slot, input->PlayerCharacterNumber); - - BattlePlayerManager.SpawnPlayer(f, playerHandle.Slot, input->PlayerCharacterNumber); + s_debugLogger.LogFormat(f, "({0}) Swapping to character number: {1}", playerHandle.Slot, playerCharacterNumber); - return true; + BattlePlayerManager.SpawnPlayer(f, playerHandle.Slot, playerCharacterNumber); } /// diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index 7b3ded7ae4..40a863ee31 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -144,8 +144,12 @@ public void UiInputOnLocalPlayerGiveUp() /// The character number which the local player selected. public void UiInputOnCharacterSelected(int characterNumber) { - _playerInput.OnCharacterSelected(characterNumber); - + PlayerRef playerRef; + playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; + QuantumRunner.Default.Game.SendCommand(playerRef, new CommandSwapCharacter + { + CharacterNumber = characterNumber + }); _debugLogger.LogFormat("Character number {0} button pressed!", characterNumber); } From 0c88b081977bd69fcddde8848b8d2ad5d1febc52 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 14:30:24 +0300 Subject: [PATCH 07/52] Battle: Removed PlayerCharacterNumber input #1467 --- .../Battle/Qtn/Player/BattlePlayerInput.qtn | 1 - .../Battle/Scripts/BattleDebugUtils.cs | 10 +--------- .../Player/BattlePlayerBotController.cs | 1 - .../Scripts/Player/BattlePlayerInput.cs | 20 ------------------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn index d0831ef262..c54b56e834 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn @@ -10,7 +10,6 @@ input bool RotationInput; FP RotationValue; bool AbilityActivate; - int PlayerCharacterNumber; } enum BattleMovementInputType diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs index 43ed2a2c36..2fb624581a 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs @@ -73,12 +73,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) inputDebugSummary += "Ability Activate"; inputNotEmpty = true; } - if (input->PlayerCharacterNumber > -1) - { - if (inputDebugSummary != "") inputDebugSummary += ", "; - inputDebugSummary += "Character Swap"; - inputNotEmpty = true; - } if (inputNotEmpty) { @@ -94,7 +88,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) " RotationInput: {5},\n" + " RotationValue: {6},\n" + " AbilityActivate: {7},\n" + - " PlayerCharacterNumber: {8},\n" + "}}", input->MovementInput, input->MovementDirectionIsNormalized, @@ -103,8 +96,7 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) input->MovementDirection, input->RotationInput, input->RotationValue, - input->AbilityActivate, - input->PlayerCharacterNumber + input->AbilityActivate ) ); } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs index a62655ee56..ea95ac5472 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs @@ -173,7 +173,6 @@ public static void GetBotInput(Frame f, bool isInPlay, BattlePlayerDataQComponen MovementDirection = FPVector2.Zero, RotationInput = false, RotationValue = FP._0, - PlayerCharacterNumber = -1, AbilityActivate = false }; } diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index d9b7d87b8f..e0a8708f5b 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -66,16 +66,6 @@ public void OnJoystickRotation(float input) _joystickRotationValue = input; } - /// - /// Called when the player presses one of the character selection buttons. - /// - /// - /// The number of the character that was selected. - public void OnCharacterSelected(int characterNumber) - { - _characterNumber = characterNumber; - } - /// @} /// @@ -145,9 +135,6 @@ public RotationInputInfo(bool rotationInput, FP rotationValue) /// Saved time stamp of the previous tap. private float _lastTapTime; - /// Saved character number from character swapping input. - private int _characterNumber = -1; - /// Bool to block screen input private bool _blockScreenInput = false; @@ -251,9 +238,6 @@ private void PollInput(CallbackPollInput callback) MovementInputInfo movementInputInfo = new(BattleMovementInputType.None, false, new BattleGridPosition() { Row = -1, Col = -1 }, FPVector2.Zero, FPVector2.Zero); RotationInputInfo rotationInputInfo = new(false, FP._0); - // check button input - if (_characterNumber > -1) _blockScreenInput = true; - Vector2 clickPosition = Vector2.zero; Vector3 unityPosition = Vector3.zero; @@ -288,7 +272,6 @@ private void PollInput(CallbackPollInput callback) RotationInput = rotationInputInfo.RotationInput, RotationValue = rotationInputInfo.RotationValue, AbilityActivate = Time.time - _lastTapTime < DoubleTapInterval && mouseClick && Vector3.Distance(_lastTapPosition, unityPosition) < DoubleTapDistance, - PlayerCharacterNumber = _characterNumber, }; DeterministicInputFlags inputFlags = DeterministicInputFlags.Repeatable; @@ -324,9 +307,6 @@ private void PollInput(CallbackPollInput callback) _previousTime = Time.time; _inputDebugNumber++; - - // reset - _characterNumber = -1; } /// @name Input reading methods From a8fe924c92914beee724759140d5f6d9570c1d6a Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 14:30:36 +0300 Subject: [PATCH 08/52] Battle: Ran quantum codegen #1467 --- .../Generated/Quantum.CodeGen.Core.cs | 31 ++++++++----------- .../Generated/Quantum.CodeGen.Prototypes.cs | 2 -- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs index e0c924ad90..d325abb184 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs @@ -977,30 +977,28 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct Input { - public const Int32 SIZE = 80; + public const Int32 SIZE = 72; public const Int32 ALIGNMENT = 8; - [FieldOffset(16)] + [FieldOffset(12)] public QBoolean IsValid; [FieldOffset(4)] public Int32 DebugNumber; [FieldOffset(0)] public BattleMovementInputType MovementInput; - [FieldOffset(20)] + [FieldOffset(16)] public QBoolean MovementDirectionIsNormalized; - [FieldOffset(28)] + [FieldOffset(24)] public BattleGridPosition MovementPositionTarget; - [FieldOffset(64)] + [FieldOffset(56)] public FPVector2 MovementPositionMove; - [FieldOffset(48)] + [FieldOffset(40)] public FPVector2 MovementDirection; - [FieldOffset(24)] + [FieldOffset(20)] public QBoolean RotationInput; - [FieldOffset(40)] + [FieldOffset(32)] public FP RotationValue; - [FieldOffset(12)] - public QBoolean AbilityActivate; [FieldOffset(8)] - public Int32 PlayerCharacterNumber; + public QBoolean AbilityActivate; public override Int32 GetHashCode() { unchecked { var hash = 19249; @@ -1014,7 +1012,6 @@ public override Int32 GetHashCode() { hash = hash * 31 + RotationInput.GetHashCode(); hash = hash * 31 + RotationValue.GetHashCode(); hash = hash * 31 + AbilityActivate.GetHashCode(); - hash = hash * 31 + PlayerCharacterNumber.GetHashCode(); return hash; } } @@ -1035,7 +1032,6 @@ static partial void SerializeCodeGen(void* ptr, FrameSerializer serializer) { var p = (Input*)ptr; serializer.Stream.Serialize((Int32*)&p->MovementInput); serializer.Stream.Serialize(&p->DebugNumber); - serializer.Stream.Serialize(&p->PlayerCharacterNumber); QBoolean.Serialize(&p->AbilityActivate, serializer); QBoolean.Serialize(&p->IsValid, serializer); QBoolean.Serialize(&p->MovementDirectionIsNormalized, serializer); @@ -1048,7 +1044,7 @@ static partial void SerializeCodeGen(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct _globals_ { - public const Int32 SIZE = 1048; + public const Int32 SIZE = 1000; public const Int32 ALIGNMENT = 8; [FieldOffset(0)] public AssetRef Map; @@ -1072,12 +1068,12 @@ public unsafe partial struct _globals_ { public Int32 PlayerConnectedCount; [FieldOffset(560)] [FramePrinter.FixedArrayAttribute(typeof(Input), 6)] - private fixed Byte _input_[480]; - [FieldOffset(1040)] + private fixed Byte _input_[432]; + [FieldOffset(992)] public BitSet6 PlayerLastConnectionState; public FixedArray input { get { - fixed (byte* p = _input_) { return new FixedArray(p, 80, 6); } + fixed (byte* p = _input_) { return new FixedArray(p, 72, 6); } } } public override Int32 GetHashCode() { @@ -1932,7 +1928,6 @@ partial void SetPlayerInputCodeGen(PlayerRef player, Input input) { i->RotationInput = input.RotationInput; i->RotationValue = input.RotationValue; i->AbilityActivate = input.AbilityActivate; - i->PlayerCharacterNumber = input.PlayerCharacterNumber; } public Input* GetPlayerInput(PlayerRef player) { if ((int)player >= (int)_globals->input.Length) { throw new System.ArgumentOutOfRangeException("player"); } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs index 74bdf1fb65..671b101ced 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs @@ -558,7 +558,6 @@ public unsafe partial class InputPrototype : StructPrototype { public QBoolean RotationInput; public FP RotationValue; public QBoolean AbilityActivate; - public Int32 PlayerCharacterNumber; partial void MaterializeUser(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context); public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context = default) { result.IsValid = this.IsValid; @@ -571,7 +570,6 @@ public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMater result.RotationInput = this.RotationInput; result.RotationValue = this.RotationValue; result.AbilityActivate = this.AbilityActivate; - result.PlayerCharacterNumber = this.PlayerCharacterNumber; MaterializeUser(frame, ref result, in context); } } From c08bc05c079ac3e3a3c80320744d78916247b813 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:18:57 +0300 Subject: [PATCH 09/52] Battle: Added command for ability activation #1467 --- .../Player/Commands/CommandActivateAbility.cs | 17 +++++++++++++++++ .../Commands/CommandActivateAbility.cs.meta | 11 +++++++++++ .../QuantumUser/Simulation/CommandSetup.User.cs | 1 + 3 files changed, 29 insertions(+) create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs new file mode 100644 index 0000000000..e29b87d13c --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs @@ -0,0 +1,17 @@ +// Quantum usings +using Quantum; +using Photon.Deterministic; + +namespace Battle.QSimulation.Player +{ + public unsafe class CommandActivateAbility : DeterministicCommand + { + public override void Serialize(BitStream stream) { } + + public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + { + BattlePlayerDataQComponent* playerData = f.Unsafe.GetPointer(playerHandle.SelectedCharacterEntity); + playerData->AbilityActivateBufferSec = FrameTimer.FromSeconds(f, FP._0_50); + } + } +} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta new file mode 100644 index 0000000000..416448cc7c --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 76ada46f5d113e5498b4cc4d41cb13a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index 7120b2bc40..f5d2bce653 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -16,6 +16,7 @@ static partial void AddCommandFactoriesUser(ICollection Date: Fri, 24 Apr 2026 15:20:43 +0300 Subject: [PATCH 10/52] Battle: Updated ability activation to use command instead of input #1467 --- .../Battle/Scripts/Player/BattlePlayerQSystem.cs | 11 +++++------ .../View/Battle/Scripts/Player/BattlePlayerInput.cs | 10 +++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 39359dc13c..3c1f1cbb1d 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -186,6 +186,11 @@ public override void Update(Frame f) continue; } + if (f.GetPlayerCommand(playerData->PlayerRef) is CommandActivateAbility abilityCommand) + { + abilityCommand.Execute(f, playerHandle); + } + input = GetInput(f, playerHandle, playerData, &stackInputStorage); if (HandleOutOfPlay(f, playerHandle)) continue; @@ -275,7 +280,6 @@ private enum SoundEffectTypeCharacter MovementDirection = FPVector2.Zero, RotationInput = false, RotationValue = FP._0, - AbilityActivate = false }; } @@ -465,11 +469,6 @@ private void HandleInPlay(Frame f, Input* input, BattlePlayerManager.PlayerHandl { bool updateMovement = true; - if (input->AbilityActivate) - { - playerData->AbilityActivateBufferSec = FrameTimer.FromSeconds(f, FP._0_50); - } - if (!playerData->AbilityCooldownSec.IsRunning(f) && playerData->AbilityActivateBufferSec.IsRunning(f)) { AbilityActivate(f, playerData, playerTransform); diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index e0a8708f5b..3e9529cec2 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -28,6 +28,7 @@ using MovementInputType = SettingsCarrier.BattleMovementInputType; using RotationInputType = SettingsCarrier.BattleRotationInputType; +using Battle.QSimulation.Player; namespace Battle.View.Player { @@ -258,6 +259,14 @@ private void PollInput(CallbackPollInput callback) _blockScreenInput = false; } + bool abilityActivate = Time.time - _lastTapTime < DoubleTapInterval && mouseClick && Vector3.Distance(_lastTapPosition, unityPosition) < DoubleTapDistance; + + if (abilityActivate) + { + PlayerRef playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; + QuantumRunner.Default.Game.SendCommand(playerRef, new CommandActivateAbility()); + } + //{ create and set input Input input = new() @@ -271,7 +280,6 @@ private void PollInput(CallbackPollInput callback) MovementDirection = movementInputInfo.MovementDirection, RotationInput = rotationInputInfo.RotationInput, RotationValue = rotationInputInfo.RotationValue, - AbilityActivate = Time.time - _lastTapTime < DoubleTapInterval && mouseClick && Vector3.Distance(_lastTapPosition, unityPosition) < DoubleTapDistance, }; DeterministicInputFlags inputFlags = DeterministicInputFlags.Repeatable; From f91c864117c6b81507c56d47875cb68f7e4b6667 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:21:22 +0300 Subject: [PATCH 11/52] Battle: Removed AbilityActivate input #1467 --- .../Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn | 1 - .../Simulation/Battle/Scripts/BattleDebugUtils.cs | 10 +--------- .../Battle/Scripts/Player/BattlePlayerBotController.cs | 3 +-- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn index c54b56e834..dac19686c7 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn @@ -9,7 +9,6 @@ input FPVector2 MovementDirection; bool RotationInput; FP RotationValue; - bool AbilityActivate; } enum BattleMovementInputType diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs index 2fb624581a..021a254fb8 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs @@ -67,12 +67,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) inputDebugSummary += "Rotate"; inputNotEmpty = true; } - if (input->AbilityActivate != false) - { - if (inputDebugSummary != "") inputDebugSummary += ", "; - inputDebugSummary += "Ability Activate"; - inputNotEmpty = true; - } if (inputNotEmpty) { @@ -87,7 +81,6 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) " MovementDirection: {4},\n" + " RotationInput: {5},\n" + " RotationValue: {6},\n" + - " AbilityActivate: {7},\n" + "}}", input->MovementInput, input->MovementDirectionIsNormalized, @@ -95,8 +88,7 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) input->MovementPositionMove, input->MovementDirection, input->RotationInput, - input->RotationValue, - input->AbilityActivate + input->RotationValue ) ); } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs index ea95ac5472..8a038541a8 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs @@ -172,8 +172,7 @@ public static void GetBotInput(Frame f, bool isInPlay, BattlePlayerDataQComponen MovementPositionMove = FPVector2.Zero, MovementDirection = FPVector2.Zero, RotationInput = false, - RotationValue = FP._0, - AbilityActivate = false + RotationValue = FP._0 }; } } From 12bb9f584975fe711499d09b7eb0bd8e1543d495 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:21:35 +0300 Subject: [PATCH 12/52] Battle: Ran quantum codegen #1467 --- .../Simulation/Generated/Quantum.CodeGen.Core.cs | 13 ++++--------- .../Generated/Quantum.CodeGen.Prototypes.cs | 2 -- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs index d325abb184..95e40b41b2 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs @@ -979,26 +979,24 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { public unsafe partial struct Input { public const Int32 SIZE = 72; public const Int32 ALIGNMENT = 8; - [FieldOffset(12)] + [FieldOffset(8)] public QBoolean IsValid; [FieldOffset(4)] public Int32 DebugNumber; [FieldOffset(0)] public BattleMovementInputType MovementInput; - [FieldOffset(16)] + [FieldOffset(12)] public QBoolean MovementDirectionIsNormalized; - [FieldOffset(24)] + [FieldOffset(20)] public BattleGridPosition MovementPositionTarget; [FieldOffset(56)] public FPVector2 MovementPositionMove; [FieldOffset(40)] public FPVector2 MovementDirection; - [FieldOffset(20)] + [FieldOffset(16)] public QBoolean RotationInput; [FieldOffset(32)] public FP RotationValue; - [FieldOffset(8)] - public QBoolean AbilityActivate; public override Int32 GetHashCode() { unchecked { var hash = 19249; @@ -1011,7 +1009,6 @@ public override Int32 GetHashCode() { hash = hash * 31 + MovementDirection.GetHashCode(); hash = hash * 31 + RotationInput.GetHashCode(); hash = hash * 31 + RotationValue.GetHashCode(); - hash = hash * 31 + AbilityActivate.GetHashCode(); return hash; } } @@ -1032,7 +1029,6 @@ static partial void SerializeCodeGen(void* ptr, FrameSerializer serializer) { var p = (Input*)ptr; serializer.Stream.Serialize((Int32*)&p->MovementInput); serializer.Stream.Serialize(&p->DebugNumber); - QBoolean.Serialize(&p->AbilityActivate, serializer); QBoolean.Serialize(&p->IsValid, serializer); QBoolean.Serialize(&p->MovementDirectionIsNormalized, serializer); QBoolean.Serialize(&p->RotationInput, serializer); @@ -1927,7 +1923,6 @@ partial void SetPlayerInputCodeGen(PlayerRef player, Input input) { i->MovementDirection = input.MovementDirection; i->RotationInput = input.RotationInput; i->RotationValue = input.RotationValue; - i->AbilityActivate = input.AbilityActivate; } public Input* GetPlayerInput(PlayerRef player) { if ((int)player >= (int)_globals->input.Length) { throw new System.ArgumentOutOfRangeException("player"); } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs index 671b101ced..3fb7b15146 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs @@ -557,7 +557,6 @@ public unsafe partial class InputPrototype : StructPrototype { public FPVector2 MovementDirection; public QBoolean RotationInput; public FP RotationValue; - public QBoolean AbilityActivate; partial void MaterializeUser(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context); public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context = default) { result.IsValid = this.IsValid; @@ -569,7 +568,6 @@ public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMater result.MovementDirection = this.MovementDirection; result.RotationInput = this.RotationInput; result.RotationValue = this.RotationValue; - result.AbilityActivate = this.AbilityActivate; MaterializeUser(frame, ref result, in context); } } From 9f14b7cb753ac503b9c12b51df04b6ce0f2f38e9 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:44:38 +0300 Subject: [PATCH 13/52] BattlePlayerInput.cs: Moved using to correct place #1469 --- .../QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 3e9529cec2..97eb49a0c7 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -22,13 +22,13 @@ // Battle QSimulation usings using Battle.QSimulation; using Battle.QSimulation.Game; +using Battle.QSimulation.Player; // Battle View usings using Battle.View.Game; using MovementInputType = SettingsCarrier.BattleMovementInputType; using RotationInputType = SettingsCarrier.BattleRotationInputType; -using Battle.QSimulation.Player; namespace Battle.View.Player { From 28fb143e4bf8cb19bdfb6a418e61cdae384693c7 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:45:08 +0300 Subject: [PATCH 14/52] CommandSetup.User.cs: Added documentation #1469 --- .../Simulation/CommandSetup.User.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index f5d2bce653..4b4eef1561 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -1,4 +1,9 @@ -// System usings +/// @file CommandSetup.User.cs +/// +/// Registers the game's custom deterministic commands with the %Quantum simulation. +/// + +// System usings using System.Collections.Generic; using Battle.QSimulation.Player; @@ -7,8 +12,20 @@ namespace Quantum { + /// + /// Contains all project-specific commands. %Quantum invokes the generated side of this partial class at startup. + /// public static partial class DeterministicCommandSetup { + /// + /// Registers the game's custom instances with + /// the %Quantum command system. Called once by the framework during simulation + /// initialization. Should not be called manually. + /// + /// + /// The command factory collection to register commands into + /// The runtime game configuration for the current session + /// The simulation configuration for the current session static partial void AddCommandFactoriesUser(ICollection factories, RuntimeConfig gameConfig, SimulationConfig simulationConfig) { // Add or remove commands to the collection. From 88a79c6f38a8605f90c08e99ee21bb55359bc1e7 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:45:24 +0300 Subject: [PATCH 15/52] CommandSwapCharacter.cs: Added documentation #1469 --- .../Player/Commands/CommandSwapCharacter.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs index 3804889540..508d5acd93 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs @@ -1,18 +1,39 @@ +/// @file CommandSwapCharacter.cs +/// +/// A deterministic command that triggers the character swapping logic for a specific player. +/// + // Quantum usings using Quantum; using Photon.Deterministic; namespace Battle.QSimulation.Player { + /// + /// A deterministic command that triggers the character swapping logic for a specific player. + /// public class CommandSwapCharacter : DeterministicCommand { + /// + /// The number of the character the player is attempting to swap to. + /// public int CharacterNumber; + /// + /// Serializes the character number into the bitstream for network transmission. + /// + /// The bitstream to write to or read from. public override void Serialize(BitStream stream) { stream.Serialize(ref CharacterNumber); } + /// + /// Executes the character swapping logic for the specified player. + /// + /// + /// The current simulation frame. + /// The player handle of the player initiating the command. public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerQSystem.HandleCharacterSwapping(f, playerHandle, CharacterNumber); From d82fde21696b28d7be4caede2b262805866e5c62 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:45:37 +0300 Subject: [PATCH 16/52] CommandActivateAbility.cs: Added documentation #1469 --- .../Player/Commands/CommandActivateAbility.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs index e29b87d13c..d66043f274 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs @@ -1,13 +1,30 @@ +/// @file CommandActivateAbility.cs +/// +/// A deterministic command that triggers the ability activation for a specific player. +/// + // Quantum usings using Quantum; using Photon.Deterministic; namespace Battle.QSimulation.Player { + /// + /// A deterministic command that triggers the ability activation for a specific player. + /// public unsafe class CommandActivateAbility : DeterministicCommand { + /// + /// Method that is required to be implemented but not needed here. + /// public override void Serialize(BitStream stream) { } + /// + /// Executes the ability activation logic by setting an input buffer for the specified player. + /// + /// + /// The current simulation frame. + /// The player handle of the player initiating the command. public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerDataQComponent* playerData = f.Unsafe.GetPointer(playerHandle.SelectedCharacterEntity); From e3985f631f9d124b06ceb9d6581334123f79940f Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:45:53 +0300 Subject: [PATCH 17/52] CommandGiveUp.cs: Added documentation #1469 --- .../Scripts/Game/Commands/CommandGiveUp.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs index 0b439cf418..1666fd86d1 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs @@ -1,13 +1,30 @@ +/// @file CommandGiveUp.cs +/// +/// A deterministic command that triggers the give up logic for a specific player. +/// + // Quantum usings using Quantum; using Photon.Deterministic; namespace Battle.QSimulation.Player { + /// + /// A deterministic command that triggers the give up logic for a specific player. + /// public class CommandGiveUp : DeterministicCommand { + /// + /// Method that is required to be implemented but not needed here. + /// public override void Serialize(BitStream stream) { } + /// + /// Executes the give up logic for the specified player. + /// + /// + /// The current simulation frame + /// The player handle of the player initiating the command. public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerQSystem.HandleGiveUp(f, playerHandle); From b1547cb63792e33ebad977bf9ed02ef063bea027 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 27 Apr 2026 18:46:21 +0300 Subject: [PATCH 18/52] BattlePlayerQSystem.cs: Updated documentation #1469 --- .../Scripts/Player/BattlePlayerQSystem.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 3c1f1cbb1d..9491869dd6 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -144,9 +144,10 @@ public static void OnProjectileHitPlayerShield(Frame f, BattleCollisionQSystem.P /// /// Update method has been split into subprocesses.
/// see @cref{BattlePlayerQSystem,GetInput}
- /// see @cref{BattlePlayerQSystem,HandleGiveUpInput}
- /// see @cref{BattlePlayerQSystem,HandleCharacterSwapping}
+ /// see @cref{Battle.QSimulation.Player,CommandGiveUp}
+ /// see @cref{Battle.QSimulation.Player,CommandSwapCharacter}
/// see @cref{BattlePlayerQSystem,HandleOutOfPlay}
+ /// see @cref{Battle.QSimulation.Player,CommandActivateAbility}
/// see @cref{BattlePlayerQSystem,HandleInPlay} /// /// Current simulation frame @@ -365,17 +366,14 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i } /// - /// Private helper method for handling player input for giving up during the game play.
- /// Subprocess of the Update method. + /// Public helper method for handling player input for giving up during the game play.
+ /// Called by @cref{Battle.QSimulation.Player,CommandGiveUp} ///
/// /// Updates give up state and calls HandleGiveUpLogic method which handles the rest of the logic. /// /// Current simulation frame. - /// Pointer to the player's input data. /// Handle of the player. - /// - /// True if the give up input was processed. public static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; @@ -386,15 +384,12 @@ public static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle player } /// - /// Private helper method for handling character swapping.
- /// Subprocess of the Update method. + /// Public helper method for handling character swapping.
+ /// Called by @cref{Battle.QSimulation.Player,CommandSwapCharacter} ///
/// /// Current simulation frame. - /// Pointer to the player's input data. /// Handle of the player. - /// - /// True if character swapped. public static void HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { s_debugLogger.LogFormat(f, "({0}) Character swap input received", playerHandle.Slot); From 272d8592f0b4d30fbce77660556b08dfbc9e3bb2 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Tue, 28 Apr 2026 16:52:19 +0300 Subject: [PATCH 19/52] Battle: Combined MovementPositionTarget and MovementPosition Move to MovementDirection #1469 --- .../Battle/Qtn/Player/BattlePlayerInput.qtn | 5 +- .../Battle/Scripts/BattleDebugUtils.cs | 12 ++- .../Player/BattlePlayerBotController.cs | 5 +- .../Player/BattlePlayerMovementController.cs | 6 +- .../Scripts/Player/BattlePlayerQSystem.cs | 42 ++++----- .../Generated/Quantum.CodeGen.Core.cs | 31 +++---- .../Generated/Quantum.CodeGen.Prototypes.cs | 10 +-- .../Scripts/Player/BattlePlayerInput.cs | 89 +++++++++++++------ 8 files changed, 112 insertions(+), 88 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn index dac19686c7..a1ffaa6ebc 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerInput.qtn @@ -4,9 +4,8 @@ input int DebugNumber; BattleMovementInputType MovementInput; bool MovementDirectionIsNormalized; - BattleGridPosition MovementPositionTarget; - FPVector2 MovementPositionMove; - FPVector2 MovementDirection; + BattleGridPosition MovementGridPosition; + FPVector2 MovementVector; bool RotationInput; FP RotationValue; } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs index 021a254fb8..a2282b4ee4 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs @@ -77,16 +77,14 @@ public static InputDebugInfo GenerateDebugInfo(Input* input) " MovementInput: {0},\n" + " MovementDirectionIsNormalized: {1},\n" + " MovementPositionTarget: {2},\n" + - " MovementPositionMove: {3},\n" + - " MovementDirection: {4},\n" + - " RotationInput: {5},\n" + - " RotationValue: {6},\n" + + " MovementVector: {3},\n" + + " RotationInput: {4},\n" + + " RotationValue: {5},\n" + "}}", input->MovementInput, input->MovementDirectionIsNormalized, - input->MovementPositionTarget.ConvertToString(), - input->MovementPositionMove, - input->MovementDirection, + input->MovementGridPosition.ConvertToString(), + input->MovementVector, input->RotationInput, input->RotationValue ) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs index 8a038541a8..8dc5facde1 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs @@ -168,9 +168,8 @@ public static void GetBotInput(Frame f, bool isInPlay, BattlePlayerDataQComponen IsValid = true, MovementInput = movementInput, MovementDirectionIsNormalized = false, - MovementPositionTarget = predictedGridPosition, - MovementPositionMove = FPVector2.Zero, - MovementDirection = FPVector2.Zero, + MovementGridPosition = predictedGridPosition, + MovementVector = FPVector2.Zero, RotationInput = false, RotationValue = FP._0 }; diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerMovementController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerMovementController.cs index 04b8b4a63c..2bcf439c82 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerMovementController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerMovementController.cs @@ -92,12 +92,12 @@ public static void UpdateMovement(Frame f, BattlePlayerDataQComponent* playerDat break; case BattleMovementInputType.PositionTarget: - ClampGridPosition(playerData, input->MovementPositionTarget, out playerData->TargetPosition); + ClampGridPosition(playerData, input->MovementGridPosition, out playerData->TargetPosition); playerData->HasTargetPosition = true; break; case BattleMovementInputType.PositionMove: - positionNext = FPVector2.MoveTowards(transform->Position, input->MovementPositionMove, playerData->Stats.Speed * f.DeltaTime); + positionNext = FPVector2.MoveTowards(transform->Position, input->MovementVector, playerData->Stats.Speed * f.DeltaTime); if (ClampAndSnapWorldPosition(playerData, positionNext, out FPVector2 clampedNext)) { positionNext = clampedNext; @@ -106,7 +106,7 @@ public static void UpdateMovement(Frame f, BattlePlayerDataQComponent* playerDat break; case BattleMovementInputType.Direction: - FPVector2 movementDirection = input->MovementDirection * (input->MovementDirectionIsNormalized ? playerData->Stats.Speed : FP._1); + FPVector2 movementDirection = input->MovementVector * (input->MovementDirectionIsNormalized ? playerData->Stats.Speed : FP._1); positionNext = transform->Position + FPVector2.ClampMagnitude(movementDirection, playerData->Stats.Speed) * f.DeltaTime; if (ClampAndSnapWorldPosition(playerData, positionNext, out FPVector2 clampedPosition)) { diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 9491869dd6..9e555bcc73 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -89,7 +89,9 @@ public static void OnProjectileHitPlayerCharacter(Frame f, BattleCollisionQSyste BattleEmotionState.Joy => SoundEffectTypeCharacter.HitCharacterJoy, BattleEmotionState.Love => SoundEffectTypeCharacter.HitCharacterLove, BattleEmotionState.Playful => SoundEffectTypeCharacter.HitCharacterPlayful, - BattleEmotionState.Sadness => SoundEffectTypeCharacter.HitCharacterSadness + BattleEmotionState.Sadness => SoundEffectTypeCharacter.HitCharacterSadness, + + _ => throw new System.NotImplementedException() }; HandleSFXCharacter(f, soundEffectType, damagedPlayerData->CharacterId); } @@ -175,21 +177,23 @@ public override void Update(Frame f) playerTransform = f.Unsafe.GetPointer(playerEntity); } - if (f.GetPlayerCommand(playerData->PlayerRef) is CommandGiveUp giveUpCommand) + switch (BattleCommand.GetCommand(f, playerData->PlayerRef, out BattleCommand commandData)) { - giveUpCommand.Execute(f, playerHandle); - continue; - } + case BattleCommand.Type.None: + break; - if (f.GetPlayerCommand(playerData->PlayerRef) is CommandSwapCharacter swapCharacterCommand) - { - swapCharacterCommand.Execute(f, playerHandle); - continue; - } + case BattleCommand.Type.GiveUp: + HandleGiveUp(f, playerHandle); + break; - if (f.GetPlayerCommand(playerData->PlayerRef) is CommandActivateAbility abilityCommand) - { - abilityCommand.Execute(f, playerHandle); + case BattleCommand.Type.ActivateAbility: + playerData->AbilityActivateBufferSec = FrameTimer.FromSeconds(f, FP._0_50); + break; + + case BattleCommand.Type.SwapCharacter: + BattleCharacterSwapQCommand swapCharacterData = (BattleCharacterSwapQCommand)commandData; + HandleCharacterSwapping(f, playerHandle, swapCharacterData.CharacterNumber); + break; } input = GetInput(f, playerHandle, playerData, &stackInputStorage); @@ -276,9 +280,8 @@ private enum SoundEffectTypeCharacter IsValid = true, MovementInput = BattleMovementInputType.None, MovementDirectionIsNormalized = false, - MovementPositionTarget = new BattleGridPosition { Col = 0, Row = 0 }, - MovementPositionMove = FPVector2.Zero, - MovementDirection = FPVector2.Zero, + MovementGridPosition = new BattleGridPosition { Col = 0, Row = 0 }, + MovementVector = FPVector2.Zero, RotationInput = false, RotationValue = FP._0, }; @@ -366,15 +369,14 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i } /// - /// Public helper method for handling player input for giving up during the game play.
- /// Called by @cref{Battle.QSimulation.Player,CommandGiveUp} + /// Private helper method for handling player input for giving up during the game play.
///
/// /// Updates give up state and calls HandleGiveUpLogic method which handles the rest of the logic. /// /// Current simulation frame. /// Handle of the player. - public static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + private static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; @@ -512,7 +514,7 @@ private void AbilityActivate(Frame f, BattlePlayerDataQComponent* playerData, Tr /**/ //} Ability test - + s_debugLogger.Error(f, "ability activated"); playerData->AbilityCooldownSec = FrameTimer.FromSeconds(f, FP._3); } } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs index 95e40b41b2..f75b0734c7 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs @@ -977,7 +977,7 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct Input { - public const Int32 SIZE = 72; + public const Int32 SIZE = 56; public const Int32 ALIGNMENT = 8; [FieldOffset(8)] public QBoolean IsValid; @@ -988,11 +988,9 @@ public unsafe partial struct Input { [FieldOffset(12)] public QBoolean MovementDirectionIsNormalized; [FieldOffset(20)] - public BattleGridPosition MovementPositionTarget; - [FieldOffset(56)] - public FPVector2 MovementPositionMove; + public BattleGridPosition MovementGridPosition; [FieldOffset(40)] - public FPVector2 MovementDirection; + public FPVector2 MovementVector; [FieldOffset(16)] public QBoolean RotationInput; [FieldOffset(32)] @@ -1004,9 +1002,8 @@ public override Int32 GetHashCode() { hash = hash * 31 + DebugNumber.GetHashCode(); hash = hash * 31 + (Int32)MovementInput; hash = hash * 31 + MovementDirectionIsNormalized.GetHashCode(); - hash = hash * 31 + MovementPositionTarget.GetHashCode(); - hash = hash * 31 + MovementPositionMove.GetHashCode(); - hash = hash * 31 + MovementDirection.GetHashCode(); + hash = hash * 31 + MovementGridPosition.GetHashCode(); + hash = hash * 31 + MovementVector.GetHashCode(); hash = hash * 31 + RotationInput.GetHashCode(); hash = hash * 31 + RotationValue.GetHashCode(); return hash; @@ -1032,15 +1029,14 @@ static partial void SerializeCodeGen(void* ptr, FrameSerializer serializer) { QBoolean.Serialize(&p->IsValid, serializer); QBoolean.Serialize(&p->MovementDirectionIsNormalized, serializer); QBoolean.Serialize(&p->RotationInput, serializer); - Quantum.BattleGridPosition.Serialize(&p->MovementPositionTarget, serializer); + Quantum.BattleGridPosition.Serialize(&p->MovementGridPosition, serializer); FP.Serialize(&p->RotationValue, serializer); - FPVector2.Serialize(&p->MovementDirection, serializer); - FPVector2.Serialize(&p->MovementPositionMove, serializer); + FPVector2.Serialize(&p->MovementVector, serializer); } } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct _globals_ { - public const Int32 SIZE = 1000; + public const Int32 SIZE = 904; public const Int32 ALIGNMENT = 8; [FieldOffset(0)] public AssetRef Map; @@ -1064,12 +1060,12 @@ public unsafe partial struct _globals_ { public Int32 PlayerConnectedCount; [FieldOffset(560)] [FramePrinter.FixedArrayAttribute(typeof(Input), 6)] - private fixed Byte _input_[432]; - [FieldOffset(992)] + private fixed Byte _input_[336]; + [FieldOffset(896)] public BitSet6 PlayerLastConnectionState; public FixedArray input { get { - fixed (byte* p = _input_) { return new FixedArray(p, 72, 6); } + fixed (byte* p = _input_) { return new FixedArray(p, 56, 6); } } } public override Int32 GetHashCode() { @@ -1918,9 +1914,8 @@ partial void SetPlayerInputCodeGen(PlayerRef player, Input input) { i->DebugNumber = input.DebugNumber; i->MovementInput = input.MovementInput; i->MovementDirectionIsNormalized = input.MovementDirectionIsNormalized; - i->MovementPositionTarget = input.MovementPositionTarget; - i->MovementPositionMove = input.MovementPositionMove; - i->MovementDirection = input.MovementDirection; + i->MovementGridPosition = input.MovementGridPosition; + i->MovementVector = input.MovementVector; i->RotationInput = input.RotationInput; i->RotationValue = input.RotationValue; } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs index 3fb7b15146..f2765d968d 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs @@ -552,9 +552,8 @@ public unsafe partial class InputPrototype : StructPrototype { public Int32 DebugNumber; public Quantum.QEnum32 MovementInput; public QBoolean MovementDirectionIsNormalized; - public Quantum.Prototypes.BattleGridPositionPrototype MovementPositionTarget; - public FPVector2 MovementPositionMove; - public FPVector2 MovementDirection; + public Quantum.Prototypes.BattleGridPositionPrototype MovementGridPosition; + public FPVector2 MovementVector; public QBoolean RotationInput; public FP RotationValue; partial void MaterializeUser(Frame frame, ref Quantum.Input result, in PrototypeMaterializationContext context); @@ -563,9 +562,8 @@ public void Materialize(Frame frame, ref Quantum.Input result, in PrototypeMater result.DebugNumber = this.DebugNumber; result.MovementInput = this.MovementInput; result.MovementDirectionIsNormalized = this.MovementDirectionIsNormalized; - this.MovementPositionTarget.Materialize(frame, ref result.MovementPositionTarget, in context); - result.MovementPositionMove = this.MovementPositionMove; - result.MovementDirection = this.MovementDirection; + this.MovementGridPosition.Materialize(frame, ref result.MovementGridPosition, in context); + result.MovementVector = this.MovementVector; result.RotationInput = this.RotationInput; result.RotationValue = this.RotationValue; MaterializeUser(frame, ref result, in context); diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 97eb49a0c7..45955edf9f 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -5,7 +5,7 @@ /// Input is processed and compiled into an input struct, which is passed over to the Quantum simulation when polled by Quantum. ///
-//#define DEBUG_INPUT_TYPE_OVERRIDE +#define DEBUG_INPUT_TYPE_OVERRIDE // Unity usings using UnityEngine; @@ -43,8 +43,45 @@ namespace Battle.View.Player /// [{Player Overview}](#page-concepts-player-overview) public class BattlePlayerInput : MonoBehaviour { - /// @name Input methods - /// Input methods are called by BattleGameViewController when the player gives a %UI input. These methods shouldn't be called any other way. + /// @name Command input methods + /// Command input methods are called by BattleGameViewController when the player gives a %UI input. These methods shouldn't be called any other way. + /// These inputs are sent to Quantum as commands. + /// @{ + + /// + /// Called when the player presses give up button + /// + public void CommandSendGiveUp() + { + BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleGiveUpQCommand()); + } + + /// + /// Called when the player presses character swap button + /// + /// + /// The character number of the character to swap to + public void CommandSendSwapCharacter(int characterNumber) + { + BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleCharacterSwapQCommand + { + CharacterNumber = characterNumber + }); + } + + /// + /// Called when the player activates ability + /// + public void CommandSendActivateAbility() + { + BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleCharacterAbilityQCommand()); + } + + /// @} + + /// @name Queued input methods + /// Queued input methods are called by BattleGameViewController when the player gives a %UI input. These methods shouldn't be called any other way. + /// These inputs are queued for next time that Quantum polls input. /// @{ /// @@ -52,7 +89,7 @@ public class BattlePlayerInput : MonoBehaviour /// /// /// The input value of the movement joystick - public void OnJoystickMovement(Vector2 input) + public void QueueJoystickMovement(Vector2 input) { _joystickMovementVector = input; } @@ -62,7 +99,7 @@ public void OnJoystickMovement(Vector2 input) ///
/// /// The input value of the rotation joystick - public void OnJoystickRotation(float input) + public void QueueJoystickRotation(float input) { _joystickRotationValue = input; } @@ -76,17 +113,15 @@ private struct MovementInputInfo { public BattleMovementInputType MovementInput; public bool MovementDirectionIsNormalized; - public BattleGridPosition MovementPositionTarget; - public FPVector2 MovementPositionMove; - public FPVector2 MovementDirection; + public BattleGridPosition MovementGridPosition; + public FPVector2 MovementVector; - public MovementInputInfo(BattleMovementInputType movementInput, bool movementDirectionIsNormalized, BattleGridPosition movementPositionTarget, FPVector2 movementPositionMove, FPVector2 movementDirection) + public MovementInputInfo(BattleMovementInputType movementInput, bool movementDirectionIsNormalized, BattleGridPosition movementPositionTarget, FPVector2 movementVector) { MovementInput = movementInput; MovementDirectionIsNormalized = movementDirectionIsNormalized; - MovementPositionTarget = movementPositionTarget; - MovementPositionMove = movementPositionMove; - MovementDirection = movementDirection; + MovementGridPosition = movementPositionTarget; + MovementVector = movementVector; } } @@ -200,8 +235,8 @@ private void OnEnable() #if DEBUG_INPUT_TYPE_OVERRIDE _debugLogger.Warning("DEBUG_INPUT_TYPE_OVERRIDE enabled!"); - _movementInputType = MovementInputType.FollowPointer; - _rotationInputType = RotationInputType.TwoFinger; + _movementInputType = MovementInputType.PointAndClick; + _rotationInputType = RotationInputType.Swipe; _debugLogger.WarningFormat("Using MovementInputType {0} override", _movementInputType); _debugLogger.WarningFormat("Using RotationInputType {0} override", _rotationInputType); @@ -236,7 +271,7 @@ private void PollInput(CallbackPollInput callback) const float DoubleTapDistance = 1.0f; // set default input info - MovementInputInfo movementInputInfo = new(BattleMovementInputType.None, false, new BattleGridPosition() { Row = -1, Col = -1 }, FPVector2.Zero, FPVector2.Zero); + MovementInputInfo movementInputInfo = new(BattleMovementInputType.None, false, new BattleGridPosition() { Row = -1, Col = -1 }, FPVector2.Zero); RotationInputInfo rotationInputInfo = new(false, FP._0); Vector2 clickPosition = Vector2.zero; @@ -263,8 +298,7 @@ private void PollInput(CallbackPollInput callback) if (abilityActivate) { - PlayerRef playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; - QuantumRunner.Default.Game.SendCommand(playerRef, new CommandActivateAbility()); + CommandSendActivateAbility(); } //{ create and set input @@ -275,9 +309,8 @@ private void PollInput(CallbackPollInput callback) DebugNumber = _inputDebugNumber, MovementInput = movementInputInfo.MovementInput, MovementDirectionIsNormalized = movementInputInfo.MovementDirectionIsNormalized, - MovementPositionTarget = movementInputInfo.MovementPositionTarget, - MovementPositionMove = movementInputInfo.MovementPositionMove, - MovementDirection = movementInputInfo.MovementDirection, + MovementGridPosition = movementInputInfo.MovementGridPosition, + MovementVector = movementInputInfo.MovementVector, RotationInput = rotationInputInfo.RotationInput, RotationValue = rotationInputInfo.RotationValue, }; @@ -331,7 +364,7 @@ private void PollInput(CallbackPollInput callback) /// Time since previous frame private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vector3 unityPosition, FP deltaTime) { - MovementInputInfo movementInputInfo = new(BattleMovementInputType.None, false, new BattleGridPosition() { Row = -1, Col = -1 }, FPVector2.Zero, FPVector2.Zero); + MovementInputInfo movementInputInfo = new(BattleMovementInputType.None, false, new BattleGridPosition() { Row = -1, Col = -1 }, FPVector2.Zero); switch (_movementInputType) { @@ -339,7 +372,7 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect if (mouseClick) { movementInputInfo.MovementInput = BattleMovementInputType.PositionTarget; - movementInputInfo.MovementPositionTarget = new() + movementInputInfo.MovementGridPosition = new() { Row = BattleGridManager.WorldYPositionToGridRow(FP.FromFloat_UNSAFE(unityPosition.z)), Col = BattleGridManager.WorldXPositionToGridCol(FP.FromFloat_UNSAFE(unityPosition.x)) @@ -351,7 +384,7 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect if (mouseDown) { movementInputInfo.MovementInput = BattleMovementInputType.PositionMove; - movementInputInfo.MovementPositionMove = new FPVector2 + movementInputInfo.MovementVector = new FPVector2 ( FP.FromFloat_UNSAFE(unityPosition.x), FP.FromFloat_UNSAFE(unityPosition.z) @@ -360,7 +393,7 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect else { movementInputInfo.MovementInput = BattleMovementInputType.None; - movementInputInfo.MovementPositionMove = FPVector2.Zero; + movementInputInfo.MovementVector = FPVector2.Zero; } break; @@ -388,8 +421,8 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect if (_swipePerformed) { Vector3 direction = unityPosition - _movementStartVector; - movementInputInfo.MovementDirection = new FPVector2(FP.FromFloat_UNSAFE(direction.x), FP.FromFloat_UNSAFE(direction.z)) / deltaTime; - movementInputInfo.MovementDirection *= FP.FromFloat_UNSAFE(_swipeSensitivity); + movementInputInfo.MovementVector = new FPVector2(FP.FromFloat_UNSAFE(direction.x), FP.FromFloat_UNSAFE(direction.z)) / deltaTime; + movementInputInfo.MovementVector *= FP.FromFloat_UNSAFE(_swipeSensitivity); } _movementStartVector = unityPosition; @@ -401,9 +434,9 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect { movementInputInfo.MovementInput = BattleMovementInputType.Direction; movementInputInfo.MovementDirectionIsNormalized = true; - movementInputInfo.MovementDirection = new FPVector2(FP.FromFloat_UNSAFE(_joystickMovementVector.x), FP.FromFloat_UNSAFE(_joystickMovementVector.y)); + movementInputInfo.MovementVector = new FPVector2(FP.FromFloat_UNSAFE(_joystickMovementVector.x), FP.FromFloat_UNSAFE(_joystickMovementVector.y)); - if (BattleGameViewController.LocalPlayerTeam == BattleTeamNumber.TeamBeta) movementInputInfo.MovementDirection *= -1; + if (BattleGameViewController.LocalPlayerTeam == BattleTeamNumber.TeamBeta) movementInputInfo.MovementVector *= -1; } break; } From 0d43e6f8c4c82bf2b81292c98909a23f1b10ca4b Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Tue, 28 Apr 2026 16:53:21 +0300 Subject: [PATCH 20/52] Battle: Changed commands to use BattleCommand class #1469 --- .../Scripts/Game/Commands/CommandGiveUp.cs | 17 +++------ .../Scripts/Player/Commands/BattleCommand.cs | 30 ++++++++++++++++ .../Player/Commands/BattleCommand.cs.meta | 11 ++++++ .../Player/Commands/CommandActivateAbility.cs | 17 ++------- .../Player/Commands/CommandSwapCharacter.cs | 16 ++------- .../Simulation/CommandSetup.User.cs | 6 ++-- .../Scripts/Game/BattleGameViewController.cs | 35 +++++++++---------- 7 files changed, 70 insertions(+), 62 deletions(-) create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs index 1666fd86d1..a1e4067dba 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs @@ -12,22 +12,13 @@ namespace Battle.QSimulation.Player /// /// A deterministic command that triggers the give up logic for a specific player. /// - public class CommandGiveUp : DeterministicCommand + public class BattleGiveUpQCommand : BattleCommand { - /// - /// Method that is required to be implemented but not needed here. - /// - public override void Serialize(BitStream stream) { } + public override Type BattleCommandType => Type.GiveUp; /// - /// Executes the give up logic for the specified player. + /// Method that is required to be implemented but not needed here. /// - /// - /// The current simulation frame - /// The player handle of the player initiating the command. - public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) - { - BattlePlayerQSystem.HandleGiveUp(f, playerHandle); - } + public override void Serialize(BitStream _) { } } } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs new file mode 100644 index 0000000000..66181f7668 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Runtime.CompilerServices; +using Photon.Deterministic; +using UnityEngine; + +namespace Quantum +{ + public abstract class BattleCommand : DeterministicCommand + { + public enum Type + { + None, + GiveUp, + ActivateAbility, + SwapCharacter + } + + public abstract Type BattleCommandType { get; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand commandData) + { + commandData = (BattleCommand)f.GetPlayerCommand(playerRef); + if (commandData == null) return Type.None; + return commandData.BattleCommandType; + } + } +} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta new file mode 100644 index 0000000000..9cb8edac05 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2a770b1a1492384dba77cd0746538a4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs index d66043f274..e2b4f561fa 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs @@ -12,23 +12,12 @@ namespace Battle.QSimulation.Player /// /// A deterministic command that triggers the ability activation for a specific player. /// - public unsafe class CommandActivateAbility : DeterministicCommand + public unsafe class BattleCharacterAbilityQCommand : BattleCommand { + public override Type BattleCommandType => Type.ActivateAbility; /// /// Method that is required to be implemented but not needed here. /// - public override void Serialize(BitStream stream) { } - - /// - /// Executes the ability activation logic by setting an input buffer for the specified player. - /// - /// - /// The current simulation frame. - /// The player handle of the player initiating the command. - public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) - { - BattlePlayerDataQComponent* playerData = f.Unsafe.GetPointer(playerHandle.SelectedCharacterEntity); - playerData->AbilityActivateBufferSec = FrameTimer.FromSeconds(f, FP._0_50); - } + public override void Serialize(BitStream _) { } } } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs index 508d5acd93..fc6407054a 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs @@ -12,8 +12,9 @@ namespace Battle.QSimulation.Player /// /// A deterministic command that triggers the character swapping logic for a specific player. /// - public class CommandSwapCharacter : DeterministicCommand + public class BattleCharacterSwapQCommand : BattleCommand { + public override Type BattleCommandType => Type.SwapCharacter; /// /// The number of the character the player is attempting to swap to. /// @@ -22,21 +23,10 @@ public class CommandSwapCharacter : DeterministicCommand /// /// Serializes the character number into the bitstream for network transmission. /// - /// The bitstream to write to or read from. + /// The bitstream to write to public override void Serialize(BitStream stream) { stream.Serialize(ref CharacterNumber); } - - /// - /// Executes the character swapping logic for the specified player. - /// - /// - /// The current simulation frame. - /// The player handle of the player initiating the command. - public void Execute(Frame f, BattlePlayerManager.PlayerHandle playerHandle) - { - BattlePlayerQSystem.HandleCharacterSwapping(f, playerHandle, CharacterNumber); - } } } diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index 4b4eef1561..2e1b248063 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -31,9 +31,9 @@ static partial void AddCommandFactoriesUser(ICollectionThe local player's BattlePlayerSlot.
public static BattlePlayerSlot LocalPlayerSlot { get; private set; } @@ -128,10 +132,7 @@ public static void AssignProjectileReference(GameObject projectileReference) ///
public void UiInputOnLocalPlayerGiveUp() { - _debugLogger.Log("Give up button pressed"); - PlayerRef playerRef; - playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; - QuantumRunner.Default.Game.SendCommand(playerRef, new CommandGiveUp()); + _playerInput.CommandSendGiveUp(); _debugLogger.Log("Give up button pressed, command sent"); } @@ -144,38 +145,33 @@ public void UiInputOnLocalPlayerGiveUp() /// The character number which the local player selected. public void UiInputOnCharacterSelected(int characterNumber) { - PlayerRef playerRef; - playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; - QuantumRunner.Default.Game.SendCommand(playerRef, new CommandSwapCharacter - { - CharacterNumber = characterNumber - }); + _playerInput.CommandSendSwapCharacter(characterNumber); _debugLogger.LogFormat("Character number {0} button pressed!", characterNumber); } /// /// Public method that gets called when local player gives movement joystick input. - /// Calls OnJoystickMovement method + /// Calls OnJoystickMovement method /// in _playerInput. /// /// /// The movement direction Vector2. public void UiInputOnJoystickMovement(Vector2 input) { - _playerInput.OnJoystickMovement(input); + _playerInput.QueueJoystickMovement(input); //Debug.Log($"Move joystick input {input}"); } /// /// Public method that gets called when local player gives rotation joystick input. - /// Calls OnJoystickRotation method + /// Calls OnJoystickRotation method /// in _playerInput. /// /// /// The rotation input as float. public void UiInputOnJoystickRotation(float input) { - _playerInput.OnJoystickRotation(input); + _playerInput.QueueJoystickRotation(input); //Debug.Log($"Rotate joystick input {input}"); } @@ -345,13 +341,14 @@ private void QEventOnViewAllPlayersConnected(EventBattleViewAllPlayersConnected /// The event data. private void QEventOnViewInit(EventBattleViewInit e) { - PlayerRef playerRef = default; + QGame = QuantumRunner.Default.Game; + LocalPlayerRef = default; // Getting LocalPlayerSlot and LocalPlayerTeam if (Utils.TryGetQuantumFrame(out Frame f)) { - playerRef = QuantumRunner.Default.Game.GetLocalPlayers()[0]; - LocalPlayerSlot = BattlePlayerManager.PlayerHandle.GetSlot(f, playerRef); + LocalPlayerRef = QGame.GetLocalPlayers()[0]; + LocalPlayerSlot = BattlePlayerManager.PlayerHandle.GetSlot(f, LocalPlayerRef); LocalPlayerTeam = BattlePlayerManager.PlayerHandle.GetTeamNumber(LocalPlayerSlot); } @@ -386,7 +383,7 @@ private void QEventOnViewInit(EventBattleViewInit e) BattleUiMovableElementData dataGiveUpButton = SettingsCarrier.Instance.GetBattleUiMovableElementData(BattleUiElementType.GiveUpButton); if (dataGiveUpButton != null) _uiController.GiveUpButtonHandler.MovableUiElement.SetData(dataGiveUpButton); - RuntimePlayer localPlayerData = f.GetPlayerData(playerRef); + RuntimePlayer localPlayerData = f.GetPlayerData(LocalPlayerRef); RuntimePlayer localTeammateData = f.GetPlayerData(BattlePlayerManager.PlayerHandle.GetTeammateHandle(f, LocalPlayerSlot).PlayerRef); // Setting local player info @@ -709,7 +706,7 @@ private void Update() if (Utils.TryGetQuantumFrame(out Frame frame)) { // Try to retrieve the singleton entity reference for the GameSession - if (frame.TryGetSingletonEntityRef(out var entity) == false) + if (frame.TryGetSingletonEntityRef(out EntityRef _) == false) { // If the GameSession singleton is not found, display an error message _debugLogger.Error(frame, "GameSession singleton not found"); From 796942c780dd5cb213c73781d1fed027e8e3a526 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:03:41 +0300 Subject: [PATCH 21/52] Battle: Renamed and moved Command script files #1469 --- .../Scripts/{Player/Commands => Game}/BattleCommand.cs | 0 .../{Player/Commands => Game}/BattleCommand.cs.meta | 0 .../Simulation/Battle/Scripts/Game/Commands.meta | 8 -------- ...tivateAbility.cs => BattleCharacterAbilityQCommand.cs} | 0 ...ity.cs.meta => BattleCharacterAbilityQCommand.cs.meta} | 0 ...andSwapCharacter.cs => BattleCharacterSwapQCommand.cs} | 0 ...racter.cs.meta => BattleCharacterSwapQCommand.cs.meta} | 0 .../Commands/BattleGiveUpQCommand.cs} | 0 .../Commands/BattleGiveUpQCommand.cs.meta} | 0 9 files changed, 8 deletions(-) rename Assets/QuantumUser/Simulation/Battle/Scripts/{Player/Commands => Game}/BattleCommand.cs (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/{Player/Commands => Game}/BattleCommand.cs.meta (100%) delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta rename Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/{CommandActivateAbility.cs => BattleCharacterAbilityQCommand.cs} (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/{CommandActivateAbility.cs.meta => BattleCharacterAbilityQCommand.cs.meta} (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/{CommandSwapCharacter.cs => BattleCharacterSwapQCommand.cs} (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/{CommandSwapCharacter.cs.meta => BattleCharacterSwapQCommand.cs.meta} (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/{Game/Commands/CommandGiveUp.cs => Player/Commands/BattleGiveUpQCommand.cs} (100%) rename Assets/QuantumUser/Simulation/Battle/Scripts/{Game/Commands/CommandGiveUp.cs.meta => Player/Commands/BattleGiveUpQCommand.cs.meta} (100%) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs rename to Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs.meta similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCommand.cs.meta rename to Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta deleted file mode 100644 index 06557d59e1..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4014e72160e714b4ba8b85880650d6ba -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandActivateAbility.cs.meta rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/CommandSwapCharacter.cs.meta rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Game/Commands/CommandGiveUp.cs.meta rename to Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta From cfb1bd15ecbe4de9e3cad61f08861753df4b5ad9 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:04:14 +0300 Subject: [PATCH 22/52] CommandSetup.User.cs: Updated documentation #1469 --- Assets/QuantumUser/Simulation/CommandSetup.User.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index 2e1b248063..decd68027c 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -13,7 +13,7 @@ namespace Quantum { /// - /// Contains all project-specific commands. %Quantum invokes the generated side of this partial class at startup. + /// Contains all project-specific commands. /// public static partial class DeterministicCommandSetup { From a085826ec50831d0a9d65ab9341d8ec4d288e8fc Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:30:28 +0300 Subject: [PATCH 23/52] Battle: Updated usings and documentation #1469 --- .../Battle/Scripts/Game/BattleCommand.cs | 7 ++----- .../Commands/BattleCharacterAbilityQCommand.cs | 8 +++++--- .../Player/Commands/BattleCharacterSwapQCommand.cs | 8 +++++--- .../Player/Commands/BattleGiveUpQCommand.cs | 8 +++++--- Assets/QuantumUser/Simulation/CommandSetup.User.cs | 14 +++++++------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs index 66181f7668..7403535cab 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs @@ -1,11 +1,8 @@ -using System.Collections; -using System.Collections.Generic; -using System.Data; using System.Runtime.CompilerServices; using Photon.Deterministic; -using UnityEngine; +using Quantum; -namespace Quantum +namespace Battle.QSimulation.Game { public abstract class BattleCommand : DeterministicCommand { diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs index e2b4f561fa..ddc2760c00 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs @@ -1,12 +1,14 @@ -/// @file CommandActivateAbility.cs +/// @file BattleCharacterAbilityQCommand.cs /// -/// A deterministic command that triggers the ability activation for a specific player. +/// Contains @cref{Battle.QSimulation.Player,BattleCharacterAbilityQCommand} class which contains a deterministic command that triggers the ability activation for a specific player. /// // Quantum usings -using Quantum; using Photon.Deterministic; +// Battle QSimulation usings +using Battle.QSimulation.Game; + namespace Battle.QSimulation.Player { /// diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs index fc6407054a..0dcc96b97f 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs @@ -1,12 +1,14 @@ -/// @file CommandSwapCharacter.cs +/// @file BattleCharacterSwapQCommand.cs /// -/// A deterministic command that triggers the character swapping logic for a specific player. +/// Contains @cref{Battle.QSimulation.Player,BattleCharacterSwapQCommand} class which contains a deterministic command that triggers the character swapping logic for a specific player. /// // Quantum usings -using Quantum; using Photon.Deterministic; +// Battle QSimulation usings +using Battle.QSimulation.Game; + namespace Battle.QSimulation.Player { /// diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs index a1e4067dba..ba6ea5f6d4 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs @@ -1,12 +1,14 @@ -/// @file CommandGiveUp.cs +/// @file BattleGiveUpQCommand.cs /// -/// A deterministic command that triggers the give up logic for a specific player. +/// Contains @cref{Battle.QSimulation.Player,BattleGiveUpQCommand} class which contains a deterministic command that triggers the give up logic for a specific player. /// // Quantum usings -using Quantum; using Photon.Deterministic; +// Battle QSimulation usings +using Battle.QSimulation.Game; + namespace Battle.QSimulation.Player { /// diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index decd68027c..3987a5dbb6 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -1,15 +1,17 @@ /// @file CommandSetup.User.cs /// -/// Registers the game's custom deterministic commands with the %Quantum simulation. +/// Contains @cref{Quantum,DeterministicCommandSetup} class contains all project-specific commands. /// // System usings using System.Collections.Generic; -using Battle.QSimulation.Player; // Quantum usings using Photon.Deterministic; +// Battle QSimulation usings +using Battle.QSimulation.Player; + namespace Quantum { /// @@ -19,8 +21,9 @@ public static partial class DeterministicCommandSetup { /// /// Registers the game's custom instances with - /// the %Quantum command system. Called once by the framework during simulation - /// initialization. Should not be called manually. + /// the %Quantum command system. Called once during the simulation initialization. + /// @warning + /// This method should only be called by Quantum. /// /// /// The command factory collection to register commands into @@ -28,9 +31,6 @@ public static partial class DeterministicCommandSetup /// The simulation configuration for the current session static partial void AddCommandFactoriesUser(ICollection factories, RuntimeConfig gameConfig, SimulationConfig simulationConfig) { - // Add or remove commands to the collection. - // factories.Add(new NavMeshAgentTestSystem.RunTest()); - factories.Add(new BattleGiveUpQCommand()); factories.Add(new BattleCharacterSwapQCommand()); factories.Add(new BattleCharacterAbilityQCommand()); From 6e2c15d8aaaa24372fcd295aafd33eafcd67c506 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:51:20 +0300 Subject: [PATCH 24/52] Battle: Moved all commands to BattleCommands.cs file #1469 --- .../Battle/Scripts/Game/BattleCommand.cs | 27 ------ .../Battle/Scripts/Game/BattleCommands.cs | 87 +++++++++++++++++++ ...Command.cs.meta => BattleCommands.cs.meta} | 0 .../Battle/Scripts/Player/Commands.meta | 8 -- .../BattleCharacterAbilityQCommand.cs | 25 ------ .../BattleCharacterAbilityQCommand.cs.meta | 11 --- .../Commands/BattleCharacterSwapQCommand.cs | 34 -------- .../BattleCharacterSwapQCommand.cs.meta | 11 --- .../Player/Commands/BattleGiveUpQCommand.cs | 26 ------ .../Commands/BattleGiveUpQCommand.cs.meta | 11 --- 10 files changed, 87 insertions(+), 153 deletions(-) delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs create mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs rename Assets/QuantumUser/Simulation/Battle/Scripts/Game/{BattleCommand.cs.meta => BattleCommands.cs.meta} (100%) delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs delete mode 100644 Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs deleted file mode 100644 index 7403535cab..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Runtime.CompilerServices; -using Photon.Deterministic; -using Quantum; - -namespace Battle.QSimulation.Game -{ - public abstract class BattleCommand : DeterministicCommand - { - public enum Type - { - None, - GiveUp, - ActivateAbility, - SwapCharacter - } - - public abstract Type BattleCommandType { get; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand commandData) - { - commandData = (BattleCommand)f.GetPlayerCommand(playerRef); - if (commandData == null) return Type.None; - return commandData.BattleCommandType; - } - } -} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs new file mode 100644 index 0000000000..1c6a35bd23 --- /dev/null +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -0,0 +1,87 @@ +/// @file BattleCommands.cs +/// +/// Contains Battlecommand class and all battle commands +/// + +// System usings +using System.Runtime.CompilerServices; + +// Quantum usings +using Quantum; +using Photon.Deterministic; + +// Battle QSimulation usings +using Battle.QSimulation.Game; + +namespace Battle.QSimulation.Game +{ + public abstract class BattleCommand : DeterministicCommand + { + public enum Type + { + None, + GiveUp, + ActivateAbility, + SwapCharacter + } + + public abstract Type BattleCommandType { get; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand commandData) + { + commandData = (BattleCommand)f.GetPlayerCommand(playerRef); + if (commandData == null) return Type.None; + return commandData.BattleCommandType; + } + } +} + +namespace Battle.QSimulation.Player +{ + /// + /// A deterministic command that triggers the ability activation for a specific player. + /// + public class BattleCharacterAbilityQCommand : BattleCommand + { + public override Type BattleCommandType => Type.ActivateAbility; + /// + /// Method that is required to be implemented but not needed here. + /// + public override void Serialize(BitStream _) { } + } + + /// + /// A deterministic command that triggers the character swapping logic for a specific player. + /// + public class BattleCharacterSwapQCommand : BattleCommand + { + public override Type BattleCommandType => Type.SwapCharacter; + /// + /// The number of the character the player is attempting to swap to. + /// + public int CharacterNumber; + + /// + /// Serializes the character number into the bitstream for network transmission. + /// + /// The bitstream to write to + public override void Serialize(BitStream stream) + { + stream.Serialize(ref CharacterNumber); + } + } + + /// + /// A deterministic command that triggers the give up logic for a specific player. + /// + public class BattleGiveUpQCommand : BattleCommand + { + public override Type BattleCommandType => Type.GiveUp; + + /// + /// Method that is required to be implemented but not needed here. + /// + public override void Serialize(BitStream _) { } + } +} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs.meta similarity index 100% rename from Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommand.cs.meta rename to Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs.meta diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta deleted file mode 100644 index 0bfa8dc0d6..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f035f2d0828dae84bbfb95c08032e2a8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs deleted file mode 100644 index ddc2760c00..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs +++ /dev/null @@ -1,25 +0,0 @@ -/// @file BattleCharacterAbilityQCommand.cs -/// -/// Contains @cref{Battle.QSimulation.Player,BattleCharacterAbilityQCommand} class which contains a deterministic command that triggers the ability activation for a specific player. -/// - -// Quantum usings -using Photon.Deterministic; - -// Battle QSimulation usings -using Battle.QSimulation.Game; - -namespace Battle.QSimulation.Player -{ - /// - /// A deterministic command that triggers the ability activation for a specific player. - /// - public unsafe class BattleCharacterAbilityQCommand : BattleCommand - { - public override Type BattleCommandType => Type.ActivateAbility; - /// - /// Method that is required to be implemented but not needed here. - /// - public override void Serialize(BitStream _) { } - } -} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta deleted file mode 100644 index 416448cc7c..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterAbilityQCommand.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 76ada46f5d113e5498b4cc4d41cb13a8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs deleted file mode 100644 index 0dcc96b97f..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs +++ /dev/null @@ -1,34 +0,0 @@ -/// @file BattleCharacterSwapQCommand.cs -/// -/// Contains @cref{Battle.QSimulation.Player,BattleCharacterSwapQCommand} class which contains a deterministic command that triggers the character swapping logic for a specific player. -/// - -// Quantum usings -using Photon.Deterministic; - -// Battle QSimulation usings -using Battle.QSimulation.Game; - -namespace Battle.QSimulation.Player -{ - /// - /// A deterministic command that triggers the character swapping logic for a specific player. - /// - public class BattleCharacterSwapQCommand : BattleCommand - { - public override Type BattleCommandType => Type.SwapCharacter; - /// - /// The number of the character the player is attempting to swap to. - /// - public int CharacterNumber; - - /// - /// Serializes the character number into the bitstream for network transmission. - /// - /// The bitstream to write to - public override void Serialize(BitStream stream) - { - stream.Serialize(ref CharacterNumber); - } - } -} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta deleted file mode 100644 index 52f5aedf90..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleCharacterSwapQCommand.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5774abcd7250818408c2eade11ad5548 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs deleted file mode 100644 index ba6ea5f6d4..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs +++ /dev/null @@ -1,26 +0,0 @@ -/// @file BattleGiveUpQCommand.cs -/// -/// Contains @cref{Battle.QSimulation.Player,BattleGiveUpQCommand} class which contains a deterministic command that triggers the give up logic for a specific player. -/// - -// Quantum usings -using Photon.Deterministic; - -// Battle QSimulation usings -using Battle.QSimulation.Game; - -namespace Battle.QSimulation.Player -{ - /// - /// A deterministic command that triggers the give up logic for a specific player. - /// - public class BattleGiveUpQCommand : BattleCommand - { - public override Type BattleCommandType => Type.GiveUp; - - /// - /// Method that is required to be implemented but not needed here. - /// - public override void Serialize(BitStream _) { } - } -} diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta deleted file mode 100644 index de36029d29..0000000000 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/Commands/BattleGiveUpQCommand.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 01220694059157d46a165f1b29c1993e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 3d88780dbc42f703a3aa6efa878618e7aed03e56 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:51:46 +0300 Subject: [PATCH 25/52] BattleUiGiveUpButtonHandler.cs: Updated give up button text #1469 --- .../Battle/Scripts/UI/Handler/BattleUiGiveUpButtonHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/UI/Handler/BattleUiGiveUpButtonHandler.cs b/Assets/QuantumUser/View/Battle/Scripts/UI/Handler/BattleUiGiveUpButtonHandler.cs index 40143fbf83..3930aeec27 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/UI/Handler/BattleUiGiveUpButtonHandler.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/UI/Handler/BattleUiGiveUpButtonHandler.cs @@ -167,7 +167,7 @@ private void UpdateInfoText() break; case ButtonInfoState.LocalGiveUp: - _giveUpButtonInfoText.text = "You want to give up"; + _giveUpButtonInfoText.text = "You want to give up\nClick to cancel"; break; case ButtonInfoState.TeammateGiveUp: From 734936648daa75e1bca6b2642e7b41a3f35c1ea8 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:52:50 +0300 Subject: [PATCH 26/52] BattlePlayerQSystem: Updated character swap and give up to continue if they happened #1469 --- .../Scripts/Player/BattlePlayerQSystem.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 9e555bcc73..ae4c69071a 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -183,7 +183,7 @@ public override void Update(Frame f) break; case BattleCommand.Type.GiveUp: - HandleGiveUp(f, playerHandle); + if (HandleGiveUp(f, playerHandle)) continue; break; case BattleCommand.Type.ActivateAbility: @@ -192,7 +192,7 @@ public override void Update(Frame f) case BattleCommand.Type.SwapCharacter: BattleCharacterSwapQCommand swapCharacterData = (BattleCharacterSwapQCommand)commandData; - HandleCharacterSwapping(f, playerHandle, swapCharacterData.CharacterNumber); + if (HandleCharacterSwapping(f, playerHandle, swapCharacterData.CharacterNumber)) continue; break; } @@ -298,7 +298,7 @@ private enum SoundEffectTypeCharacter /// /// Current simulation frame. /// Handle of the player. - private static void HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerSlot slot = playerHandle.Slot; BattleTeamNumber team = BattlePlayerManager.PlayerHandle.GetTeamNumber(playerHandle.Slot); @@ -306,7 +306,7 @@ private static void HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle if (!playerHandle.PlayerGiveUpState) { f.Events.BattleGiveUpStateChange(team, slot, BattleGiveUpStateUpdate.GiveUpVoteCancel); - return; + return false; } BattlePlayerManager.PlayerHandle teammateHandle = BattlePlayerManager.PlayerHandle.GetTeammateHandle(f, slot); @@ -320,7 +320,7 @@ private static void HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle { f.Events.BattleGiveUpStateChange(team, slot, BattleGiveUpStateUpdate.Abandoned); } - if (!teammateHandle.PlayerGiveUpState) return; + if (!teammateHandle.PlayerGiveUpState) return false; } else { @@ -336,7 +336,7 @@ private static void HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle }; BattleGameControlQSystem.OnGameOver(f, winningTeam); - return; + return true; } /// @@ -376,13 +376,13 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i /// /// Current simulation frame. /// Handle of the player. - private static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + private static bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; s_debugLogger.LogFormat(f, "({0}) Give up input received, new state: {1}", playerHandle.Slot, playerHandle.PlayerGiveUpState); - HandleGiveUpLogic(f, playerHandle); + return HandleGiveUpLogic(f, playerHandle); } /// @@ -392,19 +392,20 @@ private static void HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playe /// /// Current simulation frame. /// Handle of the player. - public static void HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) + public static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { s_debugLogger.LogFormat(f, "({0}) Character swap input received", playerHandle.Slot); if (!playerHandle.AllowCharacterSwapping) { s_debugLogger.LogFormat(f, "({0}) Character swap input rejected, as AllowCharacterSwapping == false", playerHandle.Slot); - return; + return false; } s_debugLogger.LogFormat(f, "({0}) Swapping to character number: {1}", playerHandle.Slot, playerCharacterNumber); BattlePlayerManager.SpawnPlayer(f, playerHandle.Slot, playerCharacterNumber); + return true; } /// From 3da23b822a206452659ab2db3359b4fc6cb9e268 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:56:50 +0300 Subject: [PATCH 27/52] BattlePlayerQSystem.cs: Updated documentation #1469 --- .../Battle/Scripts/Player/BattlePlayerQSystem.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index ae4c69071a..71efc5c35a 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -146,10 +146,10 @@ public static void OnProjectileHitPlayerShield(Frame f, BattleCollisionQSystem.P /// /// Update method has been split into subprocesses.
/// see @cref{BattlePlayerQSystem,GetInput}
- /// see @cref{Battle.QSimulation.Player,CommandGiveUp}
- /// see @cref{Battle.QSimulation.Player,CommandSwapCharacter}
+ /// see @cref{Battle.QSimulation.Player,BattleGiveUpQCommand}
+ /// see @cref{Battle.QSimulation.Player,BattleCharacterSwapQCommand}
/// see @cref{BattlePlayerQSystem,HandleOutOfPlay}
- /// see @cref{Battle.QSimulation.Player,CommandActivateAbility}
+ /// see @cref{Battle.QSimulation.Player,BattleCharacterAbilityQCommand}
/// see @cref{BattlePlayerQSystem,HandleInPlay} /// /// Current simulation frame @@ -298,6 +298,8 @@ private enum SoundEffectTypeCharacter /// /// Current simulation frame. /// Handle of the player. + /// + /// True if the give up input was processed. private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerSlot slot = playerHandle.Slot; @@ -376,6 +378,8 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i /// /// Current simulation frame. /// Handle of the player. + /// + /// True if the give up input was processed. private static bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; @@ -392,6 +396,8 @@ private static bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playe /// /// Current simulation frame. /// Handle of the player. + /// + /// True if character swapped. public static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { s_debugLogger.LogFormat(f, "({0}) Character swap input received", playerHandle.Slot); From b86b250bad3662a8e7bd2492e7e4966373b8c814 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:57:05 +0300 Subject: [PATCH 28/52] BattleCommands.cs: Updated documentation #1469 --- .../Battle/Scripts/Game/BattleCommands.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index 1c6a35bd23..6c0ee7f434 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -15,6 +15,10 @@ namespace Battle.QSimulation.Game { + /// + /// Abstract base class for all deterministic battle commands.
+ /// All new commands must be added to the @cref{Type} enum. + ///
public abstract class BattleCommand : DeterministicCommand { public enum Type @@ -27,6 +31,17 @@ public enum Type public abstract Type BattleCommandType { get; } + /// + /// Gets the command's @cref{Type} and data + /// + /// + /// The current simulation frame. + /// Reference to the player who sent the command + /// Contains the command, or null if there isn't one + /// + /// + /// The of the command, or if no command was found. + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand commandData) { From e36701adbddd4cc71e0a890b2e2a96b2fd86bf5c Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:50:19 +0300 Subject: [PATCH 29/52] Battle: Added concept page for commands #1469 --- .../pages/1-concepts-.md | 1 + .../pages/1-concepts-commands.md | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-.md index c81d3c6c0a..ff4c23ef8e 100644 --- a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-.md +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-.md @@ -1,3 +1,4 @@ # Concepts {#page-concepts} @bigtext{@subpage page-concepts-player} +@bigtext{@subpage page-concepts-commands} \ No newline at end of file diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md new file mode 100644 index 0000000000..ab3f6a0d74 --- /dev/null +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md @@ -0,0 +1,21 @@ +## Custom %Quantum Commands {#page-concepts-commands} + +
+ +### Custom %Quantum Commands {#page-concepts-commands} + +@ref BattleCommands.cs contains @ref Battle.QSimulation.Game.BattleCommand "BattleCommand" class That should be used to make all custom %Quantum commands in battle. +It also contains all the custom commands. + +All new commands must be added to @ref CommandSetup.User.cs and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the file. + +**C# code example** +```cs +public class BattleExampleQCommand : BattleCommand +{ + public override Type BattleCommandType => Type.Example; + + public override void Serialize(BitStream stream) { //... } + // ... +} +``` \ No newline at end of file From e43b48b64ab98b045874e367b315c2fc37495c58 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:58:36 +0300 Subject: [PATCH 30/52] Battle: Updated Custom Quantum Commands concept page #1469 --- .../pages/1-concepts-commands.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md index ab3f6a0d74..a93cb71ac1 100644 --- a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md @@ -4,10 +4,12 @@ ### Custom %Quantum Commands {#page-concepts-commands} -@ref BattleCommands.cs contains @ref Battle.QSimulation.Game.BattleCommand "BattleCommand" class That should be used to make all custom %Quantum commands in battle. +@ref BattleCommands.cs contains @ref Battle.QSimulation.Game.BattleCommand "BattleCommand" class that should be used to make all custom %Quantum commands in battle. It also contains all the custom commands. -All new commands must be added to @ref CommandSetup.User.cs and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the file. +All new commands must be added to @ref CommandSetup.User.cs and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. + +See [Quantum Commands documentation🡵](https://doc.photonengine.com/quantum/current/manual/commands) for more info. **C# code example** ```cs @@ -15,7 +17,10 @@ public class BattleExampleQCommand : BattleCommand { public override Type BattleCommandType => Type.Example; - public override void Serialize(BitStream stream) { //... } - // ... + public override void Serialize(BitStream stream) + { + //... + } + // ... } ``` \ No newline at end of file From ac9b9484fd581e05f1bf4b3cb86c974a1582e800 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:59:13 +0300 Subject: [PATCH 31/52] Battle: Removed PlayerRef when sending commands #1469 --- .../Battle/Scripts/Game/BattleGameViewController.cs | 11 +++++------ .../View/Battle/Scripts/Player/BattlePlayerInput.cs | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index 55a08c83b7..42ee2e4ca3 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -87,10 +87,9 @@ public class BattleGameViewController : QuantumCallbacks #region Public - Static Properties + /// The Quantum game public static QuantumGame QGame { get; private set; } - public static PlayerRef LocalPlayerRef { get; private set; } - /// The local player's BattlePlayerSlot. public static BattlePlayerSlot LocalPlayerSlot { get; private set; } @@ -342,13 +341,13 @@ private void QEventOnViewAllPlayersConnected(EventBattleViewAllPlayersConnected private void QEventOnViewInit(EventBattleViewInit e) { QGame = QuantumRunner.Default.Game; - LocalPlayerRef = default; + PlayerRef localPlayerRef = default; // Getting LocalPlayerSlot and LocalPlayerTeam if (Utils.TryGetQuantumFrame(out Frame f)) { - LocalPlayerRef = QGame.GetLocalPlayers()[0]; - LocalPlayerSlot = BattlePlayerManager.PlayerHandle.GetSlot(f, LocalPlayerRef); + localPlayerRef = QGame.GetLocalPlayers()[0]; + LocalPlayerSlot = BattlePlayerManager.PlayerHandle.GetSlot(f, localPlayerRef); LocalPlayerTeam = BattlePlayerManager.PlayerHandle.GetTeamNumber(LocalPlayerSlot); } @@ -383,7 +382,7 @@ private void QEventOnViewInit(EventBattleViewInit e) BattleUiMovableElementData dataGiveUpButton = SettingsCarrier.Instance.GetBattleUiMovableElementData(BattleUiElementType.GiveUpButton); if (dataGiveUpButton != null) _uiController.GiveUpButtonHandler.MovableUiElement.SetData(dataGiveUpButton); - RuntimePlayer localPlayerData = f.GetPlayerData(LocalPlayerRef); + RuntimePlayer localPlayerData = f.GetPlayerData(localPlayerRef); RuntimePlayer localTeammateData = f.GetPlayerData(BattlePlayerManager.PlayerHandle.GetTeammateHandle(f, LocalPlayerSlot).PlayerRef); // Setting local player info diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 45955edf9f..5877b2578c 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -53,7 +53,7 @@ public class BattlePlayerInput : MonoBehaviour ///
public void CommandSendGiveUp() { - BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleGiveUpQCommand()); + BattleGameViewController.QGame.SendCommand(new BattleGiveUpQCommand()); } /// @@ -63,7 +63,7 @@ public void CommandSendGiveUp() /// The character number of the character to swap to public void CommandSendSwapCharacter(int characterNumber) { - BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleCharacterSwapQCommand + BattleGameViewController.QGame.SendCommand(new BattleCharacterSwapQCommand { CharacterNumber = characterNumber }); @@ -74,7 +74,7 @@ public void CommandSendSwapCharacter(int characterNumber) /// public void CommandSendActivateAbility() { - BattleGameViewController.QGame.SendCommand(BattleGameViewController.LocalPlayerRef, new BattleCharacterAbilityQCommand()); + BattleGameViewController.QGame.SendCommand(new BattleCharacterAbilityQCommand()); } /// @} From 81e12895fab5c4f4a3e0ff3314f8fd76ca4c553e Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:59:51 +0300 Subject: [PATCH 32/52] CommandSetup.User.cs: Updated usings #1469 --- Assets/QuantumUser/Simulation/CommandSetup.User.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/CommandSetup.User.cs b/Assets/QuantumUser/Simulation/CommandSetup.User.cs index 3987a5dbb6..6088f323e8 100644 --- a/Assets/QuantumUser/Simulation/CommandSetup.User.cs +++ b/Assets/QuantumUser/Simulation/CommandSetup.User.cs @@ -10,7 +10,7 @@ using Photon.Deterministic; // Battle QSimulation usings -using Battle.QSimulation.Player; +using Battle.QSimulation.Game; namespace Quantum { From c603e5193681d7f957d4605f5d1bf57ba23a587b Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 30 Apr 2026 17:00:23 +0300 Subject: [PATCH 33/52] Battle: Updated documentation #1469 --- .../Battle/Scripts/Game/BattleCommands.cs | 12 +++--------- .../pages/1-concepts-commands.md | 17 +++++++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index 6c0ee7f434..8637e89659 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -10,9 +10,6 @@ using Quantum; using Photon.Deterministic; -// Battle QSimulation usings -using Battle.QSimulation.Game; - namespace Battle.QSimulation.Game { /// @@ -32,12 +29,12 @@ public enum Type public abstract Type BattleCommandType { get; } /// - /// Gets the command's @cref{Type} and data + /// Fetches a command for a and returns its . The out parameter contains the command itself. /// /// /// The current simulation frame. - /// Reference to the player who sent the command - /// Contains the command, or null if there isn't one + /// Reference to the player whose command is fetched. + /// Contains the command, or null if there isn't one. (out param) /// /// /// The of the command, or if no command was found. @@ -50,10 +47,7 @@ public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand co return commandData.BattleCommandType; } } -} -namespace Battle.QSimulation.Player -{ /// /// A deterministic command that triggers the ability activation for a specific player. /// diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md index a93cb71ac1..0e0200c793 100644 --- a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md @@ -1,15 +1,20 @@ ## Custom %Quantum Commands {#page-concepts-commands} -
+In %Battle we have a custom implementation of [Quantum Commands🡵](https://doc.photonengine.com/quantum/current/manual/commands) +All [{BattleQCommands}](#page-concepts-commands-battle-qcommand) extend the [{BattleCommand}](#page-concepts-commands-battle-command-base) base class. +@ref BattleCommands.cs contains all %Quantum commands in %Battle. +All new commands must be added to @ref CommandSetup.User.cs, and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. -### Custom %Quantum Commands {#page-concepts-commands} +### BattleCommand (base class) {#page-concepts-commands-battle-command-base} -@ref BattleCommands.cs contains @ref Battle.QSimulation.Game.BattleCommand "BattleCommand" class that should be used to make all custom %Quantum commands in battle. -It also contains all the custom commands. +@cref{Battle.QSimulation.Game,BattleCommand} contains @cref{Battle.QSimulation.Game.BattleCommand,Type} enum which contains all %Battle commands. +[{BattleQCommands}](#page-concepts-commands-battle-qcommand) and their type can be retrieved using @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" -All new commands must be added to @ref CommandSetup.User.cs and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. +[{BattleQCommands}](#page-concepts-commands-battle-qcommand) can be **Fetched** using @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" for handling the **command**. -See [Quantum Commands documentation🡵](https://doc.photonengine.com/quantum/current/manual/commands) for more info. +Use @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" to get data about the command. + +### BattleQCommand {#page-concepts-commands-battle-qcommand} **C# code example** ```cs From 620e6a542d7b86b5ad0a4aae43c001e3cd221b5f Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 4 May 2026 16:56:44 +0300 Subject: [PATCH 34/52] BattleCommands.cs: Updated documentation #1469 --- .../Battle/Scripts/Game/BattleCommands.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index 8637e89659..ab52166494 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -1,6 +1,8 @@ /// @file BattleCommands.cs /// -/// Contains Battlecommand class and all battle commands +/// Contains @cref{Battle.QSimulation.Game,BattleCommand} class and all battle commands +/// +/// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. /// // System usings @@ -15,14 +17,23 @@ namespace Battle.QSimulation.Game /// /// Abstract base class for all deterministic battle commands.
/// All new commands must be added to the @cref{Type} enum. + /// + /// See [{BattleCommand (base class)}](#page-concepts-commands-battle-qcommand) for more info. ///
public abstract class BattleCommand : DeterministicCommand { + /// + /// Type of the command. None if no command. + /// public enum Type { + /// No command None, + /// GiveUp, + /// ActivateAbility, + /// SwapCharacter } @@ -51,6 +62,8 @@ public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand co /// /// A deterministic command that triggers the ability activation for a specific player. /// + /// + /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleCharacterAbilityQCommand : BattleCommand { public override Type BattleCommandType => Type.ActivateAbility; @@ -63,6 +76,8 @@ public override void Serialize(BitStream _) { } /// /// A deterministic command that triggers the character swapping logic for a specific player. /// + /// + /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleCharacterSwapQCommand : BattleCommand { public override Type BattleCommandType => Type.SwapCharacter; @@ -84,6 +99,8 @@ public override void Serialize(BitStream stream) /// /// A deterministic command that triggers the give up logic for a specific player. /// + /// + /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleGiveUpQCommand : BattleCommand { public override Type BattleCommandType => Type.GiveUp; From 41ce61e0160d818c6b9f924ae6fee37b8947a0ca Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 4 May 2026 16:57:14 +0300 Subject: [PATCH 35/52] BattlePlayerQSystem.cs: Updated HandleGiveUp method #1469 --- .../Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 71efc5c35a..2541d8632f 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -380,7 +380,7 @@ private static void HandleSFXCharacter(Frame f, SoundEffectTypeCharacter type, i /// Handle of the player. /// /// True if the give up input was processed. - private static bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) + private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.PlayerGiveUpState = !playerHandle.PlayerGiveUpState; From 0b1389c086f9764c8acc36230b223c5e045470b0 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 4 May 2026 16:58:25 +0300 Subject: [PATCH 36/52] Battle: Updated commands concept page #1469 --- .../pages/1-concepts-commands.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md index 0e0200c793..6b7f43a3e7 100644 --- a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md @@ -3,19 +3,25 @@ In %Battle we have a custom implementation of [Quantum Commands🡵](https://doc.photonengine.com/quantum/current/manual/commands) All [{BattleQCommands}](#page-concepts-commands-battle-qcommand) extend the [{BattleCommand}](#page-concepts-commands-battle-command-base) base class. @ref BattleCommands.cs contains all %Quantum commands in %Battle. -All new commands must be added to @ref CommandSetup.User.cs, and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. ### BattleCommand (base class) {#page-concepts-commands-battle-command-base} @cref{Battle.QSimulation.Game,BattleCommand} contains @cref{Battle.QSimulation.Game.BattleCommand,Type} enum which contains all %Battle commands. -[{BattleQCommands}](#page-concepts-commands-battle-qcommand) and their type can be retrieved using @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" - [{BattleQCommands}](#page-concepts-commands-battle-qcommand) can be **Fetched** using @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" for handling the **command**. -Use @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" to get data about the command. - ### BattleQCommand {#page-concepts-commands-battle-qcommand} +To make a new command, add a new class in @ref BattleCommands.cs file. It should: +- Inherit from @cref{Battle.QSimulation.Game,BattleCommand} class +- Be named **%Battle(commandname)QCommand** +- Have a public override Type @ref %BattleCommandType => Type.(commandname) property +- Have a **public override void Serialize(Bitstream stream)** method + - Method can be empty if not needed, but it is required to be implemented + +The command does not necessarily have to do anything itself, since it can be done in the part of the code where receiving the command is polled. + +All new commands must be added to @ref CommandSetup.User.cs, and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. + **C# code example** ```cs public class BattleExampleQCommand : BattleCommand From 87d0a03db0dde083e2176f3b9c3675415661a493 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Mon, 4 May 2026 17:08:10 +0300 Subject: [PATCH 37/52] Battle: Fixed code links #1469 --- .../Simulation/Battle/Scripts/Game/BattleCommands.cs | 6 +++--- .../Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index ab52166494..bd69e7eaac 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -15,11 +15,11 @@ namespace Battle.QSimulation.Game { /// - /// Abstract base class for all deterministic battle commands.
- /// All new commands must be added to the @cref{Type} enum. + /// Abstract base class for all deterministic battle commands.
+ /// All new commands must be added to the enum. + ///
/// /// See [{BattleCommand (base class)}](#page-concepts-commands-battle-qcommand) for more info. - ///
public abstract class BattleCommand : DeterministicCommand { /// diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 2541d8632f..8dfcbee809 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -391,7 +391,7 @@ private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle /// /// Public helper method for handling character swapping.
- /// Called by @cref{Battle.QSimulation.Player,CommandSwapCharacter} + /// Called by ///
/// /// Current simulation frame. From 42e4cbab103ca491a5313aba3cfd6ec4799924a0 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 13:02:21 +0300 Subject: [PATCH 38/52] BattleCommands.cs: Updated Documentation #1467 --- .../Battle/Scripts/Game/BattleCommands.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index bd69e7eaac..78b6619820 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -66,7 +66,12 @@ public static Type GetCommand(Frame f, PlayerRef playerRef, out BattleCommand co /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleCharacterAbilityQCommand : BattleCommand { + /// + /// Gets the command Type associated with this command.
+ /// Always returns Type.ActivateAbility. + ///
public override Type BattleCommandType => Type.ActivateAbility; + /// /// Method that is required to be implemented but not needed here. /// @@ -80,7 +85,12 @@ public override void Serialize(BitStream _) { } /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleCharacterSwapQCommand : BattleCommand { + /// + /// Gets the command Type associated with this command.
+ /// Always returns Type.SwapCharacter. + ///
public override Type BattleCommandType => Type.SwapCharacter; + /// /// The number of the character the player is attempting to swap to. /// @@ -103,6 +113,10 @@ public override void Serialize(BitStream stream) /// See [{Custom Quantum Commands}](#page-concepts-commands) for more info. public class BattleGiveUpQCommand : BattleCommand { + /// + /// Gets the command Type associated with this command.
+ /// Always returns Type.GiveUp. + ///
public override Type BattleCommandType => Type.GiveUp; /// From 359dfe89caddfc6f686617ba01282c16de89a47e Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 14:29:29 +0300 Subject: [PATCH 39/52] Battle: Updated documentation #1467 --- .../pages/1-concepts-commands.md | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md index 6b7f43a3e7..793a5576ed 100644 --- a/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md +++ b/Doc/Doxygen/Battle/additional-documentation/pages/1-concepts-commands.md @@ -1,26 +1,29 @@ -## Custom %Quantum Commands {#page-concepts-commands} +# Custom %Quantum Commands {#page-concepts-commands} In %Battle we have a custom implementation of [Quantum Commands🡵](https://doc.photonengine.com/quantum/current/manual/commands) All [{BattleQCommands}](#page-concepts-commands-battle-qcommand) extend the [{BattleCommand}](#page-concepts-commands-battle-command-base) base class. -@ref BattleCommands.cs contains all %Quantum commands in %Battle. +@ref BattleCommands.cs contains all %Quantum commands in %Battle. -### BattleCommand (base class) {#page-concepts-commands-battle-command-base} +
+ +## BattleCommand (base class) {#page-concepts-commands-battle-command-base} @cref{Battle.QSimulation.Game,BattleCommand} contains @cref{Battle.QSimulation.Game.BattleCommand,Type} enum which contains all %Battle commands. [{BattleQCommands}](#page-concepts-commands-battle-qcommand) can be **Fetched** using @ref Battle.QSimulation.Game.BattleCommand.GetCommand "GetCommand" for handling the **command**. -### BattleQCommand {#page-concepts-commands-battle-qcommand} +
+ +## BattleQCommand {#page-concepts-commands-battle-qcommand} -To make a new command, add a new class in @ref BattleCommands.cs file. It should: -- Inherit from @cref{Battle.QSimulation.Game,BattleCommand} class -- Be named **%Battle(commandname)QCommand** -- Have a public override Type @ref %BattleCommandType => Type.(commandname) property -- Have a **public override void Serialize(Bitstream stream)** method - - Method can be empty if not needed, but it is required to be implemented +To make a new command, add a new class in @ref BattleCommands.cs file, which: +- Inherits from @cref{Battle.QSimulation.Game,BattleCommand} class +- Should be named **%Battle(commandname)QCommand** +- Has a a public override Type @ref %BattleCommandType => Type.(commandname) property +- Can have a **public override void Serialize(Bitstream stream)** method which is required if the command carries data -The command does not necessarily have to do anything itself, since it can be done in the part of the code where receiving the command is polled. +The command does not necessarily have to do anything itself, since it can be done in the part of the code where receiving the command is polled. -All new commands must be added to @ref CommandSetup.User.cs, and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum at the top of the @ref BattleCommands.cs file. +All new commands must be added to @ref CommandSetup.User.cs, and @ref Battle.QSimulation.Game.BattleCommand.Type "Type" enum in @ref Battle.QSimulation.Game.BattleCommand "BattleCommand" class at the top of the @ref BattleCommands.cs file. **C# code example** ```cs From 2f324d1865a4f21b6e5c2b99bebdfacd228fb9c8 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 14:30:08 +0300 Subject: [PATCH 40/52] BattleCommands.cs: Moved Serialize method to base class #1467 --- .../Simulation/Battle/Scripts/Game/BattleCommands.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs index 78b6619820..e15667b6b9 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs @@ -37,6 +37,8 @@ public enum Type SwapCharacter } + public override void Serialize(BitStream stream) { } + public abstract Type BattleCommandType { get; } /// @@ -71,11 +73,6 @@ public class BattleCharacterAbilityQCommand : BattleCommand /// Always returns Type.ActivateAbility. /// public override Type BattleCommandType => Type.ActivateAbility; - - /// - /// Method that is required to be implemented but not needed here. - /// - public override void Serialize(BitStream _) { } } /// @@ -118,10 +115,5 @@ public class BattleGiveUpQCommand : BattleCommand /// Always returns Type.GiveUp. /// public override Type BattleCommandType => Type.GiveUp; - - /// - /// Method that is required to be implemented but not needed here. - /// - public override void Serialize(BitStream _) { } } } From 60d099d564402a06a8f8ec1d5ca9396a66907e60 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 14:32:11 +0300 Subject: [PATCH 41/52] BattlePlayerQSystem.cs: Added check for preventing character swap to already selected character #1467 --- .../Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index b86c618e77..b2ea10a465 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -503,6 +503,8 @@ private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle /// True if character swapped. public static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { + if (playerCharacterNumber == playerHandle.SelectedCharacterNumber) return false; + s_debugLogger.LogFormat(f, "({0}) Character swap input received", playerHandle.Slot); if (!playerHandle.AllowCharacterSwapping) From df73707b77bff1508c5952355d006938ba7bcab9 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 15:22:05 +0300 Subject: [PATCH 42/52] BattlePlayerQSystem: Changed a method to public and updated documentation #1467 --- .../Battle/Scripts/Player/BattlePlayerQSystem.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index b2ea10a465..c76e30907a 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -196,10 +196,9 @@ public static void OnProjectileHitPlayerShield(Frame f, BattleCollisionQSystem.P /// /// Update method has been split into subprocesses.
/// see @cref{BattlePlayerQSystem,GetInput}
- /// see @cref{Battle.QSimulation.Player,BattleGiveUpQCommand}
- /// see @cref{Battle.QSimulation.Player,BattleCharacterSwapQCommand}
+ /// see @cref{BattlePlayerQSystem,HandleGiveUp}
+ /// see @cref{BattlePlayerQSystem,HandleCharacterSwapping}
/// see @cref{BattlePlayerQSystem,HandleOutOfPlay}
- /// see @cref{Battle.QSimulation.Player,BattleCharacterAbilityQCommand}
/// see @cref{BattlePlayerQSystem,HandleInPlay} /// /// Current simulation frame @@ -475,6 +474,7 @@ private static void HandleSFXCharacter(Frame f, BattlePlayerSlot slot, SoundEffe /// /// Private helper method for handling player input for giving up during the game play.
+ /// Subprocess of Update method. ///
/// /// Updates give up state and calls HandleGiveUpLogic method which handles the rest of the logic. @@ -493,7 +493,7 @@ private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle } /// - /// Public helper method for handling character swapping.
+ /// Private helper method for handling character swapping.
/// Called by ///
/// @@ -501,7 +501,7 @@ private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle /// Handle of the player. /// /// True if character swapped. - public static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) + private static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { if (playerCharacterNumber == playerHandle.SelectedCharacterNumber) return false; @@ -621,7 +621,7 @@ private void AbilityActivate(Frame f, BattlePlayerDataQComponent* playerData, Tr */ //} Ability test - s_debugLogger.Error(f, "ability activated"); + playerData->AbilityCooldownSec = FrameTimer.FromSeconds(f, FP._3); } } From f8f97ed456dfbea21ba3eca4f80f026e9a838c42 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 15:33:14 +0300 Subject: [PATCH 43/52] BattlePlayerQSystem.cs: Fixed indentation and updated documentation #1467 --- .../Battle/Scripts/Player/BattlePlayerQSystem.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index c76e30907a..612cc519bb 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -349,7 +349,7 @@ private enum SoundEffectTarget IsValid = true, MovementInput = BattleMovementInputType.None, MovementDirectionIsNormalized = false, - MovementGridPosition = new BattleGridPosition { Col = 0, Row = 0 }, + MovementGridPosition = new BattleGridPosition { Col = 0, Row = 0 }, MovementVector = FPVector2.Zero, RotationInput = false, RotationValue = FP._0, @@ -360,7 +360,7 @@ private enum SoundEffectTarget } /// - /// Private helper method for handling when a player gives up or abandons the match. + /// Private helper method for handling when a player wants to give up or has abandoned the match. /// /// /// Used by HandleGiveUpInput and HandlePlayerAbandoned. @@ -368,7 +368,7 @@ private enum SoundEffectTarget /// Current simulation frame. /// Handle of the player. /// - /// True if the give up input was processed. + /// True if all players on a team have given up. private static bool HandleGiveUpLogic(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { BattlePlayerSlot slot = playerHandle.Slot; @@ -473,7 +473,7 @@ private static void HandleSFXCharacter(Frame f, BattlePlayerSlot slot, SoundEffe } /// - /// Private helper method for handling player input for giving up during the game play.
+ /// Private helper method for handling player give up command.
/// Subprocess of Update method. ///
/// @@ -482,7 +482,7 @@ private static void HandleSFXCharacter(Frame f, BattlePlayerSlot slot, SoundEffe /// Current simulation frame. /// Handle of the player. /// - /// True if the give up input was processed. + /// True if all players on a team have given up. private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle) { playerHandle.GiveUpState = !playerHandle.GiveUpState; @@ -494,14 +494,14 @@ private bool HandleGiveUp(Frame f, BattlePlayerManager.PlayerHandle playerHandle /// /// Private helper method for handling character swapping.
- /// Called by + /// Subprocess of Update method. ///
/// /// Current simulation frame. /// Handle of the player. /// - /// True if character swapped. - private static bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) + /// True if character was swapped. + private bool HandleCharacterSwapping(Frame f, BattlePlayerManager.PlayerHandle playerHandle, int playerCharacterNumber) { if (playerCharacterNumber == playerHandle.SelectedCharacterNumber) return false; From 302f4f7b74e93a6d711553624c4ec87fc4424fd8 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 15:47:19 +0300 Subject: [PATCH 44/52] BattlePlayerBotController: Fixed indentation #1467 --- .../Battle/Scripts/Player/BattlePlayerBotController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs index a668f2ee42..0679345583 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerBotController.cs @@ -167,7 +167,7 @@ public static void GetBotInput(Frame f, bool isInPlay, BattlePlayerDataQComponen IsValid = true, MovementInput = movementInput, MovementDirectionIsNormalized = false, - MovementGridPosition = predictedGridPosition, + MovementGridPosition = predictedGridPosition, MovementVector = FPVector2.Zero, RotationInput = false, RotationValue = FP._0 From 3559a4430382045012df8457977fa26a7dadad94 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 15:47:39 +0300 Subject: [PATCH 45/52] BattleGameViewController.cs: Updated documentation #1467 --- .../View/Battle/Scripts/Game/BattleGameViewController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index bd9f51652a..c1f34fd8de 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -156,7 +156,7 @@ public void UiInputOnCharacterSelected(int characterNumber) /// /// Public method that gets called when local player gives movement joystick input. - /// Calls OnJoystickMovement method + /// Calls QueueJoystickMovement method /// in _playerInput. /// /// @@ -169,7 +169,7 @@ public void UiInputOnJoystickMovement(BattleJoystickState state, Vector2 value) /// /// Public method that gets called when local player gives rotation joystick input. - /// Calls OnJoystickRotation method + /// Calls QueueJoystickRotation method /// in _playerInput. /// /// From a9c88b64d8c6956c868be22ed8d6082a5d0f73e5 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 21 May 2026 16:25:39 +0300 Subject: [PATCH 46/52] BattlePlayerInput.cs: Disabled DEBUG_INPUT_TYPE_OVERRIDE #1467 --- .../QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index a80c9bc78a..8195329d19 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -5,7 +5,7 @@ /// Input is processed and compiled into an input struct, which is passed over to the Quantum simulation when polled by Quantum. ///
-#define DEBUG_INPUT_TYPE_OVERRIDE +//#define DEBUG_INPUT_TYPE_OVERRIDE // Unity usings using UnityEngine; From f598f993c7bcfa1cc1f6ff23e556f8a8fce74318 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 21 May 2026 16:27:13 +0300 Subject: [PATCH 47/52] BattlePlayerInput.cs: Removed unnecessary using #1467 --- .../QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 8195329d19..48c06096ea 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -22,7 +22,6 @@ // Battle QSimulation usings using Battle.QSimulation; using Battle.QSimulation.Game; -using Battle.QSimulation.Player; // Battle View usings using Battle.View.Game; From bd2201f134d9eb2c92b58f925b3298166962ddcc Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 21 May 2026 16:38:04 +0300 Subject: [PATCH 48/52] BattlePlayerInput.cs: Improved documenton #1467 --- .../Battle/Scripts/Player/BattlePlayerInput.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 48c06096ea..59042ac5fe 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -43,8 +43,8 @@ namespace Battle.View.Player public class BattlePlayerInput : MonoBehaviour { /// @name Command input methods - /// Command input methods are called by BattleGameViewController when the player gives a %UI input. These methods shouldn't be called any other way. - /// These inputs are sent to Quantum as commands. + /// Command input methods are called by @cref{BattleGameViewController} when the player gives a %UI input. These methods shouldn't be called any other way.
+ /// These inputs are sent to %Quantum as commands. /// @{ /// @@ -79,8 +79,8 @@ public void CommandSendActivateAbility() /// @} /// @name Queued input methods - /// Queued input methods are called by BattleGameViewController when the player gives a %UI input. These methods shouldn't be called any other way. - /// These inputs are queued for next time that Quantum polls input. + /// Queued input methods are called by @cref{BattleGameViewController} when the player gives a %UI input. These methods shouldn't be called any other way.
+ /// These inputs are queued for next time that %Quantum polls input. /// @{ /// @@ -88,7 +88,7 @@ public void CommandSendActivateAbility() /// /// /// of the joystick. (unused) - /// The input value of the movement joystick as Vector2. + /// Value of the joystick as Vector2. public void QueueJoystickMovement(BattleJoystickState state, Vector2 value) { _joystickMovementVector = value; @@ -99,7 +99,7 @@ public void QueueJoystickMovement(BattleJoystickState state, Vector2 value) ///
/// /// of the joystick. (unused) - /// The input value of the rotation joystick as float. + /// Value of the joystick as float. public void QueueJoystickRotation(BattleJoystickState state, float value) { _joystickRotationValue = value; @@ -109,8 +109,8 @@ public void QueueJoystickRotation(BattleJoystickState state, float value) /// Called when player interacts with the special joystick ///
/// - /// of the joystick. - /// Value of the joystick input as Vector2. + /// of the joystick. + /// Value of the joystick as Vector2. public void OnJoystickSpecial(BattleJoystickState state, Vector2 value) { _joystickSpecialState = state; From 7b7365c8716bec10bc5d1f99df5a7b31cfef0828 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Thu, 21 May 2026 16:47:49 +0300 Subject: [PATCH 49/52] BattlePlayerInput.cs: Renamed OnJoystickSpecial to QueueJoystickSpecial #1467 --- .../QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index 59042ac5fe..e3ca6b3cfe 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -111,7 +111,7 @@ public void QueueJoystickRotation(BattleJoystickState state, float value) /// /// of the joystick. /// Value of the joystick as Vector2. - public void OnJoystickSpecial(BattleJoystickState state, Vector2 value) + public void QueueJoystickSpecial(BattleJoystickState state, Vector2 value) { _joystickSpecialState = state; _joystickSpecialValue = value; From 950b54748d0241927d4afcbb079aeec2fd850977 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 22 May 2026 12:09:18 +0300 Subject: [PATCH 50/52] BattleGameViewController: Renamed OnJoystickSpecial to QueueJoystickSpecial --- .../View/Battle/Scripts/Game/BattleGameViewController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index c1f34fd8de..3efd437922 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -191,7 +191,7 @@ public void UiInputOnExitGamePressed() /// /// Public method that gets called when local player gives special joystick input. - /// calls OnJoystickSpecial method + /// calls QueueJoystickSpecial method /// in _playerInput /// /// @@ -199,7 +199,7 @@ public void UiInputOnExitGamePressed() /// The special input as Vector2 public void UiInputOnJoystickSpecial(BattleJoystickState state, Vector2 value) { - _playerInput.OnJoystickSpecial(state, value); + _playerInput.QueueJoystickSpecial(state, value); } /// @} From d3ce2ad010791bbea11ef0b4551c4f5e82888ce3 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 22 May 2026 12:49:26 +0300 Subject: [PATCH 51/52] BattleGameViewController.cs: Impvored formatting #1467 --- .../Scripts/Game/BattleGameViewController.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs index 3efd437922..aedd4fce81 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Game/BattleGameViewController.cs @@ -48,12 +48,11 @@ namespace Battle.View.Game /// Accesses all of the @ref UIHandlerReferences through the BattleUiController reference variable _uiController.
public class BattleGameViewController : QuantumCallbacks { - #region SerializeFields - /// @anchor BattleGameViewController-SerializeFields /// @name SerializeField variables /// SerializeFields@u-exlink are serialized variables exposed to the Unity editor. /// @{ + #region SerializeFields /// [SerializeField] Reference to BattleGridViewController which handles visual functionality for the %Battle arena's grid. /// @ref BattleGameViewController-SerializeFields @@ -85,9 +84,8 @@ public class BattleGameViewController : QuantumCallbacks [Tooltip("Reference to BattlePlayerInput which polls player input for %Quantum")] [SerializeField] private BattlePlayerInput _playerInput; - /// @} - #endregion SerializeFields + /// @} #region Public @@ -126,11 +124,10 @@ public static void AssignProjectileReference(GameObject projectileReference) #region Public - Methods - #region Public - Methods - UiInput - /// @name UiInput methods /// UiInput methods are called when the player gives an %UI input, such as presses a button. These methods shouldn't be called any other way. /// @{ + #region Public - Methods - UiInput /// /// Public method that gets called when the local player pressed the give up button. @@ -202,9 +199,8 @@ public void UiInputOnJoystickSpecial(BattleJoystickState state, Vector2 value) _playerInput.QueueJoystickSpecial(state, value); } - /// @} - #endregion Public - Methods - UiInput + /// @} #endregion Public - Methods @@ -297,11 +293,10 @@ private void Awake() QuantumEvent.Subscribe(this, QEventDebugOnScreenMessage); } - #region QuantumEvent handlers - /// @name QuantumEvent handlers /// QuantumEvent handler methods are called by QuantumEvents. These methods shouldn't be called any other way. /// @{ + #region QuantumEvent handlers /// /// Private handler method for EventBattleViewWaitForPlayers QuantumEvent.
@@ -750,9 +745,10 @@ private void QEventDebugOnScreenMessage(EventBattleDebugOnScreenMessage e) _uiController.AnnouncementHandler.SetDebugtext(e.Message); } + #endregion /// @} -#endregion + /// /// Private Update@u-exlink method. Handles %UI updates based on the game's state and countdown. From 34e6fba50e255d1acdd924a310bcfc587d99f5b7 Mon Sep 17 00:00:00 2001 From: tomipir <121516298+tomipir@users.noreply.github.com> Date: Fri, 22 May 2026 12:50:15 +0300 Subject: [PATCH 52/52] BattlePlayerInput.cs: Moved queued joystick data into a struct #1467 --- .../Scripts/Player/BattlePlayerInput.cs | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs index e3ca6b3cfe..bc4ab4e014 100644 --- a/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs +++ b/Assets/QuantumUser/View/Battle/Scripts/Player/BattlePlayerInput.cs @@ -91,7 +91,7 @@ public void CommandSendActivateAbility() /// Value of the joystick as Vector2. public void QueueJoystickMovement(BattleJoystickState state, Vector2 value) { - _joystickMovementVector = value; + _queued.JoystickMovementVector = value; } /// @@ -102,7 +102,7 @@ public void QueueJoystickMovement(BattleJoystickState state, Vector2 value) /// Value of the joystick as float. public void QueueJoystickRotation(BattleJoystickState state, float value) { - _joystickRotationValue = value; + _queued.JoystickRotationValue = value; } /// @@ -113,8 +113,8 @@ public void QueueJoystickRotation(BattleJoystickState state, float value) /// Value of the joystick as Vector2. public void QueueJoystickSpecial(BattleJoystickState state, Vector2 value) { - _joystickSpecialState = state; - _joystickSpecialValue = value; + _queued.JoystickSpecialState = state; + _queued.JoystickSpecialValue = value; } /// @} @@ -133,8 +133,8 @@ public MovementInputInfo(BattleMovementInputType movementInput, bool movementDir { MovementInput = movementInput; MovementDirectionIsNormalized = movementDirectionIsNormalized; - MovementGridPosition = movementPositionTarget; - MovementVector = movementVector; + MovementGridPosition = movementPositionTarget; + MovementVector = movementVector; } } @@ -153,10 +153,28 @@ public RotationInputInfo(bool rotationInput, FP rotationValue) } } + /// + /// Struct containing data related to queued inputs. + /// The vector received from the movement joystick. + public Vector2 JoystickMovementVector; + /// The float value received from the rotation joystick. + public float JoystickRotationValue; + /// The of the special joystick + public BattleJoystickState JoystickSpecialState; + /// The vector received from the special joystick. + public Vector2 JoystickSpecialValue; + } + /// @name State variables /// Variables related to current input states. /// @{ + /// Struct containing data related to queued inputs. + private Queued _queued; + /// Saved time from previous frame. private float _previousTime; @@ -172,21 +190,9 @@ public RotationInputInfo(bool rotationInput, FP rotationValue) /// Initial saved vector when movement input is first detected. private Vector3 _movementStartVector; - /// The vector received from the movement joystick. - private Vector2 _joystickMovementVector; - - /// The vector received from the special joystick. - private Vector2 _joystickSpecialValue; - - /// The float value received from the rotation joystick. - private float _joystickRotationValue; - /// Saved world position of the previous tap position used for double tap input validating. private Vector3 _lastTapPosition; - /// The of the special joystick - private BattleJoystickState _joystickSpecialState; - /// Saved time stamp of the previous tap. private float _lastTapTime; @@ -326,8 +332,8 @@ private void PollInput(CallbackPollInput callback) BattleSpecialInput specialInput = new() { - JoystickValue = new FPVector2(FP.FromFloat_UNSAFE(_joystickSpecialValue.x), FP.FromFloat_UNSAFE(_joystickSpecialValue.y)), - JoystickState = _joystickSpecialState + JoystickValue = new FPVector2(FP.FromFloat_UNSAFE(_queued.JoystickSpecialValue.x), FP.FromFloat_UNSAFE(_queued.JoystickSpecialValue.y)), + JoystickState = _queued.JoystickSpecialState }; Input input = new() @@ -458,11 +464,11 @@ private MovementInputInfo GetMovementInput(bool mouseDown, bool mouseClick, Vect break; case MovementInputType.Joystick: - if (_joystickMovementVector != Vector2.zero) + if (_queued.JoystickMovementVector != Vector2.zero) { movementInputInfo.MovementInput = BattleMovementInputType.Direction; movementInputInfo.MovementDirectionIsNormalized = true; - movementInputInfo.MovementVector = new FPVector2(FP.FromFloat_UNSAFE(_joystickMovementVector.x), FP.FromFloat_UNSAFE(_joystickMovementVector.y)); + movementInputInfo.MovementVector = new FPVector2(FP.FromFloat_UNSAFE(_queued.JoystickMovementVector.x), FP.FromFloat_UNSAFE(_queued.JoystickMovementVector.y)); if (BattleGameViewController.LocalPlayerTeam == BattleTeamNumber.TeamBeta) movementInputInfo.MovementVector *= -1; } @@ -518,10 +524,10 @@ private RotationInputInfo GetRotationInput(bool mouseDown, bool twoFingers, Vect break; case RotationInputType.Joystick: - if (_joystickRotationValue != 0) + if (_queued.JoystickRotationValue != 0) { rotationInputInfo.RotationInput = true; - rotationInputInfo.RotationValue = FP.FromFloat_UNSAFE(_joystickRotationValue); + rotationInputInfo.RotationValue = FP.FromFloat_UNSAFE(_queued.JoystickRotationValue); rotationInputInfo.RotationValue *= -1; } break;