feat(enemy): 死亡层三模块(终态/单段/两段)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using BaseGames.AI;
|
||||
using BaseGames.Enemies.Abilities;
|
||||
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>单段死亡能力:进入即触发一次,不重播。</summary>
|
||||
[Serializable]
|
||||
public sealed class AbilityDeath : IDeathModule
|
||||
{
|
||||
public const string Death = "Death";
|
||||
|
||||
[Tooltip("死亡演出能力")]
|
||||
[SerializeField] AbilityRef _ability;
|
||||
|
||||
public AbilityDeath() { }
|
||||
public AbilityDeath(AbilityRef ability) { _ability = ability; }
|
||||
|
||||
public string EntryState => Death;
|
||||
|
||||
public void Build(BrainBuilder b)
|
||||
{
|
||||
string id = _ability.Id;
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new InvalidOperationException("AbilityDeath:未配置死亡能力。若死亡演出走物理状态机,请改用 TerminalDeath。");
|
||||
AiStateFragments.AbilityOnce(b, Death, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a3f1cc9d7026a840a01ab2dc951006b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using BaseGames.AI;
|
||||
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>死亡演出交给物理状态机(EnemyBase.PerformDeath):AI 只需要一个无行为终态。</summary>
|
||||
[Serializable]
|
||||
public sealed class TerminalDeath : IDeathModule
|
||||
{
|
||||
public const string Death = "Death";
|
||||
public string EntryState => Death;
|
||||
public void Build(BrainBuilder b) => AiStateFragments.Terminal(b, Death);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efb16f225a6b3b846b117409a3dfb620
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using BaseGames.AI;
|
||||
using BaseGames.Enemies.Abilities;
|
||||
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>两段死亡:前段(挣扎 / 膨胀)播完接后段(爆体,可带生成物)。</summary>
|
||||
[Serializable]
|
||||
public sealed class TwoStageDeath : IDeathModule
|
||||
{
|
||||
public const string DeathPre = "Death_Pre";
|
||||
public const string Death = "Death";
|
||||
|
||||
[Tooltip("前段演出能力(挣扎 / 膨胀)")]
|
||||
[SerializeField] AbilityRef _preAbility;
|
||||
[Tooltip("后段演出能力(爆体 / 生成物)")]
|
||||
[SerializeField] AbilityRef _ability;
|
||||
|
||||
public TwoStageDeath() { }
|
||||
public TwoStageDeath(AbilityRef preAbility, AbilityRef ability)
|
||||
{ _preAbility = preAbility; _ability = ability; }
|
||||
|
||||
public string EntryState => DeathPre;
|
||||
|
||||
public void Build(BrainBuilder b)
|
||||
{
|
||||
string preId = _preAbility.Id;
|
||||
string id = _ability.Id;
|
||||
if (string.IsNullOrEmpty(preId)) throw new InvalidOperationException("TwoStageDeath:未配置前段能力。");
|
||||
if (string.IsNullOrEmpty(id)) throw new InvalidOperationException("TwoStageDeath:未配置后段能力。");
|
||||
|
||||
AiStateFragments.AbilityOnce(b, DeathPre, preId)
|
||||
.To(Death).When(x => !x.Combat.IsAbilityRunning(preId), "preDone");
|
||||
AiStateFragments.AbilityOnce(b, Death, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ebca92989544c9449248e635c9a6103
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user