diff --git a/Assets/QuantumUser/Resources/Specs/BattlePlayerClass100QSpec.asset b/Assets/QuantumUser/Resources/Specs/BattlePlayerClass100QSpec.asset index bcda4413ea..ae54756a18 100644 --- a/Assets/QuantumUser/Resources/Specs/BattlePlayerClass100QSpec.asset +++ b/Assets/QuantumUser/Resources/Specs/BattlePlayerClass100QSpec.asset @@ -20,7 +20,7 @@ MonoBehaviour: Id: Value: 1387710306654430788 ProjectileSpeed: - RawValue: 6554 + RawValue: 334234 ProjectileSpawnDistance: RawValue: 32768 ProjectileSpawnCooldown: @@ -29,3 +29,5 @@ MonoBehaviour: RawValue: 32768 JoystickTapDistanceMax: RawValue: 32768 + PlacementTimeDurationSec: + RawValue: 327680 diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerData.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerData.qtn index ef298ac22a..63c7431a00 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerData.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/BattlePlayerData.qtn @@ -22,6 +22,7 @@ component BattlePlayerDataQComponent // Player's attributes int GridExtendTop; int GridExtendBottom; + bool DisableMovement; bool DisableRotation; BattlePlayerSpawnBehaviour SpawnBehaviour; @@ -65,6 +66,7 @@ component BattlePlayerDataTemplateQComponent BattlePlayerHitboxTemplate Hitbox; + bool DisableMovement; bool DisableRotation; BattlePlayerSpawnBehaviour SpawnBehaviour; diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Data.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Data.qtn index 4b401630c8..25da0d32c9 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Data.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Data.qtn @@ -8,4 +8,6 @@ component BattlePlayerClass100DataQComponent FrameTimer JoystickTimer; [HideInInspector] FrameTimer CooldownTimer; + [HideInInspector] + FrameTimer PlacementTimer; } diff --git a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Projectile.qtn b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Projectile.qtn index 82dccfd51e..2201cd4630 100644 --- a/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Projectile.qtn +++ b/Assets/QuantumUser/Simulation/Battle/Qtn/Player/PlayerClasses/BattlePlayerClass100Projectile.qtn @@ -4,4 +4,6 @@ component BattlePlayerClass100ProjectileQComponent FPVector2 Direction; [HideInInspector] FP Speed; + [HideInInspector] + FP Radius; } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCollisionQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCollisionQSystem.cs index f22261dd50..7b5f71c1ca 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCollisionQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleCollisionQSystem.cs @@ -39,6 +39,13 @@ public struct ProjectileCollisionData public EntityRef OtherEntity; } + public struct PlayerClass100ProjectileCollisionData + { + public BattlePlayerClass100ProjectileQComponent* Projectile; + public EntityRef ProjectileEntity; + public EntityRef OtherEntity; + } + public struct ArenaBorderCollisionData { public BattleArenaBorderQComponent* ArenaBorder; @@ -243,6 +250,13 @@ public void OnTrigger2D(Frame f, TriggerInfo2D info) { BattlePlayerClass100ProjectileQComponent* playerClass100Projectile = f.Unsafe.GetPointer(info.Entity); + PlayerClass100ProjectileCollisionData playerClass100ProjectileCollisionData = new() + { + Projectile = playerClass100Projectile, + ProjectileEntity = info.Entity, + OtherEntity = info.Other + }; + switch (collisionTrigger->Type) { case BattleCollisionTriggerType.Projectile: @@ -273,7 +287,12 @@ public void OnTrigger2D(Frame f, TriggerInfo2D info) case BattleCollisionTriggerType.ArenaBorder: { s_debugLogger.Log("Player class 100 projectile hit the Arena Border"); - BattlePlayerClass100ProjectileQSystem.OnProjectileHitObstacle(f, info.Entity); + + ArenaBorderCollisionData arenaBorderCollisionData = new() + { + ArenaBorder = f.Unsafe.GetPointer(info.Other) + }; + BattlePlayerClass100ProjectileQSystem.OnProjectileHitArenaBorder(f, &arenaBorderCollisionData, &playerClass100ProjectileCollisionData); break; } } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleGameControlQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleGameControlQSystem.cs index 2f5a5deba6..4794e41908 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleGameControlQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Game/BattleGameControlQSystem.cs @@ -179,6 +179,7 @@ public override void Update(Frame f) // Transition from GetReadyToPlay to Playing if (gameSession->TimeUntilStartSec <= FP._0) { + BattlePlayerQSystem.OnGameStart(f); BattleProjectileQSystem.Launch(f); f.Events.BattleViewGameStart(); gameSession->State = BattleGameState.Playing; diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerClassManager.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerClassManager.cs index fb134f9f9b..75410d9da4 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerClassManager.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerClassManager.cs @@ -137,6 +137,19 @@ public virtual unsafe void OnProjectileHitPlayerShield(Frame f, BattleCollisionQ /// Pointer to the player data. /// Reference to the player entity. public virtual unsafe void OnUpdate(Frame f, BattlePlayerManager.PlayerHandle playerHandle, BattlePlayerDataQComponent* playerData, BattlePlayerEntityRef playerEntity, BattleSpecialInput* specialInput) { } + + /// + /// Called by the @cref{Battle.QSimulation.Player,BattlePlayerClassManager} + /// OnGameStart method + /// when the game starts.
+ /// Provides a hook for derived classes to implement character class specific simulation logic. + ///
+ /// + /// Current simulation frame. + /// Reference to the player handle. + /// Pointer to the player data. + /// Reference to the player entity. + public virtual unsafe void OnGameStart(Frame f, BattlePlayerManager.PlayerHandle playerHandle, BattlePlayerDataQComponent* playerData, EntityRef playerEntity) { } } /// @@ -389,6 +402,23 @@ public static void OnUpdate(Frame f, BattlePlayerManager.PlayerHandle playerHand playerClass.OnUpdate(f, playerHandle, playerData, playerEntity, specialInput); } + /// + /// Calls the OnGameStart method of the class of the given player character, if it is implemented. + /// + /// + /// Current simulation frame. + /// Reference to the player handle. + /// Pointer to the player data. + /// Reference to the player entity. + public static void OnGameStart(Frame f, BattlePlayerManager.PlayerHandle playerHandle, BattlePlayerDataQComponent* playerData, EntityRef playerEntity) + { + ReturnCode returnCode = GetClass(playerData->CharacterClass, out BattlePlayerClassBase playerClass); + + if (returnCode != ReturnCode.ClassRetrieved) return; + + playerClass.OnGameStart(f, playerHandle, playerData, playerEntity); + } + /// Constant for a class index error. private const int ClassIndexError = -1; /// Constant for Desensitizer class index. diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerManager.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerManager.cs index e85fc3e72a..ed06af4da0 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerManager.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerManager.cs @@ -389,11 +389,12 @@ public static void CreatePlayers(Frame f) // player's attributes GridExtendTop = playerGridExtendTop, GridExtendBottom = playerGridExtendBottom, + DisableMovement = playerCharacterDataTemplate->DisableMovement, DisableRotation = playerCharacterDataTemplate->DisableRotation, SpawnBehaviour = playerCharacterDataTemplate->SpawnBehaviour, // player's current state related data - MovementEnabled = true, + MovementEnabled = !playerCharacterDataTemplate->DisableMovement, RotationEnabled = !playerCharacterDataTemplate->DisableRotation, CurrentDefence = FP._0, diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs index 2485cf06d4..404e9406f9 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/BattlePlayerQSystem.cs @@ -208,6 +208,24 @@ public static void OnProjectileHitPlayerShield(Frame f, BattleCollisionQSystem.P BattleProjectileQSystem.SetCollisionFlag(f, projectileCollisionData->Projectile, BattleProjectileCollisionFlags.Player); } + /// + /// Calls BattlePlayerClassManager::OnGameStart for every player's selected character. + /// + /// + /// Current simulation frame. + public static void OnGameStart(Frame f) + { + foreach (BattlePlayerManager.PlayerHandle playerHandle in BattlePlayerManager.PlayerHandle.GetPlayerHandleArray(f)) + { + if (playerHandle.PlayState.IsNotInGame()) continue; + + BattlePlayerEntityRef entityRef = playerHandle.GetSelectedCharacterEntityRef(f); + BattlePlayerDataQComponent* playerData = entityRef.GetDataQComponent(f); + + BattlePlayerClassManager.OnGameStart(f, playerHandle, playerData, entityRef); + } + } + /// /// Quantum System Update method@u-exlink gets called every frame.
/// Relays the appropriate input data to each player in the game @@ -633,7 +651,7 @@ private void HandleInPlay(Frame f, Input* input, BattlePlayerManager.PlayerHandl if (!playerData->StunCooldown.IsRunning(f)) { - playerData->MovementEnabled = true; + playerData->MovementEnabled = !playerData->DisableMovement; playerData->RotationEnabled = !playerData->DisableRotation; } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100ProjectileQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100ProjectileQSystem.cs index 38e7a510b3..0580b4c785 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100ProjectileQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100ProjectileQSystem.cs @@ -12,6 +12,7 @@ // Battle Qsimulation usings using Battle.QSimulation.Projectile; +using Battle.QSimulation.Game; namespace Battle.QSimulation.Player { @@ -53,11 +54,13 @@ public static void Create(Frame f, EntityPrototype entityPrototype, FPVector2 po // get components Transform2D* projectileTransform = f.Unsafe.GetPointer(projectileEntityRef); BattlePlayerClass100ProjectileQComponent* projectile = f.Unsafe.GetPointer(projectileEntityRef); + PhysicsCollider2D* collider = f.Unsafe.GetPointer(projectileEntityRef); // set Initial projectile direction and speed projectileTransform->Position = position; projectile->Direction = direction; projectile->Speed = speed; + projectile->Radius = collider->Shape.Circle.Radius; } /// @@ -71,7 +74,7 @@ public static void Create(Frame f, EntityPrototype entityPrototype, FPVector2 po /// Reference to Quantum Filter@u-exlink. public override void Update(Frame f, ref Filter filter) { - filter.Transform->Position += filter.Projectile->Direction * filter.Projectile->Speed; + filter.Transform->Position += filter.Projectile->Direction * (filter.Projectile->Speed * f.DeltaTime); } /// @@ -93,6 +96,43 @@ public static void OnProjectileHitEmotionProjectile( f.Destroy(playerClass100ProjectileEntityRef); } + /// + /// Updates the player class 100 projectile's direction when it hits the arena border. + /// + /// + /// Current simulation frame. + /// Collision data related to the arena. + /// Collision data related to the class 100 projectile. + public static void OnProjectileHitArenaBorder( + Frame f, + BattleCollisionQSystem.ArenaBorderCollisionData* arenaCollisionData, + BattleCollisionQSystem.PlayerClass100ProjectileCollisionData* playerClass100ProjectileCollisionData + ) + { + BattlePlayerClass100ProjectileQComponent* playerClass100Projectile = playerClass100ProjectileCollisionData->Projectile; + EntityRef playerClass100ProjectileEntityRef = playerClass100ProjectileCollisionData->ProjectileEntity; + EntityRef otherEntity = playerClass100ProjectileCollisionData->OtherEntity; + BattleArenaBorderQComponent* arenaBorder = arenaCollisionData->ArenaBorder; + + FPVector2 normal = arenaBorder->Normal; + FP collisionMinOffset = arenaBorder->CollisionMinOffset; + + FPVector2 direction = FPVector2.Reflect(playerClass100Projectile->Direction, normal).Normalized; + + Transform2D* projectileTransform = f.Unsafe.GetPointer(playerClass100ProjectileEntityRef); + Transform2D* otherTransform = f.Unsafe.GetPointer(otherEntity); + + FPVector2 offsetVector = projectileTransform->Position - otherTransform->Position; + FP collisionOffset = FPVector2.Rotate(offsetVector, -FPVector2.RadiansSigned(FPVector2.Up, normal)).Y; + + if (collisionOffset - playerClass100Projectile->Radius < collisionMinOffset) + { + projectileTransform->Position += normal * (collisionMinOffset - collisionOffset + playerClass100Projectile->Radius); + } + + playerClass100Projectile->Direction = direction; + } + /// /// Destroys the player class 100 projectile. /// diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100QSpec.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100QSpec.cs index 49dfd32df4..cc3f75277c 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100QSpec.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100QSpec.cs @@ -40,5 +40,8 @@ public class BattlePlayerClass100QSpec : AssetObject [Tooltip("Maximum distance from joystick center for a press to register as pressing the middle")] /// Maximum distance from joystick center for a press to register as pressing the middle public FP JoystickTapDistanceMax; + [Tooltip("Time in seconds before character stops moving completely.")] + /// Time in seconds before character stops moving completely. + public FP PlacementTimeDurationSec; } } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100Test.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100Test.cs index 187f5ccf61..c280e25efd 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100Test.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Player/PlayerClasses/BattlePlayerClass100Test.cs @@ -9,6 +9,7 @@ // Battle QSimulation usings using Battle.QSimulation.Game; +using Battle.QSimulation.Projectile; namespace Battle.QSimulation.Player { @@ -63,12 +64,68 @@ public override unsafe void OnDespawn(Frame f, BattlePlayerManager.PlayerHandle /// Entity reference for the player. /// Pointer to special input (unused) public override unsafe void OnUpdate(Frame f, BattlePlayerManager.PlayerHandle playerHandle, BattlePlayerDataQComponent* playerData, BattlePlayerEntityRef playerEntity, BattleSpecialInput* specialInput) + { + if (GetClassData(f, playerEntity)->PlacementTimer.IsRunning(f)) return; + + playerData->DisableMovement = true; + + BattlePlayerCharacterID characterID = playerData->CharacterId; + + switch (characterID) + { + case BattlePlayerCharacterID.Character101: + HandleAiming(f, playerData, playerEntity, specialInput); + break; + case BattlePlayerCharacterID.Character102: + HandleAutoAim(f, playerEntity, specialInput); + break; + case BattlePlayerCharacterID.Character103: + HandleAiming(f, playerData, playerEntity, specialInput); + break; + case BattlePlayerCharacterID.Character104: + HandleAutoAim(f, playerEntity, specialInput); + break; + case BattlePlayerCharacterID.Character105: + HandleAiming(f, playerData, playerEntity, specialInput); + break; + case BattlePlayerCharacterID.Character106: + HandleAutoAim(f, playerEntity, specialInput); + break; + } + } + + /// + /// Called when the game starts to start the placement timer. + /// + /// + /// Current simulation frame. + /// Handle for the player. + /// Pointer to player data. + /// Entity reference to the player. + public override unsafe void OnGameStart(Frame f, BattlePlayerManager.PlayerHandle playerHandle, BattlePlayerDataQComponent* playerData, EntityRef playerEntity) + { + BattlePlayerClass100QSpec spec = BattleQConfig.GetBattlePlayerClass100Spec(f); + + BattlePlayerClass100DataQComponent* classData = GetClassData(f, playerEntity); + + classData->PlacementTimer = FrameTimer.FromSeconds(f, spec.PlacementTimeDurationSec); + } + + /// + /// Handles joystick based aiming. + /// + /// + /// Current simulation frame. + /// Pointer to player data. + /// Entity reference to the player. + /// Pointer to special input. + private unsafe void HandleAiming(Frame f, BattlePlayerDataQComponent* playerData, BattlePlayerEntityRef playerEntity, BattleSpecialInput* specialInput) { BattlePlayerClass100QSpec spec = BattleQConfig.GetBattlePlayerClass100Spec(f); //BattleDebugLogger.WarningFormat(f, nameof(BattlePlayerClass100), "Joystick ( state: {0}, Direction: {1} )", specialInput->JoystickState, specialInput->JoystickValue); - Transform2D* playerTransform = f.Unsafe.GetPointer(playerEntity); - BattlePlayerClass100DataQComponent* classData = GetClassData(f, playerEntity); + Transform2D* playerTransform = f.Unsafe.GetPointer(playerEntity); + BattlePlayerClass100DataQComponent* classData = GetClassData(f, playerEntity); bool joystickDown = specialInput->JoystickState != BattleJoystickState.Up; bool projectileOnCooldown = classData->CooldownTimer.IsRunning(f); @@ -110,5 +167,96 @@ public override unsafe void OnUpdate(Frame f, BattlePlayerManager.PlayerHandle p classData->JoystickDownPrevious = joystickDown; classData->JoystickValuePrevious = specialInput->JoystickValue; } + + /// + /// Handles autoaiming. + /// + /// + /// Current simulation frame. + /// Entity reference to the player. + /// Pointer to special input. + private unsafe void HandleAutoAim(Frame f, BattlePlayerEntityRef playerEntity, BattleSpecialInput* specialInput) + { + BattlePlayerClass100QSpec spec = BattleQConfig.GetBattlePlayerClass100Spec(f); + + Transform2D* playerTransform = f.Unsafe.GetPointer(playerEntity); + BattlePlayerClass100DataQComponent* classData = GetClassData(f, playerEntity); + + EntityRef projectileEntityRef = BattleProjectileQSystem.GetProjectileEntityRef(f); + Transform2D* projectileTransform = f.Unsafe.GetPointer(projectileEntityRef); + BattleProjectileQComponent* projectile = f.Unsafe.GetPointer(projectileEntityRef); + + bool joystickDown = specialInput->JoystickState != BattleJoystickState.Up; + bool projectileOnCooldown = classData->CooldownTimer.IsRunning(f); + + // Exit if no changes in joystick state + if (joystickDown == classData->JoystickDownPrevious) goto Exit; + + if (joystickDown) + { + // Handle joystick down + classData->JoystickTimer = FrameTimer.FromSeconds(f, spec.JoystickTapDurationMax); + } + else + { + // Handle joystick up + + // exit if projectile ability is on cooldown + if (projectileOnCooldown) goto Exit; + + bool isJoystickTap = classData->JoystickTimer.IsRunning(f) && classData->JoystickValuePrevious.Magnitude < spec.JoystickTapDistanceMax; + + FPVector2 targetPosition = projectileTransform->Position; + FPVector2 targetVelocity = projectile->Direction * projectile->Speed; + FPVector2 playerPosition = playerTransform->Position; + FPVector2 direction = (targetPosition - playerPosition).Normalized; + + FP time = FP._2; + + FPVector2 spawnPosition = playerPosition + direction * spec.ProjectileSpawnDistance; + FPVector2 targetRelativePosition = targetPosition - spawnPosition; + + FP a = projectile->Speed * projectile->Speed - spec.ProjectileSpeed * spec.ProjectileSpeed; + FP b = FPVector2.Dot(targetRelativePosition, targetVelocity) * FP._2; + FP c = targetRelativePosition.SqrMagnitude; + + if (a == 0) + { + FP time1 = -c / b; + + if (time1 > FP._0) time = time1; + } + else + { + FP discriminant = b * b - a * c * FP._4; + + if (discriminant > FP._0) + { + FP discriminantSquareRoot = FPMath.Sqrt(discriminant); + + FP time1 = (-b + discriminantSquareRoot) / (a * FP._2); + FP time2 = (-b - discriminantSquareRoot) / (a * FP._2); + + if (time1 > FP._0) time = time1; + if (time2 > FP._0) time = FPMath.Min(time, time2); + } + } + + FPVector2 interceptPoint = targetPosition + targetVelocity * time; + + direction = (interceptPoint - playerPosition).Normalized; + + FPVector2 position = playerPosition + direction * spec.ProjectileSpawnDistance; + + BattlePlayerClass100ProjectileQSystem.Create(f, f.FindAsset(spec.ProjectileEntityPrototype), position, direction, spec.ProjectileSpeed); + + // start projectile cooldown + classData->CooldownTimer = FrameTimer.FromSeconds(f, spec.ProjectileSpawnCooldown); + } + + Exit: + classData->JoystickDownPrevious = joystickDown; + classData->JoystickValuePrevious = specialInput->JoystickValue; + } } } diff --git a/Assets/QuantumUser/Simulation/Battle/Scripts/Projectile/BattleProjectileQSystem.cs b/Assets/QuantumUser/Simulation/Battle/Scripts/Projectile/BattleProjectileQSystem.cs index cb405d1448..95feefe20f 100644 --- a/Assets/QuantumUser/Simulation/Battle/Scripts/Projectile/BattleProjectileQSystem.cs +++ b/Assets/QuantumUser/Simulation/Battle/Scripts/Projectile/BattleProjectileQSystem.cs @@ -53,6 +53,15 @@ public struct Filter public BattleProjectileQComponent* Projectile; } + /// + /// Gets the projectile's EntityRef. + /// + /// + /// Current simulation frame. + /// + /// The EntityRef of the projectile. + public static EntityRef GetProjectileEntityRef(Frame f) => GetProjectileEntity(f); + #region Public - Helper Methods /// diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs index e637ae3763..ad7c88512a 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Core.cs @@ -1514,9 +1514,9 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct BattlePlayerClass100DataQComponent : Quantum.IComponent { - public const Int32 SIZE = 40; + public const Int32 SIZE = 48; public const Int32 ALIGNMENT = 8; - [FieldOffset(24)] + [FieldOffset(32)] [HideInInspector()] public FPVector2 JoystickValuePrevious; [FieldOffset(0)] @@ -1528,6 +1528,9 @@ public unsafe partial struct BattlePlayerClass100DataQComponent : Quantum.ICompo [FieldOffset(8)] [HideInInspector()] public FrameTimer CooldownTimer; + [FieldOffset(24)] + [HideInInspector()] + public FrameTimer PlacementTimer; public override Int32 GetHashCode() { unchecked { var hash = 12277; @@ -1535,6 +1538,7 @@ public override Int32 GetHashCode() { hash = hash * 31 + JoystickDownPrevious.GetHashCode(); hash = hash * 31 + JoystickTimer.GetHashCode(); hash = hash * 31 + CooldownTimer.GetHashCode(); + hash = hash * 31 + PlacementTimer.GetHashCode(); return hash; } } @@ -1543,29 +1547,35 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { QBoolean.Serialize(&p->JoystickDownPrevious, serializer); FrameTimer.Serialize(&p->CooldownTimer, serializer); FrameTimer.Serialize(&p->JoystickTimer, serializer); + FrameTimer.Serialize(&p->PlacementTimer, serializer); FPVector2.Serialize(&p->JoystickValuePrevious, serializer); } } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct BattlePlayerClass100ProjectileQComponent : Quantum.IComponent { - public const Int32 SIZE = 24; + public const Int32 SIZE = 32; public const Int32 ALIGNMENT = 8; - [FieldOffset(8)] + [FieldOffset(16)] [HideInInspector()] public FPVector2 Direction; - [FieldOffset(0)] + [FieldOffset(8)] [HideInInspector()] public FP Speed; + [FieldOffset(0)] + [HideInInspector()] + public FP Radius; public override Int32 GetHashCode() { unchecked { var hash = 18131; hash = hash * 31 + Direction.GetHashCode(); hash = hash * 31 + Speed.GetHashCode(); + hash = hash * 31 + Radius.GetHashCode(); return hash; } } public static void Serialize(void* ptr, FrameSerializer serializer) { var p = (BattlePlayerClass100ProjectileQComponent*)ptr; + FP.Serialize(&p->Radius, serializer); FP.Serialize(&p->Speed, serializer); FPVector2.Serialize(&p->Direction, serializer); } @@ -1615,7 +1625,7 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct BattlePlayerDataQComponent : Quantum.IComponent { - public const Int32 SIZE = 208; + public const Int32 SIZE = 216; public const Int32 ALIGNMENT = 8; [FieldOffset(36)] public PlayerRef PlayerRef; @@ -1627,49 +1637,51 @@ public unsafe partial struct BattlePlayerDataQComponent : Quantum.IComponent { public BattlePlayerCharacterID CharacterId; [FieldOffset(0)] public BattlePlayerCharacterClass CharacterClass; - [FieldOffset(176)] + [FieldOffset(184)] public BattlePlayerStats Stats; [FieldOffset(28)] public Int32 GridExtendTop; [FieldOffset(24)] public Int32 GridExtendBottom; [FieldOffset(40)] + public QBoolean DisableMovement; + [FieldOffset(44)] public QBoolean DisableRotation; [FieldOffset(12)] public BattlePlayerSpawnBehaviour SpawnBehaviour; - [FieldOffset(48)] - public QBoolean MovementEnabled; [FieldOffset(52)] + public QBoolean MovementEnabled; + [FieldOffset(56)] public QBoolean RotationEnabled; - [FieldOffset(72)] + [FieldOffset(80)] public FP CurrentDefence; - [FieldOffset(120)] + [FieldOffset(128)] public FrameTimer StunCooldown; - [FieldOffset(112)] + [FieldOffset(120)] public FrameTimer ShieldHitCooldown; - [FieldOffset(44)] + [FieldOffset(48)] public QBoolean HasTargetPosition; - [FieldOffset(128)] + [FieldOffset(136)] public FPVector2 TargetPosition; - [FieldOffset(80)] - public FP RotationBaseRad; [FieldOffset(88)] + public FP RotationBaseRad; + [FieldOffset(96)] public FP RotationOffsetRad; [FieldOffset(32)] public Int32 ShieldCount; [FieldOffset(20)] public Int32 AttachedShieldNumber; - [FieldOffset(56)] + [FieldOffset(64)] public BattlePlayerShieldEntityRef AttachedShield; - [FieldOffset(104)] + [FieldOffset(112)] public FrameTimer AbilityCooldownSec; - [FieldOffset(96)] + [FieldOffset(104)] public FrameTimer AbilityActivateBufferSec; - [FieldOffset(64)] + [FieldOffset(72)] public FP BotMovementCooldownSec; - [FieldOffset(160)] + [FieldOffset(168)] public FPVector2 ViewPosition; - [FieldOffset(144)] + [FieldOffset(152)] public FPVector2 ViewMovementVector; public override Int32 GetHashCode() { unchecked { @@ -1682,6 +1694,7 @@ public override Int32 GetHashCode() { hash = hash * 31 + Stats.GetHashCode(); hash = hash * 31 + GridExtendTop.GetHashCode(); hash = hash * 31 + GridExtendBottom.GetHashCode(); + hash = hash * 31 + DisableMovement.GetHashCode(); hash = hash * 31 + DisableRotation.GetHashCode(); hash = hash * 31 + (Int32)SpawnBehaviour; hash = hash * 31 + MovementEnabled.GetHashCode(); @@ -1716,6 +1729,7 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { serializer.Stream.Serialize(&p->GridExtendTop); serializer.Stream.Serialize(&p->ShieldCount); PlayerRef.Serialize(&p->PlayerRef, serializer); + QBoolean.Serialize(&p->DisableMovement, serializer); QBoolean.Serialize(&p->DisableRotation, serializer); QBoolean.Serialize(&p->HasTargetPosition, serializer); QBoolean.Serialize(&p->MovementEnabled, serializer); @@ -1737,15 +1751,17 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { } [StructLayout(LayoutKind.Explicit)] public unsafe partial struct BattlePlayerDataTemplateQComponent : Quantum.IComponent { - public const Int32 SIZE = 32; + public const Int32 SIZE = 40; public const Int32 ALIGNMENT = 8; [FieldOffset(8)] public Int32 GridExtendTop; [FieldOffset(4)] public Int32 GridExtendBottom; - [FieldOffset(16)] + [FieldOffset(24)] public BattlePlayerHitboxTemplate Hitbox; [FieldOffset(12)] + public QBoolean DisableMovement; + [FieldOffset(16)] public QBoolean DisableRotation; [FieldOffset(0)] public BattlePlayerSpawnBehaviour SpawnBehaviour; @@ -1755,6 +1771,7 @@ public override Int32 GetHashCode() { hash = hash * 31 + GridExtendTop.GetHashCode(); hash = hash * 31 + GridExtendBottom.GetHashCode(); hash = hash * 31 + Hitbox.GetHashCode(); + hash = hash * 31 + DisableMovement.GetHashCode(); hash = hash * 31 + DisableRotation.GetHashCode(); hash = hash * 31 + (Int32)SpawnBehaviour; return hash; @@ -1772,6 +1789,7 @@ public static void Serialize(void* ptr, FrameSerializer serializer) { serializer.Stream.Serialize((Int32*)&p->SpawnBehaviour); serializer.Stream.Serialize(&p->GridExtendBottom); serializer.Stream.Serialize(&p->GridExtendTop); + QBoolean.Serialize(&p->DisableMovement, serializer); QBoolean.Serialize(&p->DisableRotation, serializer); Quantum.BattlePlayerHitboxTemplate.Serialize(&p->Hitbox, serializer); } diff --git a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs index db6d1f9075..fec7f0f64b 100644 --- a/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs +++ b/Assets/QuantumUser/Simulation/Generated/Quantum.CodeGen.Prototypes.cs @@ -276,6 +276,8 @@ public unsafe partial class BattlePlayerClass100DataQComponentPrototype : Compon public Quantum.Prototypes.FrameTimerPrototype JoystickTimer; [HideInInspector()] public Quantum.Prototypes.FrameTimerPrototype CooldownTimer; + [HideInInspector()] + public Quantum.Prototypes.FrameTimerPrototype PlacementTimer; partial void MaterializeUser(Frame frame, ref Quantum.BattlePlayerClass100DataQComponent result, in PrototypeMaterializationContext context); public override Boolean AddToEntity(FrameBase f, EntityRef entity, in PrototypeMaterializationContext context) { Quantum.BattlePlayerClass100DataQComponent component = default; @@ -287,6 +289,7 @@ public void Materialize(Frame frame, ref Quantum.BattlePlayerClass100DataQCompon result.JoystickDownPrevious = this.JoystickDownPrevious; this.JoystickTimer.Materialize(frame, ref result.JoystickTimer, in context); this.CooldownTimer.Materialize(frame, ref result.CooldownTimer, in context); + this.PlacementTimer.Materialize(frame, ref result.PlacementTimer, in context); MaterializeUser(frame, ref result, in context); } } @@ -297,6 +300,8 @@ public unsafe partial class BattlePlayerClass100ProjectileQComponentPrototype : public FPVector2 Direction; [HideInInspector()] public FP Speed; + [HideInInspector()] + public FP Radius; partial void MaterializeUser(Frame frame, ref Quantum.BattlePlayerClass100ProjectileQComponent result, in PrototypeMaterializationContext context); public override Boolean AddToEntity(FrameBase f, EntityRef entity, in PrototypeMaterializationContext context) { Quantum.BattlePlayerClass100ProjectileQComponent component = default; @@ -306,6 +311,7 @@ public override Boolean AddToEntity(FrameBase f, EntityRef entity, in PrototypeM public void Materialize(Frame frame, ref Quantum.BattlePlayerClass100ProjectileQComponent result, in PrototypeMaterializationContext context = default) { result.Direction = this.Direction; result.Speed = this.Speed; + result.Radius = this.Radius; MaterializeUser(frame, ref result, in context); } } @@ -348,6 +354,7 @@ public unsafe class BattlePlayerDataQComponentPrototype : ComponentPrototype SpawnBehaviour; public QBoolean MovementEnabled; @@ -381,6 +388,7 @@ public void Materialize(Frame frame, ref Quantum.BattlePlayerDataQComponent resu this.Stats.Materialize(frame, ref result.Stats, in context); result.GridExtendTop = this.GridExtendTop; result.GridExtendBottom = this.GridExtendBottom; + result.DisableMovement = this.DisableMovement; result.DisableRotation = this.DisableRotation; result.SpawnBehaviour = this.SpawnBehaviour; result.MovementEnabled = this.MovementEnabled; @@ -408,6 +416,7 @@ public unsafe partial class BattlePlayerDataTemplateQComponentPrototype : Compon public Int32 GridExtendTop; public Int32 GridExtendBottom; public Quantum.Prototypes.BattlePlayerHitboxTemplatePrototype Hitbox; + public QBoolean DisableMovement; public QBoolean DisableRotation; public Quantum.QEnum32 SpawnBehaviour; partial void MaterializeUser(Frame frame, ref Quantum.BattlePlayerDataTemplateQComponent result, in PrototypeMaterializationContext context); @@ -420,6 +429,7 @@ public void Materialize(Frame frame, ref Quantum.BattlePlayerDataTemplateQCompon result.GridExtendTop = this.GridExtendTop; result.GridExtendBottom = this.GridExtendBottom; this.Hitbox.Materialize(frame, ref result.Hitbox, in context); + result.DisableMovement = this.DisableMovement; result.DisableRotation = this.DisableRotation; result.SpawnBehaviour = this.SpawnBehaviour; MaterializeUser(frame, ref result, in context); diff --git a/Assets/QuantumUser/View/Generated/Quantum.CodeGen.UnityPrototypeAdapters.cs b/Assets/QuantumUser/View/Generated/Quantum.CodeGen.UnityPrototypeAdapters.cs index 2569b74fb2..c1a1e9c4a3 100644 --- a/Assets/QuantumUser/View/Generated/Quantum.CodeGen.UnityPrototypeAdapters.cs +++ b/Assets/QuantumUser/View/Generated/Quantum.CodeGen.UnityPrototypeAdapters.cs @@ -129,6 +129,7 @@ public unsafe partial class BattlePlayerDataQComponentPrototype : Quantum.Quantu public Quantum.Prototypes.BattlePlayerStatsPrototype Stats; public Int32 GridExtendTop; public Int32 GridExtendBottom; + public QBoolean DisableMovement; public QBoolean DisableRotation; public Quantum.QEnum32 SpawnBehaviour; public QBoolean MovementEnabled; @@ -159,6 +160,7 @@ public override Quantum.Prototypes.BattlePlayerDataQComponentPrototype Convert(Q converter.Convert(this.Stats, out result.Stats); converter.Convert(this.GridExtendTop, out result.GridExtendTop); converter.Convert(this.GridExtendBottom, out result.GridExtendBottom); + converter.Convert(this.DisableMovement, out result.DisableMovement); converter.Convert(this.DisableRotation, out result.DisableRotation); converter.Convert(this.SpawnBehaviour, out result.SpawnBehaviour); converter.Convert(this.MovementEnabled, out result.MovementEnabled);