所有敌人默认常驻身体接触伤害:存活即开、死亡时经 PerformDeath 统一关碰撞体停止。 - ContactChaseAbility/AnimatedCeilingDropAbility 移除对 BodyContactDamage 的开关引用 - BodyContactDamage 语义改为常驻(更新注释) - 脚手架 SetupHurtAndContactBoxes 去掉 contactEnabled 参数恒为 true,并把 ContactDamageZone 的 HitBox._targetLayers 限定为 PlayerHurtBox(避免常驻后敌人互相误伤) - 7 个敌人预制体:E001 启用 BodyContactDamage;E002/E004/E005/ChaoFeng 补齐 ContactDamageZone(镜像 HurtBox 身体碰撞体);全部 _targetLayers 收敛为 PlayerHurtBox - 更新 Docs/Guides/02 敌人搭建指南 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using BaseGames.Combat;
|
|
using UnityEngine;
|
|
|
|
namespace BaseGames.Enemies
|
|
{
|
|
/// <summary>
|
|
/// 身体接触伤害:组件启用时把 HitBox 切到 Interval 模式并持续激活,
|
|
/// 令敌人对停留在判定盒内的目标按固定间隔重复造成伤害。
|
|
///
|
|
/// 敌人默认常驻开启:只要敌人存活,身体接触即持续造成伤害;与任何攻击/移动能力解耦,
|
|
/// 不由能力开关。死亡由 EnemyBase.PerformDeath 统一禁用全部碰撞体而自然停止,
|
|
/// 对象池复用时 OnSpawn 恢复碰撞体 + GO 重新激活触发本组件 OnEnable 重新接管。
|
|
///
|
|
/// 重复命中由 HitBox 的 Interval 节奏(Enter/Exit 跟踪占用 + Update 轮询)驱动,
|
|
/// 不再依赖反复 Activate()——后者无法对已停留目标补发 OnTriggerEnter,会导致只命中一次。
|
|
/// </summary>
|
|
[RequireComponent(typeof(HitBox))]
|
|
public class BodyContactDamage : MonoBehaviour
|
|
{
|
|
[SerializeField] private float _repeatInterval = 0.5f;
|
|
|
|
private HitBox _hitBox;
|
|
|
|
private void Awake() => _hitBox = GetComponent<HitBox>();
|
|
private void OnEnable()
|
|
{
|
|
_hitBox?.SetIntervalMode(_repeatInterval);
|
|
_hitBox?.Activate();
|
|
}
|
|
private void OnDisable() => _hitBox?.Deactivate();
|
|
}
|
|
}
|