42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring for the training-dummy enemy prefab. Bakes a stationary, damageable auto-target
|
|
/// candidate: <see cref="TrainingDummyTag"/> marks it for the ability auto-target cone,
|
|
/// <see cref="Health"/> and <see cref="HitRadius"/> make it a valid projectile hit target, and a
|
|
/// <see cref="DamageEvent"/> buffer receives server-authoritative hits. Dummies are NOT ghosts and
|
|
/// carry no <c>GhostOwner</c>, so projectiles never treat them as the firing owner.
|
|
/// <c>GetEntity(TransformUsageFlags.Dynamic)</c> ensures a runtime LocalTransform for hit tests
|
|
/// and spawn placement.
|
|
/// </summary>
|
|
public class TrainingDummyAuthoring : MonoBehaviour
|
|
{
|
|
[Min(0f), Tooltip("Starting and maximum health for the dummy.")]
|
|
public float MaxHealth = 60f;
|
|
|
|
[Min(0f), Tooltip("World-unit radius used by the projectile hit test.")]
|
|
public float HitRadius = 0.8f;
|
|
|
|
private class TrainingDummyBaker : Baker<TrainingDummyAuthoring>
|
|
{
|
|
public override void Bake(TrainingDummyAuthoring authoring)
|
|
{
|
|
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
|
|
|
AddComponent<TrainingDummyTag>(entity);
|
|
AddComponent(entity, new Health
|
|
{
|
|
Current = authoring.MaxHealth,
|
|
Max = authoring.MaxHealth
|
|
});
|
|
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
|
AddBuffer<DamageEvent>(entity);
|
|
}
|
|
}
|
|
}
|
|
}
|