Initial Combat Implementation
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ProjectM.Authoring
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring for an upgrade pickup ghost prefab: a world object that grants one stat modifier to the
|
||||
/// first player that overlaps it (server-authoritative, applied by <c>UpgradePickupSystem</c>) and
|
||||
/// then despawns. Bake the prefab as an interpolated ghost (add a GhostAuthoringComponent) so clients
|
||||
/// see it appear and despawn. <c>GetEntity(TransformUsageFlags.Dynamic)</c> gives it a world transform.
|
||||
/// </summary>
|
||||
public class UpgradePickupAuthoring : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Which stat the granted modifier targets.")]
|
||||
public StatTarget Target = StatTarget.Damage;
|
||||
|
||||
[Tooltip("How the granted modifier combines.")]
|
||||
public ModOp Op = ModOp.Flat;
|
||||
|
||||
[Tooltip("Modifier magnitude: flat amount, or fractional percent (0.1 = +10%).")]
|
||||
public float Value = 10f;
|
||||
|
||||
[Tooltip("Overlap radius (world units) for the player pickup test.")]
|
||||
[Min(0f)] public float HitRadius = 1f;
|
||||
|
||||
private class UpgradePickupBaker : Baker<UpgradePickupAuthoring>
|
||||
{
|
||||
public override void Bake(UpgradePickupAuthoring authoring)
|
||||
{
|
||||
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
||||
AddComponent(entity, new UpgradePickup
|
||||
{
|
||||
Target = (byte)authoring.Target,
|
||||
Op = (byte)authoring.Op,
|
||||
Value = authoring.Value,
|
||||
SourceId = 0u,
|
||||
});
|
||||
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user