1
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
namespace BITKit.IO
|
||||
{
|
||||
public interface IAsset
|
||||
{
|
||||
string Name { get; set; }
|
||||
byte[] Buffer{ get; set; }
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3eb498b90aa487048a9fd9a3e9253dd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BITKit.StateMachine
|
||||
{
|
||||
public struct EmptyState:IState
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnStateEntry(IState old)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
}
|
||||
}
|
||||
public interface IState
|
||||
{
|
||||
bool Enabled { get; set; }
|
||||
void Initialize();
|
||||
void OnStateEntry(IState old);
|
||||
void OnStateUpdate(float deltaTime);
|
||||
void OnStateExit(IState old, IState newState);
|
||||
}
|
||||
|
||||
public interface IStateMachine<T> where T:IState
|
||||
{
|
||||
bool Enabled { get; set; }
|
||||
T CurrentState { get; set; }
|
||||
event Action<T,T> OnStateChanged;
|
||||
event Action<T> OnStateRegistered;
|
||||
event Action<T> OnStateUnRegistered;
|
||||
|
||||
IDictionary<Type, T> StateDictionary { get; }
|
||||
void Initialize();
|
||||
void UpdateState(float deltaTime);
|
||||
void DisposeState();
|
||||
void TransitionState<State>() where State : T;
|
||||
void TransitionState(T state);
|
||||
void Register(T newState) => throw new NotImplementedException("未实现的接口");
|
||||
void UnRegister(T newState) => throw new NotImplementedException("未实现的接口");
|
||||
void InvokeOnStateRegistered(T state){}
|
||||
void InvokeOnStateUnRegistered(T state){}
|
||||
}
|
||||
|
||||
public static class StateMachineUtils
|
||||
{
|
||||
public static void Register<T>(this IStateMachine<T> stateMachine, T newState) where T : IState
|
||||
{
|
||||
if (stateMachine.StateDictionary.ContainsKey(newState.GetType()))
|
||||
{
|
||||
throw new ArgumentException($"State {newState.GetType().Name} already registered");
|
||||
}
|
||||
stateMachine.StateDictionary.Add(newState.GetType(), newState);
|
||||
newState.Initialize();
|
||||
stateMachine.InvokeOnStateRegistered(newState);
|
||||
}
|
||||
public static void UnRegister<T>(this IStateMachine<T> stateMachine, T newState) where T : IState
|
||||
{
|
||||
if (!stateMachine.StateDictionary.ContainsKey(newState.GetType())) return;
|
||||
stateMachine.StateDictionary.Remove(newState.GetType());
|
||||
stateMachine.InvokeOnStateUnRegistered(newState);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c15343777409d940bcf21398f800660
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe7ae68fb2f193640afdc79aef634c98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user