using System; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// Shared BAKE step for the two enemy directors (Wave + Zone): add the prefab-pool buffer and fill it from the /// authoring GameObject[] exactly as before — always add the (possibly empty) buffer, skip null entries, and /// GetEntity(prefab, Dynamic) per entry. The element type differs per director (WaveEnemyPrefab vs /// ZoneEnemyPrefab), so the caller supplies a tiny factory wrapping the resolved Entity in its element struct; /// nothing about the serialized inspector fields or the baked buffer contents changes. /// public static class EnemyPrefabBakeExt { public static void AddEnemyPrefabPool( this Baker baker, Entity e, GameObject[] prefabs, Func make) where TAuthoring : Component where TElem : unmanaged, IBufferElementData { var buffer = baker.AddBuffer(e); if (prefabs == null) return; foreach (var prefab in prefabs) { if (prefab != null) buffer.Add(make(baker.GetEntity(prefab, TransformUsageFlags.Dynamic))); } } } }