Files
Project-M/Assets/_Project/Scripts/Authoring/Building/StructureAuthoring.cs
T
kronic 21a4c71413 Hygiene B4c: clean dedup helpers (knockback, bakers, editor rig)
- 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>
2026-07-08 21:26:23 -07:00

36 lines
1.7 KiB
C#

using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Generic authoring for a non-functional build-structure ghost prefab (Wall / Pylon) — duplicate
/// Turret.prefab so the ownerless interpolated GhostAuthoringComponent on PlacedStructure.Type comes free,
/// then swap TurretAuthoring for this. Bakes ONLY <see cref="PlacedStructure"/>{Type=<see cref="Kind"/>}
/// (no <see cref="Turret"/> stats, so TurretFireSystem ignores it). BuildPlaceSystem overrides Cell +
/// LastProcessedTick and adds RegionTag{Base} at placement. <see cref="Kind"/> is a byte (StructureType.*) to
/// dodge the cross-assembly enum-in-Burst hazard and the MCP enum-drop gotcha.
/// </summary>
public class StructureAuthoring : MonoBehaviour
{
[Tooltip("StructureType byte: 5 = Wall, 6 = Pylon (do NOT use 1-4: Turret + reserved M7 automation).")]
public byte Kind = StructureType.Wall;
[Min(1f)] public float MaxHp = 150f;
private class StructureBaker : Baker<StructureAuthoring>
{
public override void Bake(StructureAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
this.AddPlacedStructure(entity, authoring.Kind);
// EB-1: Wall/Pylon are damageable + destructible AI targets (a wall soaks Husk strikes that would
// otherwise hit a turret). DamageEvent buffer MUST exist or an AI strike crashes at ECB playback.
// No HitRadius -> ProjectileDamageSystem ignores them (no friendly projectile fire).
this.AddDamageable(entity, authoring.MaxHp);
}
}
}
}