Initial Combat Implementation
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for the projectile ghost prefab fired by the player's primary ability. Bakes the
|
||||
/// baked-once tunables (<see cref="Projectile.Speed"/>, <see cref="Projectile.Damage"/>,
|
||||
/// <see cref="Projectile.Range"/>) onto the entity; the replicated <c>Direction</c>/<c>SpawnId</c>
|
||||
/// and the integrated <c>DistanceTravelled</c> are left at their default 0 and written at spawn
|
||||
/// time by AbilityFireSystem. Ghost replication and <c>GhostOwner</c> are supplied by the
|
||||
/// GhostAuthoringComponent added on the same prefab GameObject (not added here, nor is Health).
|
||||
/// <c>GetEntity(TransformUsageFlags.Dynamic)</c> ensures a runtime-mutable LocalTransform exists.
|
||||
/// </summary>
|
||||
public class ProjectileAuthoring : MonoBehaviour
|
||||
{
|
||||
[Min(0f)] public float Speed = 25f;
|
||||
[Min(0f)] public float Damage = 20f;
|
||||
[Min(0f)] public float Range = 20f;
|
||||
|
||||
private class ProjectileBaker : Baker<ProjectileAuthoring>
|
||||
{
|
||||
public override void Bake(ProjectileAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
|
||||
// Direction / SpawnId / DistanceTravelled default to 0 — set at spawn by AbilityFireSystem.
|
||||
AddComponent(entity, new Projectile
|
||||
{
|
||||
Speed = authoring.Speed,
|
||||
Damage = authoring.Damage,
|
||||
Range = authoring.Range
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user