using System; using System.Collections.Generic; using Cielonos.MainGame.Characters; using SLSUtilities.General; using SoftCircuits.Collections; using UnityEngine; namespace Cielonos.MainGame { public partial class AttackAreaBase { /// /// 统一管理 AttackArea 生命周期内的事件,避免事件数据散落在不同子模块中。 /// public class EventSubmodule : AttackAreaSubmoduleBase { /// /// 每次有效命中都会执行的通用命中事件,适合处理 Buff、印记、装备联动等命中后逻辑。 /// public readonly List> onHit = new List>(); /// /// 只在指定 hitIndex 命中时执行的事件,用于多段攻击中某一段具有特殊效果的情况。 /// public readonly SortedList> onIndexedHit = new SortedList>(); /// /// 成功触发 Breakthrough 时执行的事件,使用 key + priority 支持同一区域内多来源的有序处理。 /// public readonly OrderedDictionary> onBreakthrough = new OrderedDictionary>(); /// /// 单次攻击结算完成后执行的事件,传入完整 Attack.Result,适合根据 Outcome 播放反馈或触发后续机制。 /// public readonly OrderedDictionary> onAttackFinished = new OrderedDictionary>(); public EventSubmodule(AttackAreaBase owner) : base(owner) { } public void InvokeHitEvents(CharacterBase target, Vector3 hitPosition, int hitIndex, bool canTriggerHitEvent) { if (!canTriggerHitEvent) return; foreach (Action hitEvent in onHit) { hitEvent.Invoke(target, hitPosition); } if (onIndexedHit.TryGetValue(hitIndex, out Action action)) { action.Invoke(target, hitPosition); } } public void InvokeBreakthrough(CharacterBase target, Vector3 hitPosition) { onBreakthrough.Invoke(target, hitPosition); } public void InvokeAttackFinished(CharacterBase target, Attack.Result attackResult) { if (target == null || attackResult == null || attackResult.isReactionOnlyCheck) return; onAttackFinished.Invoke(target, attackResult); } } } }