using ProjectM.Simulation; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; namespace ProjectM.Server { /// /// The ONE per-enemy spawn-stamp for expedition ROOM enemies, shared by RoomEnemyDirectorSystem (wave drip) and /// BossAISystem (phase-two summon). Keeps the teardown/relevancy/clear-count contract in a single place so a boss /// add can never silently drop a tag: (counted by the room-clear gate), /// (the RoomTeardown filter — Room byte MUST equal the current room), and /// {Expedition} (relevancy — an untagged add would leak to base players, a Base-tagged one /// would hide from the expedition party). Scale preserved via baked.WithPosition (never FromPosition, which /// resets the [GhostField] Scale). Returns the spawned entity so a caller can layer extra (e.g. boss HP/scale). /// public static class ZoneEnemySpawnUtil { public static Entity Spawn(EntityCommandBuffer ecb, Entity prefab, in LocalTransform baked, float3 pos, byte region, byte room) { var enemy = ecb.Instantiate(prefab); ecb.SetComponent(enemy, baked.WithPosition(pos)); // preserve the baked [GhostField] Scale ecb.AddComponent(enemy, new RegionTag { Region = region }); ecb.AddComponent(enemy); return enemy; } } }