Files
Fishing2NetTest/Assets/Scripts/NBC/FSM/FsmBaseState.cs
2026-03-05 18:07:55 +08:00

91 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace NBC
{
public abstract class FsmBaseState<TOwnerClass>
{
protected TOwnerClass _owner;
protected Fsm<TOwnerClass> Root;
public FsmTransmit Params = new FsmTransmit();
public abstract uint StateId { get; }
public uint PrevState { get; set; }
public uint NextState { get; set; }
protected float EnterTime { get; set; }
public void Init(TOwnerClass owner, Fsm<TOwnerClass> fsm)
{
_owner = owner;
Root = fsm;
}
public virtual void Transition(FsmBaseState<TOwnerClass> source)
{
Enter();
}
public void Enter()
{
EnterTime = Time.time;
onEnter();
}
protected virtual void onEnter()
{
}
public void Exit()
{
onExit();
}
protected virtual void onExit()
{
}
public uint Update()
{
return onUpdate();
}
protected virtual uint onUpdate()
{
return 0;
}
public uint FixedUpdate()
{
return onFixedUpdate();
}
protected virtual uint onFixedUpdate()
{
return 0;
}
public void PreUpdate()
{
OnPreUpdate();
}
protected virtual void OnPreUpdate()
{
}
public uint LateUpdate()
{
return OnLateUpdate();
}
protected virtual uint OnLateUpdate()
{
return 0;
}
}
}