129 lines
4.0 KiB
C#
129 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Inventory;
|
|
using Opsive.BehaviorDesigner.Runtime;
|
|
using Sirenix.OdinInspector;
|
|
using SLSUtilities.FunctionalAnimation;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class Automata : CharacterBase
|
|
{
|
|
[TitleGroup("Data & Presets")]
|
|
public List<FuncAnimData> fullBodyFuncAnims = new List<FuncAnimData>();
|
|
public VFXData vfxData;
|
|
public AttackData attackData;
|
|
[HideInInspector]
|
|
private List<string> registeredFunctionNames = new List<string>();
|
|
|
|
[TitleGroup("Subcontrollers")]
|
|
public BehaviorTree behaviorTree;
|
|
public NavMeshAgent navMeshAgent;
|
|
|
|
|
|
private IDisposable getHitRecovery;
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
vfxData.Initialize(this);
|
|
RegisterFullBodyFuncAnims();
|
|
//RegisterFunctionsToAnimSc(LightAttack0);
|
|
}
|
|
}
|
|
|
|
public partial class Automata
|
|
{
|
|
public override bool GetHit(BreakthroughType breakthroughType,
|
|
DisruptionType disruptionType = DisruptionType.NormalExternal, Vector3 direction = default)
|
|
{
|
|
if (base.GetHit(breakthroughType, disruptionType, direction))
|
|
{
|
|
navMeshAgent.isStopped = true;
|
|
getHitRecovery?.Dispose();
|
|
getHitRecovery = Observable.Timer(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
|
|
{
|
|
navMeshAgent.isStopped = false;
|
|
}).AddTo(this);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public partial class Automata
|
|
{
|
|
|
|
}
|
|
|
|
public partial class Automata
|
|
{
|
|
public void RegisterFullBodyFuncAnims()
|
|
{
|
|
foreach (FuncAnimData funcAnim in fullBodyFuncAnims)
|
|
{
|
|
animationSc.fullBodyFuncAnimSm.Add(funcAnim);
|
|
}
|
|
}
|
|
|
|
protected virtual void RegisterFunctionsToAnimSc(params Action[] functions)
|
|
{
|
|
foreach (Action function in functions)
|
|
{
|
|
string functionName = function.Method.Name;
|
|
if (!animationSc.registeredFunctions.TryAdd(functionName, anim => function()))
|
|
{
|
|
Debug.LogWarning($"Function {functionName} is already registered.");
|
|
}
|
|
else
|
|
{
|
|
registeredFunctionNames.Add(functionName);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected virtual void RegisterFunctionsToAnimSc(params Action<RuntimeFuncAnim>[] functions)
|
|
{
|
|
foreach (Action<RuntimeFuncAnim> function in functions)
|
|
{
|
|
string functionName = function.Method.Name;
|
|
if (!animationSc.registeredFunctions.TryAdd(functionName, function))
|
|
{
|
|
Debug.LogWarning($"Function {functionName} is already registered.");
|
|
}
|
|
else
|
|
{
|
|
registeredFunctionNames.Add(functionName);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void RemoveAllRegisteredFunctions()
|
|
{
|
|
foreach (string functionName in registeredFunctionNames)
|
|
{
|
|
if (!animationSc.registeredFunctions.Remove(functionName))
|
|
{
|
|
Debug.LogWarning($"Function {functionName} is not found.");
|
|
}
|
|
}
|
|
|
|
registeredFunctionNames.Clear();
|
|
}
|
|
|
|
protected virtual void RemoveFunctionsFromAnimSc(params Action[] functions)
|
|
{
|
|
foreach (Action function in functions)
|
|
{
|
|
string functionName = function.Method.Name;
|
|
if (!animationSc.registeredFunctions.Remove(functionName))
|
|
{
|
|
Debug.LogWarning($"Function {functionName} is not found.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |