Hygiene B2: dead-code removal
Delete (unreferenced in any scene, per operator decision):
- TrainingDummy* chain (authoring/spawner/system/components/prefab) + UpgradePickup* chain (authoring/spawner/systems/components/prefab); remove TrainingDummyTag from the 3 live combat queries (AbilityFire/Melee/HealthApplyDamage now key on EnemyTag) and repoint HealthApplyDamageSystemTests to EnemyTag.
- Dead RPC RegionTransitSystem + RegionTransitRequest (no sender, ungated) + its test.
- Heartbeat + HeartbeatSystem (no WorldSystemFilter, ran no-op every tick) + its test.
- BuildSendSystem dead conveyor/pylon dev hooks (s_ConveyorDir, [/] rotation, Place{Pylon,Harvester,Conveyor} statics).
- Deprecated CyclePhase alias consts (Expedition/Defend/Build/*Ticks); repoint WaveSystemTests to Siege/Calm.
- Unread FeelConfig fields (HitFlashDurationMs, RumbleHeavy) + dangling HudUi doc-comments + stale crefs.
451/451 EditMode tests pass. CLAUDE.md HeartbeatSystemTests example ref to be repointed in B7.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the training-dummy enemy prefab. Bakes a stationary, damageable auto-target
|
||||
/// candidate: <see cref="TrainingDummyTag"/> marks it for the ability auto-target cone,
|
||||
/// <see cref="Health"/> and <see cref="HitRadius"/> make it a valid projectile hit target, and a
|
||||
/// <see cref="DamageEvent"/> buffer receives server-authoritative hits. Dummies are NOT ghosts and
|
||||
/// carry no <c>GhostOwner</c>, so projectiles never treat them as the firing owner.
|
||||
/// <c>GetEntity(TransformUsageFlags.Dynamic)</c> ensures a runtime LocalTransform for hit tests
|
||||
/// and spawn placement.
|
||||
/// </summary>
|
||||
public class TrainingDummyAuthoring : MonoBehaviour
|
||||
{
|
||||
[Min(0f), Tooltip("Starting and maximum health for the dummy.")]
|
||||
public float MaxHealth = 60f;
|
||||
|
||||
[Min(0f), Tooltip("World-unit radius used by the projectile hit test.")]
|
||||
public float HitRadius = 0.8f;
|
||||
|
||||
private class TrainingDummyBaker : Baker<TrainingDummyAuthoring>
|
||||
{
|
||||
public override void Bake(TrainingDummyAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
|
||||
AddComponent<TrainingDummyTag>(entity);
|
||||
AddComponent(entity, new Health
|
||||
{
|
||||
Current = authoring.MaxHealth,
|
||||
Max = authoring.MaxHealth
|
||||
});
|
||||
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
||||
AddBuffer<DamageEvent>(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c32aebeb7bfbb464898dfee8e6e87e6c
|
||||
@@ -1,48 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the baked <see cref="TrainingDummySpawner"/> singleton. Place this on a single
|
||||
/// GameObject in the gameplay subscene; at runtime the server-only
|
||||
/// <c>TrainingDummySpawnSystem</c> reads the singleton, instantiates <see cref="Count"/> dummies
|
||||
/// laid out along +X from <see cref="Origin"/> at <see cref="Spacing"/> intervals, then destroys
|
||||
/// the singleton so it fires exactly once. The entity itself carries no transform
|
||||
/// (<c>TransformUsageFlags.None</c>); only the referenced <see cref="DummyPrefab"/> needs a
|
||||
/// runtime-mutable LocalTransform (<c>TransformUsageFlags.Dynamic</c>).
|
||||
/// </summary>
|
||||
public class TrainingDummySpawnerAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Training dummy prefab to instantiate. Must carry TrainingDummyAuthoring.")]
|
||||
public GameObject DummyPrefab;
|
||||
|
||||
[Min(0)]
|
||||
[Tooltip("How many dummies to spawn.")]
|
||||
public int Count = 3;
|
||||
|
||||
[Min(0f)]
|
||||
[Tooltip("World-unit spacing between consecutive dummies along +X.")]
|
||||
public float Spacing = 3f;
|
||||
|
||||
[Tooltip("World-space position of the first dummy.")]
|
||||
public Vector3 Origin = new Vector3(0, 0, 8);
|
||||
|
||||
private class TrainingDummySpawnerBaker : Baker<TrainingDummySpawnerAuthoring>
|
||||
{
|
||||
public override void Bake(TrainingDummySpawnerAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
||||
|
||||
AddComponent(entity, new TrainingDummySpawner
|
||||
{
|
||||
Prefab = GetEntity(authoring.DummyPrefab, TransformUsageFlags.Dynamic),
|
||||
Count = authoring.Count,
|
||||
Spacing = authoring.Spacing,
|
||||
Origin = authoring.Origin
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51cc543c146d84239ba6dc219221df18
|
||||
@@ -1,43 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for an upgrade pickup ghost prefab: a world object that grants one stat modifier to the
|
||||
/// first player that overlaps it (server-authoritative, applied by <c>UpgradePickupSystem</c>) and
|
||||
/// then despawns. Bake the prefab as an interpolated ghost (add a GhostAuthoringComponent) so clients
|
||||
/// see it appear and despawn. <c>GetEntity(TransformUsageFlags.Dynamic)</c> gives it a world transform.
|
||||
/// </summary>
|
||||
public class UpgradePickupAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Which stat the granted modifier targets.")]
|
||||
public StatTarget Target = StatTarget.Damage;
|
||||
|
||||
[Tooltip("How the granted modifier combines.")]
|
||||
public ModOp Op = ModOp.Flat;
|
||||
|
||||
[Tooltip("Modifier magnitude: flat amount, or fractional percent (0.1 = +10%).")]
|
||||
public float Value = 10f;
|
||||
|
||||
[Tooltip("Overlap radius (world units) for the player pickup test.")]
|
||||
[Min(0f)] public float HitRadius = 1f;
|
||||
|
||||
private class UpgradePickupBaker : Baker<UpgradePickupAuthoring>
|
||||
{
|
||||
public override void Bake(UpgradePickupAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new UpgradePickup
|
||||
{
|
||||
Target = (byte)authoring.Target,
|
||||
Op = (byte)authoring.Op,
|
||||
Value = authoring.Value,
|
||||
SourceId = 0u,
|
||||
});
|
||||
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07e6d40378fcb43c5be706ef96cb4bb2
|
||||
@@ -1,48 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the baked <see cref="UpgradePickupSpawner"/> singleton (mirrors
|
||||
/// TrainingDummySpawnerAuthoring). Place on a single GameObject in the gameplay subscene; the
|
||||
/// server-only <c>UpgradePickupSpawnSystem</c> reads it, spawns <see cref="Count"/> pickups along +X
|
||||
/// from <see cref="Origin"/> at <see cref="Spacing"/> intervals, then destroys the singleton so it
|
||||
/// fires exactly once. The entity carries no transform; only the prefab needs a runtime transform.
|
||||
/// </summary>
|
||||
public class UpgradePickupSpawnerAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Upgrade pickup prefab to instantiate. Must carry UpgradePickupAuthoring.")]
|
||||
public GameObject PickupPrefab;
|
||||
|
||||
[Min(0)]
|
||||
[Tooltip("How many pickups to spawn.")]
|
||||
public int Count = 2;
|
||||
|
||||
[Min(0f)]
|
||||
[Tooltip("World-unit spacing between consecutive pickups along +X.")]
|
||||
public float Spacing = 3f;
|
||||
|
||||
[Tooltip("World-space position of the first pickup.")]
|
||||
public Vector3 Origin = new Vector3(-4f, 0f, 6f);
|
||||
|
||||
private class UpgradePickupSpawnerBaker : Baker<UpgradePickupSpawnerAuthoring>
|
||||
{
|
||||
public override void Bake(UpgradePickupSpawnerAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
||||
|
||||
AddComponent(entity, new UpgradePickupSpawner
|
||||
{
|
||||
Prefab = authoring.PickupPrefab != null
|
||||
? GetEntity(authoring.PickupPrefab, TransformUsageFlags.Dynamic)
|
||||
: Entity.Null,
|
||||
Count = authoring.Count,
|
||||
Spacing = authoring.Spacing,
|
||||
Origin = authoring.Origin,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e367eb55e2c2248f18be10d6c3c9ad67
|
||||
@@ -16,14 +16,13 @@ namespace ProjectM.Client
|
||||
/// <see cref="BuildPaletteState.Active"/>), so the place-click never also fires. Build mode is suspended while
|
||||
/// the pause overlay is open, and the frame a palette button changes the selection never also places.
|
||||
/// (2) keyboard hotkeys (fallback, suppressed in palette mode): B/V/F place at the local player's cell.
|
||||
/// Editor-only statics (PlaceStructure / PlaceHarvester / ...) drive the same RPC path from execute_code for
|
||||
/// Editor-only statics (PlaceStructure / PlaceTurret / ...) drive the same RPC path from execute_code for
|
||||
/// headless validation. Managed SystemBase; UnityEngine.InputSystem types are fully qualified to avoid the
|
||||
/// ProjectM.Simulation.PlayerInput name collision. The server re-validates legality + cost authoritatively.
|
||||
/// </summary>
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
|
||||
public partial class BuildSendSystem : SystemBase
|
||||
{
|
||||
static byte s_ConveyorDir; // key-flow pending conveyor facing (0=+X,1=-X,2=+Z,3=-Z)
|
||||
|
||||
// Dev hotkey fallback: key -> buildable (Conveyor uses s_ConveyorDir for facing).
|
||||
static readonly (UnityEngine.InputSystem.Key Key, byte Type)[] s_BuildHotkeys =
|
||||
@@ -62,18 +61,9 @@ namespace ProjectM.Client
|
||||
/// <summary>EDITOR / execute_code hook: queue a wall placement at a specific cell.</summary>
|
||||
public static void PlaceWall(int cellX, int cellZ) => PlaceStructure(StructureType.Wall, cellX, cellZ);
|
||||
|
||||
/// <summary>EDITOR / execute_code hook: queue a pylon placement at a specific cell.</summary>
|
||||
public static void PlacePylon(int cellX, int cellZ) => PlaceStructure(StructureType.Pylon, cellX, cellZ);
|
||||
|
||||
/// <summary>EDITOR / execute_code hook: queue a harvester placement at a specific cell.</summary>
|
||||
public static void PlaceHarvester(int cellX, int cellZ) => PlaceStructure(StructureType.Harvester, cellX, cellZ);
|
||||
|
||||
/// <summary>EDITOR / execute_code hook: queue a fabricator placement at a specific cell.</summary>
|
||||
public static void PlaceFabricator(int cellX, int cellZ) => PlaceStructure(StructureType.Fabricator, cellX, cellZ);
|
||||
|
||||
/// <summary>EDITOR / execute_code hook: queue a conveyor placement facing direction (0=+X,1=-X,2=+Z,3=-Z).</summary>
|
||||
public static void PlaceConveyor(int cellX, int cellZ, byte direction) => PlaceStructure(StructureType.Conveyor, cellX, cellZ, direction);
|
||||
|
||||
#endif
|
||||
|
||||
protected override void OnCreate()
|
||||
@@ -106,14 +96,9 @@ namespace ProjectM.Client
|
||||
// Hotkey fallback (suppressed while the palette build mode is active).
|
||||
if (keyboard != null && !BuildPaletteState.Active)
|
||||
{
|
||||
if (keyboard.leftBracketKey.wasPressedThisFrame)
|
||||
s_ConveyorDir = (byte)((s_ConveyorDir + 3) % 4);
|
||||
if (keyboard.rightBracketKey.wasPressedThisFrame)
|
||||
s_ConveyorDir = (byte)((s_ConveyorDir + 1) % 4);
|
||||
|
||||
foreach (var (key, type) in s_BuildHotkeys)
|
||||
if (keyboard[key].wasPressedThisFrame && TryGetLocalPlayerCell(out int2 cell))
|
||||
SendBuild(connection, type, cell.x, cell.y, type == StructureType.Conveyor ? s_ConveyorDir : (byte)0);
|
||||
SendBuild(connection, type, cell.x, cell.y, (byte)0);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
@@ -45,8 +45,6 @@ namespace ProjectM.Client
|
||||
public static float HitStopRefDamage;
|
||||
/// <summary>Tint for the (deferred) enemy material hit-flash — exposed now, wired in the ShaderGraph slice.</summary>
|
||||
public static Color HitFlashColor;
|
||||
/// <summary>Duration (ms) of the deferred enemy hit-flash.</summary>
|
||||
public static float HitFlashDurationMs;
|
||||
/// <summary>Master gate for the (deferred) true freeze-frame hit-stop. FALSE for v1 (camera-punch only).</summary>
|
||||
public static bool HitStopFreezeEnabled;
|
||||
|
||||
@@ -130,8 +128,6 @@ namespace ProjectM.Client
|
||||
public static float RumbleHit;
|
||||
/// <summary>Rumble strength on a kill.</summary>
|
||||
public static float RumbleKill;
|
||||
/// <summary>Rumble strength on dash / local death (the heaviest).</summary>
|
||||
public static float RumbleHeavy;
|
||||
/// <summary>Seconds a rumble pulse lasts before it auto-stops.</summary>
|
||||
public static float RumbleDurationSec;
|
||||
|
||||
@@ -190,7 +186,6 @@ namespace ProjectM.Client
|
||||
HitStopMaxFrames = 2; // C4: a 2-frame (~33ms) camera hold reads as crunch, not a lag-y stutter
|
||||
HitStopRefDamage = 30f;
|
||||
HitFlashColor = new Color(1f, 0.85f, 0.55f, 1f);
|
||||
HitFlashDurationMs = 80f;
|
||||
HitStopFreezeEnabled = true; // C4: enable the finisher hit-stop hold (presentation-only camera freeze, bounded below)
|
||||
|
||||
// Feature 1/2 death
|
||||
@@ -239,7 +234,6 @@ namespace ProjectM.Client
|
||||
RumbleEnabled = true;
|
||||
RumbleHit = 0.25f;
|
||||
RumbleKill = 0.45f;
|
||||
RumbleHeavy = 0.6f;
|
||||
RumbleDurationSec = 0.12f;
|
||||
|
||||
// Deferred-items pass (2026-06)
|
||||
|
||||
@@ -146,8 +146,6 @@ namespace ProjectM.Client
|
||||
return e;
|
||||
}
|
||||
|
||||
/// <summary>True when the theme is loaded and a sprite is present (callers choose icon vs text fallback).</summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// An input-prompt chip: the Synty key/button glyph (left untinted to keep its printed face) when present,
|
||||
@@ -170,7 +168,5 @@ namespace ProjectM.Client
|
||||
return cap;
|
||||
}
|
||||
|
||||
/// <summary>Apply a uniform 9-slice (horizontal / vertical source-texture px) to a skinned element.</summary>
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ProjectM.Server
|
||||
/// this tick), subtracts the summed amount from <see cref="Health"/>, then clears the buffer so
|
||||
/// each hit is applied exactly once. Entities that carry character stats (players) clamp to their
|
||||
/// data-driven <see cref="EffectiveCharacterStats.MaxHealth"/> ceiling; others (training dummies)
|
||||
/// clamp at zero. A dead <see cref="TrainingDummyTag"/> is destroyed; player death is deferred.
|
||||
/// clamp at zero. A dead <see cref="EnemyTag"/> is destroyed; player death is deferred.
|
||||
/// Health.Current is a <c>[GhostField]</c>, so the new value replicates to clients for display.
|
||||
///
|
||||
/// Runs server-only (<see cref="WorldSystemFilterFlags.ServerSimulation"/>) inside the prediction
|
||||
@@ -156,7 +156,7 @@ namespace ProjectM.Server
|
||||
if (SystemAPI.HasComponent<IsLunging>(entity)) SystemAPI.SetComponentEnabled<IsLunging>(entity, false);
|
||||
}
|
||||
}
|
||||
else if (SystemAPI.HasComponent<TrainingDummyTag>(entity) || SystemAPI.HasComponent<EnemyTag>(entity) || SystemAPI.HasComponent<Destructible>(entity))
|
||||
else if (SystemAPI.HasComponent<EnemyTag>(entity) || SystemAPI.HasComponent<Destructible>(entity))
|
||||
ecb.DestroyEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Transforms;
|
||||
|
||||
namespace ProjectM.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// Server-only, one-shot dummy spawner. On its first update it reads the baked
|
||||
/// <see cref="TrainingDummySpawner"/> singleton and instantiates <c>Count</c> training-dummy
|
||||
/// ghosts in a row, spaced <c>Spacing</c> world-units apart along +X starting at <c>Origin</c>.
|
||||
/// It then destroys the spawner singleton entity so <c>RequireForUpdate<TrainingDummySpawner></c>
|
||||
/// is no longer satisfied and the system stops running (idempotent: dummies are spawned exactly once).
|
||||
/// Runs in the default <see cref="SimulationSystemGroup"/> (NOT the prediction loop) since spawning is
|
||||
/// a non-predicted, server-authoritative event; the dummies replicate to clients as interpolated ghosts.
|
||||
/// All structural changes are batched through an <see cref="EntityCommandBuffer"/>.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||
public partial struct TrainingDummySpawnSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnCreate(ref SystemState state)
|
||||
{
|
||||
state.RequireForUpdate<TrainingDummySpawner>();
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
// Grab both the singleton entity (to destroy when done) and its baked config.
|
||||
var spawnerEntity = SystemAPI.GetSingletonEntity<TrainingDummySpawner>();
|
||||
var spawner = SystemAPI.GetComponent<TrainingDummySpawner>(spawnerEntity);
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
|
||||
for (int i = 0; i < spawner.Count; i++)
|
||||
{
|
||||
var dummy = ecb.Instantiate(spawner.Prefab);
|
||||
var position = spawner.Origin + new float3(i * spawner.Spacing, 0f, 0f);
|
||||
ecb.SetComponent(dummy, LocalTransform.FromPosition(position));
|
||||
}
|
||||
|
||||
// One-shot: remove the spawner so RequireForUpdate fails and the system idles.
|
||||
ecb.DestroyEntity(spawnerEntity);
|
||||
|
||||
ecb.Playback(state.EntityManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7673acbc74f7a4bddbca0679122511ea
|
||||
@@ -1,56 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Transforms;
|
||||
|
||||
namespace ProjectM.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// Server-only, one-shot upgrade-pickup spawner (mirrors TrainingDummySpawnSystem). On its first
|
||||
/// update it reads the baked <see cref="UpgradePickupSpawner"/> singleton and instantiates
|
||||
/// <c>Count</c> pickup ghosts in a row, spaced <c>Spacing</c> world-units apart along +X starting at
|
||||
/// <c>Origin</c>, then destroys the singleton so the system idles (spawned exactly once). Runs in the
|
||||
/// default <see cref="SimulationSystemGroup"/> (NOT the prediction loop); pickups replicate to clients
|
||||
/// as interpolated ghosts. Structural changes are batched through an <see cref="EntityCommandBuffer"/>.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||
public partial struct UpgradePickupSpawnSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnCreate(ref SystemState state)
|
||||
{
|
||||
state.RequireForUpdate<UpgradePickupSpawner>();
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
var spawnerEntity = SystemAPI.GetSingletonEntity<UpgradePickupSpawner>();
|
||||
var spawner = SystemAPI.GetComponent<UpgradePickupSpawner>(spawnerEntity);
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
|
||||
if (spawner.Prefab != Entity.Null)
|
||||
{
|
||||
// Preserve the prefab's baked scale/rotation (FromPosition would reset Scale to 1).
|
||||
var baseXform = SystemAPI.GetComponent<LocalTransform>(spawner.Prefab);
|
||||
for (int i = 0; i < spawner.Count; i++)
|
||||
{
|
||||
var pickup = ecb.Instantiate(spawner.Prefab);
|
||||
var position = spawner.Origin + new float3(i * spawner.Spacing, 0f, 0f);
|
||||
var xform = baseXform;
|
||||
xform.Position = position;
|
||||
ecb.SetComponent(pickup, xform);
|
||||
}
|
||||
}
|
||||
|
||||
// One-shot: remove the spawner so RequireForUpdate fails and the system idles.
|
||||
ecb.DestroyEntity(spawnerEntity);
|
||||
|
||||
ecb.Playback(state.EntityManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 602544c80ca5649258a9d6ca9ad74f79
|
||||
@@ -1,78 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Transforms;
|
||||
|
||||
namespace ProjectM.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// Server-authoritative upgrade pickup grant. When a player overlaps an <see cref="UpgradePickup"/>
|
||||
/// (planar XZ distance within the pickup's <see cref="HitRadius"/>), appends the pickup's modifier to
|
||||
/// the player's replicated <see cref="StatModifier"/> buffer (which replicates to the predicting
|
||||
/// owner, so StatRecomputeSystem folds identical effective stats on both worlds) and destroys the
|
||||
/// pickup. Runs in the default <see cref="SimulationSystemGroup"/> (NOT the prediction loop) since the
|
||||
/// grant is a non-predicted server event. The buffer append + pickup destroy are batched through an
|
||||
/// <see cref="EntityCommandBuffer"/> played back immediately — so a plain-world EditMode test needs no
|
||||
/// separate ECB system.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||
public partial struct UpgradePickupSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnCreate(ref SystemState state)
|
||||
{
|
||||
state.RequireForUpdate<UpgradePickup>();
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
// Snapshot modifiable players (carrying the modifier buffer + a transform) once this tick.
|
||||
var playerEntities = new NativeList<Entity>(Allocator.Temp);
|
||||
var playerPositions = new NativeList<float3>(Allocator.Temp);
|
||||
foreach (var (xform, e) in
|
||||
SystemAPI.Query<RefRO<LocalTransform>>()
|
||||
.WithAll<PlayerTag, StatModifier>()
|
||||
.WithEntityAccess())
|
||||
{
|
||||
playerEntities.Add(e);
|
||||
playerPositions.Add(xform.ValueRO.Position);
|
||||
}
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
|
||||
foreach (var (xform, radius, pickup, pickupEntity) in
|
||||
SystemAPI.Query<RefRO<LocalTransform>, RefRO<HitRadius>, RefRO<UpgradePickup>>()
|
||||
.WithEntityAccess())
|
||||
{
|
||||
float2 pp = new float2(xform.ValueRO.Position.x, xform.ValueRO.Position.z);
|
||||
float r = radius.ValueRO.Value;
|
||||
|
||||
for (int i = 0; i < playerEntities.Length; i++)
|
||||
{
|
||||
float2 cp = new float2(playerPositions[i].x, playerPositions[i].z);
|
||||
if (math.distancesq(pp, cp) > r * r)
|
||||
continue;
|
||||
|
||||
ecb.AppendToBuffer(playerEntities[i], new StatModifier
|
||||
{
|
||||
Target = pickup.ValueRO.Target,
|
||||
Op = pickup.ValueRO.Op,
|
||||
Value = pickup.ValueRO.Value,
|
||||
SourceId = pickup.ValueRO.SourceId,
|
||||
});
|
||||
ecb.DestroyEntity(pickupEntity);
|
||||
break; // granted to the first overlapping player, then despawns
|
||||
}
|
||||
}
|
||||
|
||||
ecb.Playback(state.EntityManager);
|
||||
ecb.Dispose();
|
||||
playerEntities.Dispose();
|
||||
playerPositions.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3d9ef25fbc464e52aa342b531d6f35e
|
||||
@@ -1,71 +0,0 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Burst;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.NetCode;
|
||||
using Unity.Transforms;
|
||||
|
||||
namespace ProjectM.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// Server-authoritative handler for <see cref="RegionTransitRequest"/> RPCs. Resolves the sender's player
|
||||
/// (via the source connection's <see cref="NetworkId"/> -> <see cref="GhostOwner"/>), flips its
|
||||
/// <see cref="RegionTag"/> to the requested region, and teleports it to that region's origin
|
||||
/// (<see cref="RegionMath.RegionOrigin"/>, centered on the base via <see cref="BaseGridMath.PlotCenter"/>).
|
||||
/// Runs in the default server SimulationSystemGroup (NOT the prediction loop) so the transit applies once;
|
||||
/// the next snapshot reconciles the owner-predicted client and <see cref="RegionRelevancySystem"/> re-scopes
|
||||
/// which region's ghosts the connection receives. Mirrors the <see cref="StorageOpReceiveSystem"/> RPC shape.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||
public partial struct RegionTransitSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnCreate(ref SystemState state)
|
||||
{
|
||||
state.RequireForUpdate<BaseAnchor>();
|
||||
|
||||
var builder = new EntityQueryBuilder(Allocator.Temp)
|
||||
.WithAll<RegionTransitRequest, ReceiveRpcCommandRequest>();
|
||||
state.RequireForUpdate(state.GetEntityQuery(builder));
|
||||
}
|
||||
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
var baseCenter = BaseGridMath.PlotCenter(SystemAPI.GetSingleton<BaseAnchor>());
|
||||
|
||||
// Map connection NetworkId -> player entity.
|
||||
var playerByConn = new NativeHashMap<int, Entity>(8, Allocator.Temp);
|
||||
foreach (var (owner, entity) in
|
||||
SystemAPI.Query<RefRO<GhostOwner>>().WithAll<PlayerTag, RegionTag>().WithEntityAccess())
|
||||
{
|
||||
playerByConn[owner.ValueRO.NetworkId] = entity;
|
||||
}
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
|
||||
foreach (var (request, receive, requestEntity) in
|
||||
SystemAPI.Query<RefRO<RegionTransitRequest>, RefRO<ReceiveRpcCommandRequest>>().WithEntityAccess())
|
||||
{
|
||||
var connEntity = receive.ValueRO.SourceConnection;
|
||||
if (SystemAPI.HasComponent<NetworkId>(connEntity))
|
||||
{
|
||||
int connId = SystemAPI.GetComponent<NetworkId>(connEntity).Value;
|
||||
if (playerByConn.TryGetValue(connId, out var player))
|
||||
{
|
||||
byte target = request.ValueRO.TargetRegion;
|
||||
SystemAPI.GetComponentRW<RegionTag>(player).ValueRW.Region = target;
|
||||
SystemAPI.GetComponentRW<LocalTransform>(player).ValueRW.Position =
|
||||
RegionMath.RegionOrigin(target, baseCenter);
|
||||
}
|
||||
}
|
||||
|
||||
ecb.DestroyEntity(requestEntity);
|
||||
}
|
||||
|
||||
ecb.Playback(state.EntityManager);
|
||||
playerByConn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d6ce89f189d984c83cd213d86d4b02
|
||||
@@ -80,7 +80,7 @@ namespace ProjectM.Simulation
|
||||
if (isServer)
|
||||
{
|
||||
foreach (var (tx, th, te) in
|
||||
SystemAPI.Query<RefRO<LocalTransform>, RefRO<Health>>().WithAny<TrainingDummyTag, EnemyTag>().WithEntityAccess())
|
||||
SystemAPI.Query<RefRO<LocalTransform>, RefRO<Health>>().WithAll<EnemyTag>().WithEntityAccess())
|
||||
{
|
||||
if (th.ValueRO.Current <= 0f) continue; // B3: corpses are neither aim magnets nor cleave targets
|
||||
candidatePositions.Add(tx.ValueRO.Position);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// EB-1 — opt-in marker for an entity that <see cref="ProjectM.Server.HealthApplyDamageSystem"/> DESTROYS when
|
||||
/// its <see cref="Health"/> hits 0 (alongside <c>TrainingDummyTag</c>/<c>EnemyTag</c>). Baked ONLY on the
|
||||
/// its <see cref="Health"/> hits 0 (alongside <c>EnemyTag</c>). Baked ONLY on the
|
||||
/// player-built structure ghosts (Turret/Wall/Pylon) so "machines can die". DELIBERATELY a distinct tag rather
|
||||
/// than gating on bare <see cref="PlacedStructure"/>: that identity is SHARED by the reserved M7 automation
|
||||
/// machines (Harvester/Fabricator/Conveyor) whose teardown would silently drop in-flight conveyor cargo — the
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ProjectM.Simulation
|
||||
/// Hit points for any damageable ghost (players, training dummies). Server-authoritative:
|
||||
/// only server systems write <see cref="Current"/>; clients receive it via the [GhostField]
|
||||
/// for display and prediction reconciliation. <see cref="Max"/> is baked identically on both
|
||||
/// worlds and is not replicated. Added by PlayerBaker / TrainingDummyBaker.
|
||||
/// worlds and is not replicated. Added by PlayerBaker.
|
||||
/// </summary>
|
||||
public struct Health : IComponentData
|
||||
{
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Baked singleton describing the training-dummy field to spawn at world start. Consumed once by
|
||||
/// the server-only TrainingDummySpawnSystem, which instantiates <see cref="Count"/> dummies from
|
||||
/// <see cref="Prefab"/> and then destroys this singleton so the spawn runs exactly once. Not
|
||||
/// replicated — dummies are spawned authoritatively on the server and reach clients as ghosts.
|
||||
/// </summary>
|
||||
public struct TrainingDummySpawner : IComponentData
|
||||
{
|
||||
/// <summary>Baked entity prefab to instantiate for each dummy.</summary>
|
||||
public Entity Prefab;
|
||||
|
||||
/// <summary>Number of dummies to spawn.</summary>
|
||||
public int Count;
|
||||
|
||||
/// <summary>World-unit gap between consecutive dummies along the spawn line (X axis).</summary>
|
||||
public float Spacing;
|
||||
|
||||
/// <summary>World-space position of the first dummy; subsequent dummies offset by <see cref="Spacing"/>.</summary>
|
||||
public float3 Origin;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8f27601fb20640718aaed2c48d1d016
|
||||
@@ -1,11 +0,0 @@
|
||||
using Unity.Entities;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Zero-size marker identifying a training-dummy enemy. Server auto-target collects
|
||||
/// <see cref="TrainingDummyTag"/> entities as candidates, and the damage/death path destroys
|
||||
/// a dummy when its <c>Health.Current</c> reaches zero. Added by TrainingDummyBaker.
|
||||
/// </summary>
|
||||
public struct TrainingDummyTag : IComponentData { }
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebe9114e40db748669d89ef861415bac
|
||||
@@ -1,17 +0,0 @@
|
||||
using Unity.Entities;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// A world pickup that, on player overlap, grants one StatModifier (server-authoritative) and is then
|
||||
/// destroyed. Mirrors a single StatModifier payload (Target/Op as bytes). The pickup is an
|
||||
/// interpolated ghost so clients see and despawn it; the grant is applied by UpgradePickupSystem.
|
||||
/// </summary>
|
||||
public struct UpgradePickup : IComponentData
|
||||
{
|
||||
public byte Target; // StatTarget
|
||||
public byte Op; // ModOp
|
||||
public float Value;
|
||||
public uint SourceId;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0d34f4d0b12241c7b0f0b1d002142f3
|
||||
@@ -1,17 +0,0 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Singleton describing how many upgrade pickups to spawn and where (mirrors TrainingDummySpawner).
|
||||
/// Consumed once by the server's UpgradePickupSpawnSystem.
|
||||
/// </summary>
|
||||
public struct UpgradePickupSpawner : IComponentData
|
||||
{
|
||||
public Entity Prefab;
|
||||
public float3 Origin;
|
||||
public int Count;
|
||||
public float Spacing;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 059368b62be834614ae3a110a51d42da
|
||||
@@ -1,13 +0,0 @@
|
||||
using Unity.Entities;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Trivial unmanaged component used by the setup smoke test to prove the ECS
|
||||
/// compile + source-gen + tick path works. Safe to delete once real gameplay exists.
|
||||
/// </summary>
|
||||
public struct Heartbeat : IComponentData
|
||||
{
|
||||
public int Tick;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0347bd6d99db438f85ec1985b7f81e1
|
||||
@@ -1,23 +0,0 @@
|
||||
using Unity.Burst;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Smoke-test system: increments every <see cref="Heartbeat"/> once per tick.
|
||||
/// Default (no <c>[WorldSystemFilter]</c>) so it runs in the SimulationSystemGroup of
|
||||
/// every world. Burst-compiled and unmanaged (<see cref="ISystem"/>) per DOTS convention.
|
||||
/// </summary>
|
||||
[BurstCompile]
|
||||
public partial struct HeartbeatSystem : ISystem
|
||||
{
|
||||
[BurstCompile]
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
foreach (var heartbeat in SystemAPI.Query<RefRW<Heartbeat>>())
|
||||
{
|
||||
heartbeat.ValueRW.Tick++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78349f49733934f348acb488689fc9ec
|
||||
@@ -174,7 +174,7 @@ namespace ProjectM.Simulation
|
||||
var enemyPositions = new NativeList<float3>(Allocator.Temp);
|
||||
foreach (var (xform, health, enemyEntity) in
|
||||
SystemAPI.Query<RefRO<LocalTransform>, RefRO<Health>>()
|
||||
.WithAny<EnemyTag, TrainingDummyTag>()
|
||||
.WithAll<EnemyTag>()
|
||||
.WithEntityAccess())
|
||||
{
|
||||
if (health.ValueRO.Current <= 0f)
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace ProjectM.Simulation
|
||||
/// <para>
|
||||
/// <b>Values that already live in a clear, public, semantically-named home (NOT duplicated here):</b>
|
||||
/// <list type="bullet">
|
||||
/// <item><see cref="CyclePhase.ExpeditionTicks"/> / <see cref="CyclePhase.BuildTicks"/> — cycle phase durations.</item>
|
||||
/// <item><see cref="RegionMath.ExpeditionOffsetX"/> — base→expedition world-space offset.</item>
|
||||
/// <item>Per-ability/character stats — authored in ScriptableObjects, baked to the AbilityDatabase blob (M3).</item>
|
||||
/// </list>
|
||||
|
||||
@@ -39,22 +39,6 @@ namespace ProjectM.Simulation
|
||||
/// <summary>The base is under assault by a Husk wave (event-triggered; ends when the wave is cleared).</summary>
|
||||
public const byte Siege = 1;
|
||||
|
||||
// ---- Deprecated aliases (kept so HUD/audio/tests keep compiling through the cut-over; cleaned up later). ----
|
||||
|
||||
/// <summary>DEPRECATED alias of <see cref="Calm"/>.</summary>
|
||||
public const byte Expedition = 0;
|
||||
|
||||
/// <summary>DEPRECATED alias of <see cref="Siege"/>.</summary>
|
||||
public const byte Defend = 1;
|
||||
|
||||
/// <summary>DEPRECATED, unreachable — the timed Build phase is retired.</summary>
|
||||
public const byte Build = 2;
|
||||
|
||||
/// <summary>DEPRECATED — the forced Expedition timer is retired (the loop is player-driven). Kept so existing crefs resolve.</summary>
|
||||
public const uint ExpeditionTicks = 3600;
|
||||
|
||||
/// <summary>DEPRECATED — the forced Build timer is retired. Kept so existing crefs resolve.</summary>
|
||||
public const uint BuildTicks = 1200;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using Unity.NetCode;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Client -> server request to move the sender's player between world regions (base <-> expedition).
|
||||
/// A one-off action, so an RPC (not a per-tick predicted input), mirroring <see cref="StorageOpRequest"/>.
|
||||
/// TargetRegion is a byte (see <see cref="RegionId"/>) to keep the generated serializer trivial. The
|
||||
/// server teleports the sender's player to the region origin and flips its <see cref="RegionTag"/>, which
|
||||
/// re-scopes GhostRelevancy so the client gains the target region's ghosts and drops the old region's.
|
||||
/// </summary>
|
||||
public struct RegionTransitRequest : IRpcCommand
|
||||
{
|
||||
/// <summary>Destination region id (see <see cref="RegionId"/>).</summary>
|
||||
public byte TargetRegion;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32c76b46284ed1845a412ca030de2499
|
||||
Reference in New Issue
Block a user