FututeWand初步
This commit is contained in:
@@ -80,6 +80,9 @@ namespace Cielonos.MainGame
|
||||
impulseSm = null;
|
||||
reactionSm = null;
|
||||
|
||||
scheduledActions.Clear();
|
||||
_toBeExecutedScheduledActions.Clear();
|
||||
|
||||
areaCollider = GetComponent<Collider>();
|
||||
|
||||
// 通过 VFXObject 组件确定 VFX 顶层节点,比遍历 parent 链更可靠。
|
||||
@@ -122,11 +125,62 @@ namespace Cielonos.MainGame
|
||||
hitSm?.Update();
|
||||
timeSm?.Update();
|
||||
moveSm?.Update();
|
||||
UpdateScheduledActions();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class AttackAreaBase
|
||||
{
|
||||
public class ScheduledAction
|
||||
{
|
||||
public Action action;
|
||||
public float delay;
|
||||
|
||||
public ScheduledAction(Action action, float delay)
|
||||
{
|
||||
this.action = action;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
[HideInEditorMode] public List<ScheduledAction> scheduledActions = new List<ScheduledAction>();
|
||||
private List<ScheduledAction> _toBeExecutedScheduledActions = new List<ScheduledAction>();
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个在指定延迟时间后执行的动作,只要 AttackArea 存在且 active 就会更新
|
||||
/// </summary>
|
||||
public AttackAreaBase AddScheduleAction(Action action, float delay)
|
||||
{
|
||||
scheduledActions.Add(new ScheduledAction(action, delay));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新所有延迟执行的动作,不受子模块启用状态的影响
|
||||
/// </summary>
|
||||
private void UpdateScheduledActions()
|
||||
{
|
||||
if (scheduledActions.Count > 0)
|
||||
{
|
||||
_toBeExecutedScheduledActions.Clear();
|
||||
float dt = creator != null && creator.selfTimeSm != null ? creator.selfTimeSm.DeltaTime : Time.deltaTime;
|
||||
for (int i = scheduledActions.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var scheduledAction = scheduledActions[i];
|
||||
scheduledAction.delay -= dt;
|
||||
if (scheduledAction.delay <= 0)
|
||||
{
|
||||
_toBeExecutedScheduledActions.Add(scheduledAction);
|
||||
scheduledActions.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
foreach (var scheduledAction in _toBeExecutedScheduledActions)
|
||||
{
|
||||
scheduledAction.action?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region TransformSubmodule
|
||||
|
||||
public T SetTransformSubmodule<T>(Transform target = null, float delay = 0) where T : AttackAreaBase
|
||||
@@ -263,16 +317,6 @@ namespace Cielonos.MainGame
|
||||
keepFlat, straightThrowInitially, straightThrowDuration, stopWhenHit);
|
||||
return this as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置回旋镖/旋转区域追踪移动子模块(链式/Fluent 初始化),返回子模块以供进一步配置
|
||||
/// </summary>
|
||||
public BoomerangMoveSubmodule SetBoomerangMoveSubmodule(CharacterBase target, float moveSpeed, float angularSpeed, Vector3 initialDirection)
|
||||
{
|
||||
var submodule = new BoomerangMoveSubmodule(this, target, moveSpeed, angularSpeed, initialDirection);
|
||||
moveSm = submodule;
|
||||
return submodule;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RaycastSubmodule
|
||||
|
||||
Reference in New Issue
Block a user