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