Files
Project-M/Assets/_Project/Scripts/Authoring/Combat/EnemyAuthoring.cs
T
kronic e362aaeb43 Import art/VFX asset packs + game-feel systems; normalize texture extensions to lowercase for LFS
Add BefourStudios SciFi environment packs, Gabriel Aguiar VFX, and the
ShaderCrew Toon Shader embedded packages, plus combat/enemy/wave/death
gameplay systems and supporting vault docs/screenshots.

Rename 11 vendor textures from uppercase .PNG/.HDR to lowercase so the
case-sensitive Git LFS filters (*.png/*.hdr) match on case-sensitive
filesystems (Linux CI, case-sensitive macOS), not just locally where
core.ignorecase=true masks the gap. Each .meta moved with its asset so
GUID references are preserved. All ~1000 binaries tracked via LFS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 22:50:43 -07:00

57 lines
2.5 KiB
C#

using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring for the Husk enemy prefab. Bakes the gameplay components onto a prefab whose ghost setup
/// (GhostAuthoringComponent: interpolated, ownerless) is inherited by DUPLICATING an existing interpolated
/// ghost (UpgradePickup.prefab) — so the Husk replicates to all clients with no hand-written <c>[GhostField]</c>
/// (the stock LocalTransform variant carries its server-driven position). Damageable exactly like the training
/// dummy (Health/HitRadius/DamageEvent) plus the Husk AI tunables. <c>GetEntity(Dynamic)</c> gives a
/// runtime-mutable LocalTransform for server-authoritative movement and hit tests.
/// </summary>
public class EnemyAuthoring : MonoBehaviour
{
[Min(0f), Tooltip("Starting and maximum health for the Husk.")]
public float MaxHealth = 30f;
[Min(0f), Tooltip("World-unit radius used by the projectile hit test.")]
public float HitRadius = 0.7f;
[Min(0f), Tooltip("Planar seek speed toward the nearest player, units/second.")]
public float MoveSpeed = 3.5f;
[Min(0f), Tooltip("Centre-to-centre distance at which the Husk can strike a player.")]
public float AttackRange = 1.6f;
[Min(0f), Tooltip("Damage dealt per strike.")]
public float AttackDamage = 8f;
[Min(1), Tooltip("Simulation ticks between strikes (~60 ticks/sec).")]
public int AttackCooldownTicks = 36;
private class EnemyBaker : Baker<EnemyAuthoring>
{
public override void Bake(EnemyAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
AddComponent<EnemyTag>(entity);
AddComponent(entity, new Health { Current = authoring.MaxHealth, Max = authoring.MaxHealth });
AddComponent(entity, new HitRadius { Value = authoring.HitRadius });
AddBuffer<DamageEvent>(entity);
AddComponent(entity, new EnemyStats
{
MoveSpeed = authoring.MoveSpeed,
AttackRange = authoring.AttackRange,
AttackDamage = authoring.AttackDamage,
AttackCooldownTicks = authoring.AttackCooldownTicks,
});
AddComponent(entity, new EnemyAttackCooldown { NextAttackTick = 0 });
}
}
}
}