141 lines
4.3 KiB
C#
141 lines
4.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.StateMachine;
|
|
using Unity.Mathematics;
|
|
|
|
namespace BITFactory.Cutting
|
|
{
|
|
public interface ICuttingToolBrush:IState
|
|
{
|
|
string Name { get; }
|
|
string Description { get; }
|
|
void HandlePoint(bool isPreview,float3 normal, float3 point);
|
|
void ReleasePoint(float3 normal,float3 point);
|
|
}
|
|
|
|
public interface ICuttingToolService : IStateMachine<ICuttingToolBrush>
|
|
{
|
|
bool IsPreview { get; }
|
|
bool IsCutting { get; }
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class CuttingToolServiceFromDI : InjectFromDI<ICuttingToolService>,ICuttingToolService
|
|
{
|
|
private ICuttingToolService _cuttingToolServiceImplementation => Value;
|
|
public bool Enabled
|
|
{
|
|
get => _cuttingToolServiceImplementation.Enabled;
|
|
set => _cuttingToolServiceImplementation.Enabled = value;
|
|
}
|
|
|
|
public ICuttingToolBrush CurrentState
|
|
{
|
|
get => _cuttingToolServiceImplementation.CurrentState;
|
|
set => _cuttingToolServiceImplementation.CurrentState = value;
|
|
}
|
|
|
|
public event Action<ICuttingToolBrush, ICuttingToolBrush> OnStateChanged
|
|
{
|
|
add => _cuttingToolServiceImplementation.OnStateChanged += value;
|
|
remove => _cuttingToolServiceImplementation.OnStateChanged -= value;
|
|
}
|
|
|
|
public event Action<ICuttingToolBrush> OnStateRegistered
|
|
{
|
|
add=>_cuttingToolServiceImplementation.OnStateRegistered+=value;
|
|
remove=>_cuttingToolServiceImplementation.OnStateRegistered-=value;
|
|
}
|
|
public event Action<ICuttingToolBrush> OnStateUnRegistered
|
|
{
|
|
add=>_cuttingToolServiceImplementation.OnStateUnRegistered+=value;
|
|
remove=>_cuttingToolServiceImplementation.OnStateUnRegistered-=value;
|
|
}
|
|
|
|
public IDictionary<Type, ICuttingToolBrush> StateDictionary => _cuttingToolServiceImplementation.StateDictionary;
|
|
|
|
public void Initialize()
|
|
{
|
|
_cuttingToolServiceImplementation.Initialize();
|
|
}
|
|
|
|
public void UpdateState(float deltaTime)
|
|
{
|
|
_cuttingToolServiceImplementation.UpdateState(deltaTime);
|
|
}
|
|
|
|
public void DisposeState()
|
|
{
|
|
_cuttingToolServiceImplementation.DisposeState();
|
|
}
|
|
|
|
public void TransitionState<State>() where State : ICuttingToolBrush
|
|
{
|
|
_cuttingToolServiceImplementation.TransitionState<State>();
|
|
}
|
|
|
|
public void TransitionState(ICuttingToolBrush state)
|
|
{
|
|
_cuttingToolServiceImplementation.TransitionState(state);
|
|
}
|
|
|
|
public void Register(ICuttingToolBrush newState)
|
|
{
|
|
_cuttingToolServiceImplementation.Register(newState);
|
|
}
|
|
public void UnRegister(ICuttingToolBrush newState)
|
|
{
|
|
_cuttingToolServiceImplementation.UnRegister(newState);
|
|
}
|
|
|
|
public void InvokeOnStateRegistered(ICuttingToolBrush state)
|
|
{
|
|
_cuttingToolServiceImplementation.InvokeOnStateRegistered(state);
|
|
}
|
|
|
|
public void InvokeOnStateUnRegistered(ICuttingToolBrush state)
|
|
{
|
|
_cuttingToolServiceImplementation.InvokeOnStateUnRegistered(state);
|
|
}
|
|
|
|
public bool IsPreview => _cuttingToolServiceImplementation.IsPreview;
|
|
|
|
public bool IsCutting => _cuttingToolServiceImplementation.IsCutting;
|
|
}
|
|
|
|
public abstract class CuttingToolBrush : ICuttingToolBrush
|
|
{
|
|
[Inject] protected ICuttingTool cuttingTool;
|
|
public virtual string Name => "切削笔刷";
|
|
public virtual string Description => "未定义的笔刷,看到这个说明笔刷没有实现";
|
|
public bool Enabled { get; set; }
|
|
|
|
public virtual void Initialize()
|
|
{
|
|
}
|
|
|
|
public virtual void OnStateEntry(IState old)
|
|
{
|
|
}
|
|
|
|
public virtual void OnStateUpdate(float deltaTime)
|
|
{
|
|
}
|
|
|
|
public virtual void OnStateExit(IState old, IState newState)
|
|
{
|
|
}
|
|
|
|
public virtual void HandlePoint(bool isPreview, float3 normal, float3 point)
|
|
{
|
|
}
|
|
|
|
public virtual void ReleasePoint(float3 normal, float3 point)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|