Continued
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the baked <see cref="StructureCatalog"/> singleton (the build cost/prefab table). For the
|
||||
/// M6 foundation there is one buildable type (Turret), so the entry is flat fields — only the prefab
|
||||
/// object-ref + cost amount need inspector wiring; the type + cost-resource are byte consts in the baker
|
||||
/// (enum-via-MCP is unreliable, and bytes dodge the cross-assembly enum-in-Burst hazard). M7 generalizes to
|
||||
/// an array; the runtime <see cref="StructureCatalogEntry"/> buffer is already the data-driven shape. Place
|
||||
/// once in the gameplay subscene.
|
||||
/// </summary>
|
||||
public class StructureCatalogAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Turret structure ghost prefab (TurretAuthoring + GhostAuthoring).")]
|
||||
public GameObject TurretPrefab;
|
||||
|
||||
[Tooltip("Ore cost to build a turret.")]
|
||||
[Min(0)] public int TurretCostOre = 10;
|
||||
|
||||
private class StructureCatalogBaker : Baker<StructureCatalogAuthoring>
|
||||
{
|
||||
public override void Bake(StructureCatalogAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.None);
|
||||
AddComponent<StructureCatalog>(entity);
|
||||
var buf = AddBuffer<StructureCatalogEntry>(entity);
|
||||
|
||||
if (authoring.TurretPrefab != null)
|
||||
{
|
||||
buf.Add(new StructureCatalogEntry
|
||||
{
|
||||
Type = StructureType.Turret,
|
||||
Prefab = GetEntity(authoring.TurretPrefab, TransformUsageFlags.Dynamic),
|
||||
CostResourceId = ResourceId.Ore,
|
||||
CostAmount = authoring.TurretCostOre,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40093ed42072f5a4889f5f62f510aa27
|
||||
@@ -0,0 +1,39 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the turret structure ghost prefab (duplicate UpgradePickup.prefab so the ownerless
|
||||
/// interpolated GhostAuthoringComponent comes free). Bakes <see cref="PlacedStructure"/>{Type=Turret} +
|
||||
/// <see cref="Turret"/> stats. BuildPlaceSystem stamps Cell + LastProcessedTick at placement.
|
||||
/// </summary>
|
||||
public class TurretAuthoring : MonoBehaviour
|
||||
{
|
||||
[Min(1f)] public float Range = 10f;
|
||||
[Min(1)] public int CooldownTicks = 30;
|
||||
[Min(1f)] public float Damage = 12f;
|
||||
|
||||
private class TurretBaker : Baker<TurretAuthoring>
|
||||
{
|
||||
public override void Bake(TurretAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new PlacedStructure
|
||||
{
|
||||
Type = StructureType.Turret,
|
||||
Cell = default,
|
||||
NextTick = 0u,
|
||||
LastProcessedTick = 0u,
|
||||
});
|
||||
AddComponent(entity, new Turret
|
||||
{
|
||||
Range = authoring.Range,
|
||||
CooldownTicks = authoring.CooldownTicks,
|
||||
Damage = authoring.Damage,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfb1e0820cbf41b4bbbe99066dfadd40
|
||||
Reference in New Issue
Block a user