40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
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,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|