Sandbox target dummy: planted EnemyTag ghost + DevSandbox respawn spawner
GymSub bakes no WaveDirector (why sandbox enemies never spawned); the sandbox's combat target is now a TargetDummyTag'd enemy ghost all five EnemyAISystem passes exclude (planted; knockback stamps inert), spawned at player+3m with 400 HP by an editor-only scene-gated server system, dying through the normal Dying path and respawning 1.5s after the corpse. EnemyTag-reuse audited: sandbox-only by design (cleared-checks would count it elsewhere). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,14 +120,14 @@ namespace ProjectM.Server
|
|||||||
if (sweep)
|
if (sweep)
|
||||||
{
|
{
|
||||||
foreach (var depenXform in SystemAPI.Query<RefRW<LocalTransform>>()
|
foreach (var depenXform in SystemAPI.Query<RefRW<LocalTransform>>()
|
||||||
.WithAll<EnemyTag>().WithNone<Dying, BossState>())
|
.WithAll<EnemyTag>().WithNone<Dying, BossState>().WithNone<TargetDummyTag>())
|
||||||
depenXform.ValueRW.Position = EnemyMoveUtil.Depenetrate(in physics, depenXform.ValueRO.Position, SweepRadius, envFilter);
|
depenXform.ValueRW.Position = EnemyMoveUtil.Depenetrate(in physics, depenXform.ValueRO.Position, SweepRadius, envFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var (xform, stats, cooldown, knockback, windup, region) in
|
foreach (var (xform, stats, cooldown, knockback, windup, region) in
|
||||||
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<EnemyAttackCooldown>,
|
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<EnemyAttackCooldown>,
|
||||||
RefRW<KnockbackState>, RefRW<AttackWindup>, RefRO<RegionTag>>()
|
RefRW<KnockbackState>, RefRW<AttackWindup>, RefRO<RegionTag>>()
|
||||||
.WithAll<EnemyTag>().WithNone<LungeState, SpitterState, Dying>())
|
.WithAll<EnemyTag>().WithNone<LungeState, SpitterState, Dying>().WithNone<TargetDummyTag>())
|
||||||
{
|
{
|
||||||
float3 pos = xform.ValueRO.Position;
|
float3 pos = xform.ValueRO.Position;
|
||||||
byte huskRegion = region.ValueRO.Region;
|
byte huskRegion = region.ValueRO.Region;
|
||||||
@@ -398,7 +398,7 @@ namespace ProjectM.Server
|
|||||||
foreach (var (xform, stats, knockback, windup, spitter, region) in
|
foreach (var (xform, stats, knockback, windup, spitter, region) in
|
||||||
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<KnockbackState>,
|
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<KnockbackState>,
|
||||||
RefRW<AttackWindup>, RefRW<SpitterState>, RefRO<RegionTag>>()
|
RefRW<AttackWindup>, RefRW<SpitterState>, RefRO<RegionTag>>()
|
||||||
.WithAll<EnemyTag, SpitterState>().WithNone<LungeState, Dying>())
|
.WithAll<EnemyTag, SpitterState>().WithNone<LungeState, Dying>().WithNone<TargetDummyTag>())
|
||||||
{
|
{
|
||||||
float3 pos = xform.ValueRO.Position;
|
float3 pos = xform.ValueRO.Position;
|
||||||
byte sRegion = region.ValueRO.Region;
|
byte sRegion = region.ValueRO.Region;
|
||||||
@@ -503,7 +503,7 @@ namespace ProjectM.Server
|
|||||||
// Charger whose bit is currently DISABLED is still visited (Entities default-excludes disabled enableables).
|
// Charger whose bit is currently DISABLED is still visited (Entities default-excludes disabled enableables).
|
||||||
foreach (var (lunge, isLunging) in
|
foreach (var (lunge, isLunging) in
|
||||||
SystemAPI.Query<RefRO<LungeState>, EnabledRefRW<IsLunging>>()
|
SystemAPI.Query<RefRO<LungeState>, EnabledRefRW<IsLunging>>()
|
||||||
.WithAll<EnemyTag>().WithPresent<IsLunging>().WithNone<Dying>())
|
.WithAll<EnemyTag>().WithPresent<IsLunging>().WithNone<Dying>().WithNone<TargetDummyTag>())
|
||||||
{
|
{
|
||||||
isLunging.ValueRW = lunge.ValueRO.UntilTick != 0u; // lunging iff a committed lunge is live this tick
|
isLunging.ValueRW = lunge.ValueRO.UntilTick != 0u; // lunging iff a committed lunge is live this tick
|
||||||
}
|
}
|
||||||
@@ -591,7 +591,7 @@ namespace ProjectM.Server
|
|||||||
float nudgeStep = UnstickNudgeSpeed * dt;
|
float nudgeStep = UnstickNudgeSpeed * dt;
|
||||||
foreach (var (nxform, nstats, nav, nregion, nent) in
|
foreach (var (nxform, nstats, nav, nregion, nent) in
|
||||||
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<EnemyNavState>, RefRO<RegionTag>>()
|
SystemAPI.Query<RefRW<LocalTransform>, RefRO<EnemyStats>, RefRW<EnemyNavState>, RefRO<RegionTag>>()
|
||||||
.WithAll<EnemyTag>().WithNone<SpitterState, BossState, Dying>().WithEntityAccess())
|
.WithAll<EnemyTag>().WithNone<SpitterState, BossState, Dying>().WithNone<TargetDummyTag>().WithEntityAccess())
|
||||||
{
|
{
|
||||||
float3 npos = nxform.ValueRO.Position;
|
float3 npos = nxform.ValueRO.Position;
|
||||||
byte nRegion = nregion.ValueRO.Region;
|
byte nRegion = nregion.ValueRO.Region;
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
#if UNITY_EDITOR
|
||||||
|
using ProjectM.Simulation;
|
||||||
|
using Unity.Collections;
|
||||||
|
using Unity.Entities;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
using Unity.Transforms;
|
||||||
|
|
||||||
|
namespace ProjectM.Server
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 07-20 sandbox combat target: keeps ONE planted <see cref="TargetDummyTag"/> dummy alive in the DevSandbox
|
||||||
|
/// (scene-name gate — the established dev-script convention; GymSub bakes no WaveDirector, so this is the
|
||||||
|
/// sandbox's enemy source by design). The dummy is a real enemy ghost instantiated from a baked prefab
|
||||||
|
/// (grunt-shaped preferred), parked at the first player's position + a fixed offset, HP fat enough to eat a
|
||||||
|
/// few chains; it dies through the NORMAL death path (Dying corpse window → destroy → kill pop on the client)
|
||||||
|
/// and respawns at the same anchor shortly after — kill feedback stays testable on repeat. Editor-only.
|
||||||
|
/// </summary>
|
||||||
|
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||||
|
public partial class TargetDummySpawnSystem : SystemBase
|
||||||
|
{
|
||||||
|
const float RespawnDelaySec = 1.5f;
|
||||||
|
const float DummyHealth = 400f;
|
||||||
|
static readonly float3 AnchorOffset = new float3(3f, 0f, 1.5f);
|
||||||
|
|
||||||
|
float _respawnTimer;
|
||||||
|
float3 _anchor;
|
||||||
|
bool _anchored;
|
||||||
|
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "DevSandbox")
|
||||||
|
return;
|
||||||
|
|
||||||
|
// A dummy exists (alive OR in its Dying corpse window) -> nothing to do; the corpse window
|
||||||
|
// conveniently delays the respawn timer until the body is gone.
|
||||||
|
var dummyQ = SystemAPI.QueryBuilder().WithAll<TargetDummyTag>().Build();
|
||||||
|
if (!dummyQ.IsEmpty) { _respawnTimer = 0f; return; }
|
||||||
|
|
||||||
|
// Anchor once on the first player seen (spawn point + offset = a consistent training spot).
|
||||||
|
if (!_anchored)
|
||||||
|
{
|
||||||
|
foreach (var xf in SystemAPI.Query<RefRO<LocalTransform>>().WithAll<PlayerTag>())
|
||||||
|
{
|
||||||
|
_anchor = xf.ValueRO.Position + AnchorOffset;
|
||||||
|
_anchored = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!_anchored) return; // no player yet (world still connecting)
|
||||||
|
}
|
||||||
|
|
||||||
|
_respawnTimer += SystemAPI.Time.DeltaTime; // wall-frame is fine: dev spawner in the plain server group
|
||||||
|
if (_respawnTimer < RespawnDelaySec) return;
|
||||||
|
_respawnTimer = 0f;
|
||||||
|
|
||||||
|
// Grunt-shaped prefab preferred (no lunge/spit machinery on a training dummy); fall back to any enemy.
|
||||||
|
var prefQ = EntityManager.CreateEntityQuery(new EntityQueryDesc
|
||||||
|
{
|
||||||
|
All = new ComponentType[] { typeof(EnemyTag), typeof(Prefab) },
|
||||||
|
None = new ComponentType[] { typeof(LungeState), typeof(SpitterState) },
|
||||||
|
Options = EntityQueryOptions.IncludePrefab,
|
||||||
|
});
|
||||||
|
var prefabs = prefQ.ToEntityArray(Allocator.Temp);
|
||||||
|
if (prefabs.Length == 0)
|
||||||
|
{
|
||||||
|
prefabs.Dispose();
|
||||||
|
var anyQ = EntityManager.CreateEntityQuery(new EntityQueryDesc
|
||||||
|
{
|
||||||
|
All = new ComponentType[] { typeof(EnemyTag), typeof(Prefab) },
|
||||||
|
Options = EntityQueryOptions.IncludePrefab,
|
||||||
|
});
|
||||||
|
prefabs = anyQ.ToEntityArray(Allocator.Temp);
|
||||||
|
if (prefabs.Length == 0) { prefabs.Dispose(); return; } // no enemy ghosts in this world
|
||||||
|
}
|
||||||
|
var prefab = prefabs[0];
|
||||||
|
prefabs.Dispose();
|
||||||
|
|
||||||
|
var inst = EntityManager.Instantiate(prefab);
|
||||||
|
var baked = EntityManager.GetComponentData<LocalTransform>(prefab);
|
||||||
|
EntityManager.SetComponentData(inst, baked.WithPosition(_anchor)); // WithPosition: never FromPosition (Scale reset)
|
||||||
|
EntityManager.SetComponentData(inst, new Health { Current = DummyHealth, Max = DummyHealth });
|
||||||
|
EntityManager.AddComponent<TargetDummyTag>(inst); // server-only: plants it (every AI pass excludes the tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 036a5a62e96d4ac49b556c748135b478
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Unity.Entities;
|
||||||
|
|
||||||
|
namespace ProjectM.Simulation
|
||||||
|
{
|
||||||
|
/// <summary>07-20 sandbox combat testing: marks a server-spawned enemy ghost as a PLANTED target dummy —
|
||||||
|
/// every EnemyAISystem pass excludes it (no move, no attack, no knockback integration, no depenetration
|
||||||
|
/// nudge), so it stands at its anchor and just takes hits. Server-only (runtime-added at spawn, never
|
||||||
|
/// replicated); the client sees a normal interpolated enemy, so health bars, hit flash, damage, kill pop
|
||||||
|
/// and the death path all exercise the REAL pipeline. Spawned + respawned by TargetDummySpawnSystem in the
|
||||||
|
/// DevSandbox (GymSub bakes no WaveDirector — the sandbox's combat target is this dummy, by design).
|
||||||
|
/// ★ EnemyTag-reuse audit (CLAUDE.md): cleave/projectile damage MUST see it (the point); AI passes exclude
|
||||||
|
/// it; wave/room cleared-checks would count it — acceptable ONLY because the spawner is sandbox-gated.</summary>
|
||||||
|
public struct TargetDummyTag : IComponentData { }
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 013cf2990a041494fa876653dff1d059
|
||||||
Reference in New Issue
Block a user