Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b595286
Battle: Added command for give up #1467
tomipir Apr 24, 2026
70870d4
Battle: Updated give up to use command instead of input #1467
tomipir Apr 24, 2026
b7ea9b5
Battle: Removed GiveUpInput #1467
tomipir Apr 24, 2026
6310f58
Battle: Ran quantum codegen #1467
tomipir Apr 24, 2026
f8487b3
Battle: Added command for character swapping #1467
tomipir Apr 24, 2026
e4cb3fe
Battle: Updated character swapping to use command instead of input #1467
tomipir Apr 24, 2026
0c88b08
Battle: Removed PlayerCharacterNumber input #1467
tomipir Apr 24, 2026
a8fe924
Battle: Ran quantum codegen #1467
tomipir Apr 24, 2026
c08bc05
Battle: Added command for ability activation #1467
tomipir Apr 24, 2026
8f51ae5
Battle: Updated ability activation to use command instead of input #1467
tomipir Apr 24, 2026
f91c864
Battle: Removed AbilityActivate input #1467
tomipir Apr 24, 2026
12bb9f5
Battle: Ran quantum codegen #1467
tomipir Apr 24, 2026
9f14b7c
BattlePlayerInput.cs: Moved using to correct place #1469
tomipir Apr 27, 2026
28fb143
CommandSetup.User.cs: Added documentation #1469
tomipir Apr 27, 2026
88a79c6
CommandSwapCharacter.cs: Added documentation #1469
tomipir Apr 27, 2026
d82fde2
CommandActivateAbility.cs: Added documentation #1469
tomipir Apr 27, 2026
e3985f6
CommandGiveUp.cs: Added documentation #1469
tomipir Apr 27, 2026
b1547cb
BattlePlayerQSystem.cs: Updated documentation #1469
tomipir Apr 27, 2026
272d859
Battle: Combined MovementPositionTarget and MovementPosition Move to …
tomipir Apr 28, 2026
0d43e6f
Battle: Changed commands to use BattleCommand class #1469
tomipir Apr 28, 2026
796942c
Battle: Renamed and moved Command script files #1469
tomipir Apr 28, 2026
cfb1bd1
CommandSetup.User.cs: Updated documentation #1469
tomipir Apr 28, 2026
a085826
Battle: Updated usings and documentation #1469
tomipir Apr 28, 2026
6e2c15d
Battle: Moved all commands to BattleCommands.cs file #1469
tomipir Apr 29, 2026
3d88780
BattleUiGiveUpButtonHandler.cs: Updated give up button text #1469
tomipir Apr 29, 2026
7349366
BattlePlayerQSystem: Updated character swap and give up to continue i…
tomipir Apr 29, 2026
3da23b8
BattlePlayerQSystem.cs: Updated documentation #1469
tomipir Apr 29, 2026
b86b250
BattleCommands.cs: Updated documentation #1469
tomipir Apr 29, 2026
e36701a
Battle: Added concept page for commands #1469
tomipir Apr 29, 2026
e43b48b
Battle: Updated Custom Quantum Commands concept page #1469
tomipir Apr 29, 2026
ac9b948
Battle: Removed PlayerRef when sending commands #1469
tomipir Apr 30, 2026
81e1289
CommandSetup.User.cs: Updated usings #1469
tomipir Apr 30, 2026
c603e51
Battle: Updated documentation #1469
tomipir Apr 30, 2026
620e6a5
BattleCommands.cs: Updated documentation #1469
tomipir May 4, 2026
41ce61e
BattlePlayerQSystem.cs: Updated HandleGiveUp method #1469
tomipir May 4, 2026
0b1389c
Battle: Updated commands concept page #1469
tomipir May 4, 2026
87d0a03
Battle: Fixed code links #1469
tomipir May 4, 2026
16ee274
Merge branch 'main' into Battle/feature/Commands
tomipir May 11, 2026
84968f5
Merge branch 'main' into Battle/feature/Commands
tomipir May 21, 2026
42e4cba
BattleCommands.cs: Updated Documentation #1467
tomipir May 21, 2026
359dfe8
Battle: Updated documentation #1467
tomipir May 21, 2026
2f324d1
BattleCommands.cs: Moved Serialize method to base class #1467
tomipir May 21, 2026
60d099d
BattlePlayerQSystem.cs: Added check for preventing character swap to …
tomipir May 21, 2026
df73707
BattlePlayerQSystem: Changed a method to public and updated documenta…
tomipir May 21, 2026
f8f97ed
BattlePlayerQSystem.cs: Fixed indentation and updated documentation #…
tomipir May 21, 2026
302f4f7
BattlePlayerBotController: Fixed indentation #1467
tomipir May 21, 2026
3559a44
BattleGameViewController.cs: Updated documentation #1467
tomipir May 21, 2026
a9c88b6
BattlePlayerInput.cs: Disabled DEBUG_INPUT_TYPE_OVERRIDE #1467
Niklas603619 May 21, 2026
f598f99
BattlePlayerInput.cs: Removed unnecessary using #1467
Niklas603619 May 21, 2026
bd2201f
BattlePlayerInput.cs: Improved documenton #1467
Niklas603619 May 21, 2026
7b7365c
BattlePlayerInput.cs: Renamed OnJoystickSpecial to QueueJoystickSpeci…
tomipir May 21, 2026
950b547
BattleGameViewController: Renamed OnJoystickSpecial to QueueJoystickS…
tomipir May 22, 2026
d3ce2ad
BattleGameViewController.cs: Impvored formatting #1467
tomipir May 22, 2026
34e6fba
BattlePlayerInput.cs: Moved queued joystick data into a struct #1467
tomipir May 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ input
int DebugNumber;
BattleMovementInputType MovementInput;
bool MovementDirectionIsNormalized;
BattleGridPosition MovementPositionTarget;
FPVector2 MovementPositionMove;
FPVector2 MovementDirection;
BattleGridPosition MovementGridPosition;
FPVector2 MovementVector;
bool RotationInput;
FP RotationValue;
bool AbilityActivate;
int PlayerCharacterNumber;
bool GiveUpInput;
BattleSpecialInput Special;
}

Expand Down
38 changes: 6 additions & 32 deletions Assets/QuantumUser/Simulation/Battle/Scripts/BattleDebugUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +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 (input->PlayerCharacterNumber > -1)
{
if (inputDebugSummary != "") inputDebugSummary += ", ";
inputDebugSummary += "Character Swap";
inputNotEmpty = true;
}
if (input->GiveUpInput != false)
{
if (inputDebugSummary != "") inputDebugSummary += ", ";
inputDebugSummary += "Give Up";
inputNotEmpty = true;
}

if (inputNotEmpty)
{
Expand All @@ -95,24 +77,16 @@ 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" +
" AbilityActivate: {7},\n" +
" PlayerCharacterNumber: {8},\n" +
" GiveUpInput: {9}\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,
input->AbilityActivate,
input->PlayerCharacterNumber,
input->GiveUpInput
input->RotationValue
)
);
}
Expand Down
119 changes: 119 additions & 0 deletions Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/// @file BattleCommands.cs
/// <summary>
/// Contains @cref{Battle.QSimulation.Game,BattleCommand} class and all battle commands
///
/// See [{Custom Quantum Commands}](#page-concepts-commands) for more info.
/// </summary>

// System usings
using System.Runtime.CompilerServices;

// Quantum usings
using Quantum;
using Photon.Deterministic;

namespace Battle.QSimulation.Game
{
/// <summary>
/// Abstract base class for all deterministic battle commands.<br/>
/// All new commands must be added to the <see cref="Type"/> enum.
/// </summary>
///
/// See [{BattleCommand (base class)}](#page-concepts-commands-battle-qcommand) for more info.
public abstract class BattleCommand : DeterministicCommand
{
/// <summary>
/// Type of the command. None if no command.
/// </summary>
public enum Type
{
/// <summary>No command</summary>
None,
/// <summary><See cref="BattleGiveUpQCommand"/></summary>
GiveUp,
/// <summary><See cref="BattleCharacterAbilityQCommand"/></summary>
ActivateAbility,
/// <summary><See cref="BattleCharacterSwapQCommand"/></summary>
SwapCharacter
}

public override void Serialize(BitStream stream) { }

public abstract Type BattleCommandType { get; }

/// <summary>
/// Fetches a command for a <paramref name="playerRef"/> and returns its <see cref="Type"/>. The <paramref name="commandData"/> out parameter contains the command itself.
/// </summary>
///
/// <param name="f">The current simulation frame.</param>
/// <param name="playerRef">Reference to the player whose command is fetched.</param>
/// <param name="commandData">Contains the command, or null if there isn't one. (<b>out param</b>)</param>
///
/// <returns>
/// The <see cref="Type"/> of the command, or <see cref="Type.None"/> if no command was found.
/// </returns>
[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;
}
}

/// <summary>
/// A deterministic command that triggers the ability activation for a specific player.
/// </summary>
///
/// See [{Custom Quantum Commands}](#page-concepts-commands) for more info.
public class BattleCharacterAbilityQCommand : BattleCommand
{
/// <summary>
/// Gets the command <see cref="BattleCommand.Type">Type</see> associated with this command.<br/>
/// Always returns <see cref="BattleCommand.Type.ActivateAbility">Type.ActivateAbility</see>.
/// </summary>
public override Type BattleCommandType => Type.ActivateAbility;
}

/// <summary>
/// A deterministic command that triggers the character swapping logic for a specific player.
/// </summary>
///
/// See [{Custom Quantum Commands}](#page-concepts-commands) for more info.
public class BattleCharacterSwapQCommand : BattleCommand
{
/// <summary>
/// Gets the command <see cref="BattleCommand.Type">Type</see> associated with this command.<br/>
/// Always returns <see cref="BattleCommand.Type.SwapCharacter">Type.SwapCharacter</see>.
/// </summary>
public override Type BattleCommandType => Type.SwapCharacter;

/// <summary>
/// The number of the character the player is attempting to swap to.
/// </summary>
public int CharacterNumber;

/// <summary>
/// Serializes the character number into the bitstream for network transmission.
/// </summary>
/// <param name="stream">The bitstream to write to</param>
public override void Serialize(BitStream stream)
{
stream.Serialize(ref CharacterNumber);
}
}

/// <summary>
/// A deterministic command that triggers the give up logic for a specific player.
/// </summary>
///
/// See [{Custom Quantum Commands}](#page-concepts-commands) for more info.
public class BattleGiveUpQCommand : BattleCommand
{
/// <summary>
/// Gets the command <see cref="BattleCommand.Type">Type</see> associated with this command.<br/>
/// Always returns <see cref="BattleCommand.Type.GiveUp">Type.GiveUp</see>.
/// </summary>
public override Type BattleCommandType => Type.GiveUp;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,10 @@ 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,
PlayerCharacterNumber = -1,
GiveUpInput = false,
AbilityActivate = false
RotationValue = FP._0
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ 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;
playerData->ViewPosition = playerData->TargetPosition;
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;
Expand All @@ -108,7 +108,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))
{
Expand Down
Loading