21a4c71413
- KnockbackUtil.Stamp: shared knockback-stamp used by AbilityFireSystem + MeleeComboSystem (guard + planar normalize + write; speed passed in). - BakerStructureExt: AddPlacedStructure/AddDamageable extensions on Baker<T>; rewired Turret/Structure/Harvester/Conveyor/Fabricator bakers (baked data + serialized fields unchanged). - EnemyPrefabBakeExt.AddEnemyPrefabPool: shared prefab-buffer bake for ZoneEnemyDirector/WaveDirector authoring (fields stay flat — no serialization change). - Editor AnimRigUtil (HasParam + root-yaw overlay clip) shared by PlayerRigTools/EnemyRigTools; EnemyRigTools.MakeMat now GUID-preserving (CopySerialized over existing) — the composite AnimatorController copy left as-is with a caveat comment. 466/466 EditMode tests pass, 0 warnings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.8 KiB
C#
40 lines
1.8 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// 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 <see cref="PlacedStructure"/> stamp and the damageable triad
|
|
/// (<see cref="Health"/> + <see cref="DamageEvent"/> buffer + <see cref="Destructible"/>). Extension methods on
|
|
/// the concrete <see cref="Baker{TAuthoringType}"/> (not IBaker, whose AddComponent/AddBuffer are obsolete) so
|
|
/// the non-obsolete public Baker API resolves.
|
|
/// </summary>
|
|
public static class BakerStructureExt
|
|
{
|
|
/// <summary>Stamp PlacedStructure{Type=type} with the standard baked defaults (Cell/NextTick/LastProcessedTick set at placement).</summary>
|
|
public static void AddPlacedStructure<TAuthoring>(this Baker<TAuthoring> baker, Entity e, byte type)
|
|
where TAuthoring : Component
|
|
{
|
|
baker.AddComponent(e, new PlacedStructure
|
|
{
|
|
Type = type,
|
|
Cell = default,
|
|
NextTick = 0u,
|
|
LastProcessedTick = 0u,
|
|
});
|
|
}
|
|
|
|
/// <summary>Make an entity damageable/destructible: Health{Current=Max=maxHp} + the required DamageEvent buffer + Destructible tag.</summary>
|
|
public static void AddDamageable<TAuthoring>(this Baker<TAuthoring> baker, Entity e, float maxHp)
|
|
where TAuthoring : Component
|
|
{
|
|
baker.AddComponent(e, new Health { Current = maxHp, Max = maxHp });
|
|
baker.AddBuffer<DamageEvent>(e);
|
|
baker.AddComponent<Destructible>(e);
|
|
}
|
|
}
|
|
}
|