using ProjectM.Simulation; using Unity.Entities; using UnityEngine; namespace ProjectM.Authoring { /// /// Baker helpers shared by the build-structure / automation-machine bakers. These emit the SAME component data /// the bakers wrote inline before (no serialized authoring field or baked component change) — they only /// deduplicate the repeated stamp and the damageable triad /// ( + buffer + ). Extension methods on /// the concrete (not IBaker, whose AddComponent/AddBuffer are obsolete) so /// the non-obsolete public Baker API resolves. /// public static class BakerStructureExt { /// Stamp PlacedStructure{Type=type} with the standard baked defaults (Cell/NextTick/LastProcessedTick set at placement). public static void AddPlacedStructure(this Baker baker, Entity e, byte type) where TAuthoring : Component { baker.AddComponent(e, new PlacedStructure { Type = type, Cell = default, NextTick = 0u, LastProcessedTick = 0u, }); } /// Make an entity damageable/destructible: Health{Current=Max=maxHp} + the required DamageEvent buffer + Destructible tag. public static void AddDamageable(this Baker baker, Entity e, float maxHp) where TAuthoring : Component { baker.AddComponent(e, new Health { Current = maxHp, Max = maxHp }); baker.AddBuffer(e); baker.AddComponent(e); } } }