21a4c71413
- KnockbackUtil.Stamp: shared knockback-stamp used by AbilityFireSystem + MeleeComboSystem (guard + planar normalize + write; speed passed in). - BakerStructureExt: AddPlacedStructure/AddDamageable extensions on Baker<T>; rewired Turret/Structure/Harvester/Conveyor/Fabricator bakers (baked data + serialized fields unchanged). - EnemyPrefabBakeExt.AddEnemyPrefabPool: shared prefab-buffer bake for ZoneEnemyDirector/WaveDirector authoring (fields stay flat — no serialization change). - Editor AnimRigUtil (HasParam + root-yaw overlay clip) shared by PlayerRigTools/EnemyRigTools; EnemyRigTools.MakeMat now GUID-preserving (CopySerialized over existing) — the composite AnimatorController copy left as-is with a caveat comment. 466/466 EditMode tests pass, 0 warnings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.7 KiB
C#
40 lines
1.7 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;
|
|
[Min(1f)] public float MaxHp = 120f;
|
|
|
|
private class TurretBaker : Baker<TurretAuthoring>
|
|
{
|
|
public override void Bake(TurretAuthoring authoring)
|
|
{
|
|
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
|
|
this.AddPlacedStructure(entity, StructureType.Turret);
|
|
AddComponent(entity, new Turret
|
|
{
|
|
Range = authoring.Range,
|
|
CooldownTicks = authoring.CooldownTicks,
|
|
Damage = authoring.Damage,
|
|
});
|
|
// EB-1: structures are damageable + destructible (Husks push for them; HealthApplyDamageSystem
|
|
// destroys a Destructible at Health<=0). The DamageEvent buffer MUST exist on the archetype or an
|
|
// AI/turret strike crashes at ECB playback. NO HitRadius on purpose -> ProjectileDamageSystem (needs
|
|
// Health+HitRadius) ignores structures, so player shots never friendly-fire your own turret.
|
|
this.AddDamageable(entity, authoring.MaxHp);
|
|
}
|
|
}
|
|
}
|
|
}
|