36 lines
1.5 KiB
C#
36 lines
1.5 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;
|
|
|
|
private class StructureBaker : Baker<StructureAuthoring>
|
|
{
|
|
public override void Bake(StructureAuthoring authoring)
|
|
{
|
|
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
|
AddComponent(entity, new PlacedStructure
|
|
{
|
|
Type = authoring.Kind,
|
|
Cell = default,
|
|
NextTick = 0u,
|
|
LastProcessedTick = 0u,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|