Import art/VFX asset packs + game-feel systems; normalize texture extensions to lowercase for LFS

Add BefourStudios SciFi environment packs, Gabriel Aguiar VFX, and the
ShaderCrew Toon Shader embedded packages, plus combat/enemy/wave/death
gameplay systems and supporting vault docs/screenshots.

Rename 11 vendor textures from uppercase .PNG/.HDR to lowercase so the
case-sensitive Git LFS filters (*.png/*.hdr) match on case-sensitive
filesystems (Linux CI, case-sensitive macOS), not just locally where
core.ignorecase=true masks the gap. Each .meta moved with its asset so
GUID references are preserved. All ~1000 binaries tracked via LFS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 22:50:43 -07:00
parent dd0064c377
commit e362aaeb43
4830 changed files with 1293057 additions and 38 deletions
@@ -0,0 +1,131 @@
using ProjectM.Simulation;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
using Unity.Transforms;
namespace ProjectM.Server
{
/// <summary>
/// Server-authoritative Husk AI: each tick every Husk seeks the nearest LIVING player and strikes on
/// contact. Husks are OWNERLESS INTERPOLATED ghosts (not predicted), so this runs SERVER-ONLY in the plain
/// <see cref="SimulationSystemGroup"/> — writing <see cref="LocalTransform"/> directly (replicated to clients
/// by the stock LocalTransform default variant; no hand-written <c>[GhostField]</c>). Ordered
/// <c>[UpdateAfter(PredictedSimulationSystemGroup)]</c> (the predicted group is OrderFirst, so UpdateBefore is ignored) so a contact <see cref="DamageEvent"/> appended this
/// tick is drained the following tick by <see cref="HealthApplyDamageSystem"/> (which runs inside the predicted
/// group on the server). No <c>Simulate</c> filter: interpolated ghosts are not predicted and the server has
/// no rollback, so every Husk advances exactly once per tick. Movement/attack math is the pure, deterministic
/// <see cref="EnemyAIMath"/>; server fixed-step <c>SystemAPI.Time.DeltaTime</c> is correct here (not the
/// rollback loop). Structural-free: the only deferred op is appending to the player's DamageEvent buffer.
/// </summary>
[BurstCompile]
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(PredictedSimulationSystemGroup))]
public partial struct EnemyAISystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<NetworkTime>();
state.RequireForUpdate(state.GetEntityQuery(ComponentType.ReadOnly<EnemyTag>()));
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
// Snapshot living player targets once this tick (stable query order).
var playerEntities = new NativeList<Entity>(Allocator.Temp);
var playerPositions = new NativeList<float3>(Allocator.Temp);
foreach (var (xform, health, entity) in
SystemAPI.Query<RefRO<LocalTransform>, RefRO<Health>>()
.WithAll<PlayerTag>()
.WithEntityAccess())
{
if (health.ValueRO.Current <= 0f)
continue; // don't chase or strike a corpse
playerEntities.Add(entity);
playerPositions.Add(xform.ValueRO.Position);
}
if (playerEntities.Length == 0)
{
playerEntities.Dispose();
playerPositions.Dispose();
return;
}
float dt = SystemAPI.Time.DeltaTime;
var serverTick = SystemAPI.GetSingleton<NetworkTime>().ServerTick;
var ecb = new EntityCommandBuffer(Allocator.Temp);
foreach (var (xform, stats, cooldown) in
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<EnemyAttackCooldown>>()
.WithAll<EnemyTag>())
{
float3 pos = xform.ValueRO.Position;
// Nearest living player (planar XZ).
int best = -1;
float bestSq = float.MaxValue;
for (int i = 0; i < playerPositions.Length; i++)
{
float2 d = playerPositions[i].xz - pos.xz;
float sq = math.lengthsq(d);
if (sq < bestSq)
{
bestSq = sq;
best = i;
}
}
float3 targetPos = playerPositions[best];
// Seek: stop just inside strike range so the Husk holds position to attack.
float stopDistance = stats.ValueRO.AttackRange * 0.9f;
float3 vel = EnemyAIMath.SeekVelocity(pos, targetPos, stats.ValueRO.MoveSpeed, stopDistance);
float3 newPos = pos + vel * dt;
newPos.y = pos.y; // hold the movement plane
xform.ValueRW.Position = newPos;
// Face the target (planar) for presentation.
float3 toTarget = targetPos - pos;
toTarget.y = 0f;
if (math.lengthsq(toTarget) > 1e-6f)
xform.ValueRW.Rotation = quaternion.LookRotationSafe(math.normalize(toTarget), math.up());
// Strike on contact once the cooldown has elapsed.
if (EnemyAIMath.InAttackRange(pos, targetPos, stats.ValueRO.AttackRange))
{
uint nextRaw = cooldown.ValueRO.NextAttackTick;
bool ready = true;
if (nextRaw != 0)
{
var nextTick = new NetworkTick(nextRaw);
if (nextTick.IsValid && nextTick.IsNewerThan(serverTick))
ready = false;
}
if (ready)
{
ecb.AppendToBuffer(playerEntities[best], new DamageEvent
{
Amount = stats.ValueRO.AttackDamage,
SourceNetworkId = -1, // environment / Husk, not a player
});
uint cooldownTicks = (uint)math.max(1, stats.ValueRO.AttackCooldownTicks);
cooldown.ValueRW.NextAttackTick = TickUtil.NonZero(serverTick.TickIndexForValidTick + cooldownTicks);
}
}
}
ecb.Playback(state.EntityManager);
ecb.Dispose();
playerEntities.Dispose();
playerPositions.Dispose();
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5ab8a84c266f92b4c80b39ad9904a71d
@@ -32,6 +32,7 @@ namespace ProjectM.Server
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(Allocator.Temp);
bool haveTick = SystemAPI.TryGetSingleton<NetworkTime>(out var netTime);
foreach (var (health, dmg, entity) in
SystemAPI.Query<RefRW<Health>, DynamicBuffer<DamageEvent>>()
@@ -40,6 +41,21 @@ namespace ProjectM.Server
if (dmg.Length == 0)
continue;
// Respawn invulnerability: a freshly-recovered player ignores damage for a window.
if (haveTick && netTime.ServerTick.IsValid && SystemAPI.HasComponent<RespawnInvuln>(entity))
{
uint until = SystemAPI.GetComponent<RespawnInvuln>(entity).UntilTick;
if (until != 0)
{
var untilTick = new NetworkTick(until);
if (untilTick.IsValid && untilTick.IsNewerThan(netTime.ServerTick))
{
dmg.Clear();
continue;
}
}
}
float total = 0f;
for (int i = 0; i < dmg.Length; i++)
total += dmg[i].Amount;
@@ -57,7 +73,7 @@ namespace ProjectM.Server
health.ValueRW.Current = newHp;
// Server-authoritative death: training dummies despawn; player death is deferred (clamp only).
if (health.ValueRO.Current <= 0f && SystemAPI.HasComponent<TrainingDummyTag>(entity))
if (health.ValueRO.Current <= 0f && (SystemAPI.HasComponent<TrainingDummyTag>(entity) || SystemAPI.HasComponent<EnemyTag>(entity)))
ecb.DestroyEntity(entity);
}
@@ -0,0 +1,80 @@
using ProjectM.Simulation;
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
using Unity.Transforms;
namespace ProjectM.Server
{
/// <summary>
/// Server-authoritative player death→respawn timing. The "is dead" GATE is derived every predicted tick from
/// replicated Health by <see cref="PlayerDeathStateSystem"/> (so movement/aim/fire stop on both server and
/// owner-client); THIS system owns the timer + the authoritative recovery. Runs server-only in the plain
/// <see cref="SimulationSystemGroup"/> AFTER the predicted group, so it observes this tick's post-damage Health.
/// On first seeing Health&lt;=0 it schedules a respawn tick; once due it refills Health to the effective max and
/// repositions the player to its deterministic base spawn slot (<see cref="PlayerSpawnMath"/>). Health.Current
/// (GhostField) + LocalTransform replicate, so the recovery reaches clients and the derived Dead clears.
/// </summary>
[BurstCompile]
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(PredictedSimulationSystemGroup))]
public partial struct PlayerRespawnSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<NetworkTime>();
state.RequireForUpdate<PlayerSpawner>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var serverTick = SystemAPI.GetSingleton<NetworkTime>().ServerTick;
if (!serverTick.IsValid)
return;
uint now = serverTick.TickIndexForValidTick;
var spawner = SystemAPI.GetSingleton<PlayerSpawner>();
float3 center = spawner.SpawnPoint;
if (SystemAPI.TryGetSingleton<BaseAnchor>(out var baseAnchor))
center = BaseGridMath.PlotCenter(baseAnchor);
foreach (var (health, respawn, invuln, xform, owner, eff) in
SystemAPI.Query<RefRW<Health>, RefRW<RespawnState>, RefRW<RespawnInvuln>, RefRW<LocalTransform>,
RefRO<GhostOwner>, RefRO<EffectiveCharacterStats>>()
.WithAll<PlayerTag>())
{
if (health.ValueRO.Current > 0f)
{
respawn.ValueRW.RespawnTick = 0; // alive: clear any pending schedule
continue;
}
// Dead this tick.
if (respawn.ValueRO.RespawnTick == 0)
{
// Just died: schedule the recovery.
respawn.ValueRW.RespawnTick = RespawnMath.RespawnTick(now, respawn.ValueRO.DelayTicks);
}
else if (RespawnMath.IsDue(now, respawn.ValueRO.RespawnTick))
{
// Recover: full health at the deterministic base spawn slot.
float maxHealth = eff.ValueRO.MaxHealth > 0f ? eff.ValueRO.MaxHealth : health.ValueRO.Max;
health.ValueRW.Current = maxHealth;
float3 pos = center + PlayerSpawnMath.SpawnOffset(
owner.ValueRO.NetworkId, spawner.SpawnRingRadius, spawner.RingSlots);
xform.ValueRW.Position = pos;
// Grant brief post-respawn damage immunity so the swarm can't instantly re-kill.
invuln.ValueRW.UntilTick = TickUtil.NonZero(now + (uint)math.max(0, respawn.ValueRO.InvulnTicks));
respawn.ValueRW.RespawnTick = 0;
}
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bddd5fecdba7e6c45853f4360acdbe74
@@ -0,0 +1,106 @@
using ProjectM.Simulation;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
using Unity.Transforms;
namespace ProjectM.Server
{
/// <summary>
/// Server-only Husk wave/threat director: a state machine that escalates the swarm. In <c>Lull</c> it waits
/// until the lull timer expires, then starts the next wave (count = <c>BaseCount + (wave-1)*CountPerWave</c>). In
/// <c>Spawning</c> it spawns one Husk every <c>SpawnIntervalTicks</c> at a deterministic ring slot around the
/// <see cref="BaseAnchor"/>, round-robin over the <see cref="WaveEnemyPrefab"/> pool, until the wave is fully
/// spawned; then it waits for the field to be cleared (no live <see cref="EnemyTag"/>) before returning to
/// <c>Lull</c>. Plain <see cref="SimulationSystemGroup"/>, server-authoritative (Husks are interpolated ghosts).
/// Replaces the flat <c>EnemySpawnSystem</c> sustain. Tick gating uses the wrap-safe <see cref="NetworkTick"/>
/// compare + <see cref="TickUtil.NonZero"/>.
/// </summary>
[BurstCompile]
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
[UpdateInGroup(typeof(SimulationSystemGroup))]
public partial struct WaveSystem : ISystem
{
EntityQuery m_AliveHusks;
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<WaveDirector>();
state.RequireForUpdate<WaveState>();
state.RequireForUpdate<NetworkTime>();
m_AliveHusks = state.GetEntityQuery(ComponentType.ReadOnly<EnemyTag>());
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var serverTick = SystemAPI.GetSingleton<NetworkTime>().ServerTick;
if (!serverTick.IsValid)
return;
uint now = serverTick.TickIndexForValidTick;
var director = SystemAPI.GetSingleton<WaveDirector>();
var directorEntity = SystemAPI.GetSingletonEntity<WaveDirector>();
var prefabs = SystemAPI.GetBuffer<WaveEnemyPrefab>(directorEntity);
if (prefabs.Length == 0)
return;
var wave = SystemAPI.GetComponent<WaveState>(directorEntity);
// Ring centre on the base plot when present.
float3 center = new float3(0f, 1f, 0f);
if (SystemAPI.TryGetSingleton<BaseAnchor>(out var baseAnchor))
center = BaseGridMath.PlotCenter(baseAnchor);
// Due when no action is scheduled yet (NextActionTick 0) or the scheduled tick is at/behind now.
bool dueNow = wave.NextActionTick == 0 || !new NetworkTick(wave.NextActionTick).IsNewerThan(serverTick);
if (wave.Phase == WavePhase.Lull)
{
if (dueNow)
{
// Start the next (bigger) wave.
wave.WaveNumber += 1;
wave.RemainingToSpawn =
math.max(1, director.BaseCount + (wave.WaveNumber - 1) * director.CountPerWave);
wave.Phase = WavePhase.Spawning;
wave.NextActionTick = TickUtil.NonZero(now); // spawn the first Husk this tick
}
}
else // Spawning
{
if (wave.RemainingToSpawn > 0)
{
if (dueNow)
{
int slots = math.max(1, director.RingSlots);
int prefabIdx = wave.SpawnCounter % prefabs.Length;
float3 pos = EnemyAIMath.RingPosition(center, wave.SpawnCounter, slots, director.RingRadius);
pos.y = center.y;
var ecb = new EntityCommandBuffer(Allocator.Temp);
var husk = ecb.Instantiate(prefabs[prefabIdx].Prefab);
ecb.SetComponent(husk, LocalTransform.FromPosition(pos));
ecb.Playback(state.EntityManager);
ecb.Dispose();
wave.SpawnCounter += 1;
wave.RemainingToSpawn -= 1;
wave.NextActionTick = TickUtil.NonZero(now + (uint)math.max(1, director.SpawnIntervalTicks));
}
}
else if (m_AliveHusks.CalculateEntityCount() == 0)
{
// Wave cleared: calm before the next.
wave.Phase = WavePhase.Lull;
wave.NextActionTick = TickUtil.NonZero(now + (uint)math.max(1, director.LullTicks));
}
}
SystemAPI.SetComponent(directorEntity, wave);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e9cc4f5328b0b794f965c102019f888a