Fixup use of using on short namespaces
This commit is contained in:
parent
f310982890
commit
fb96548db2
23
imm/FSM.cs
23
imm/FSM.cs
@ -2,28 +2,27 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using imm; // Ensure this namespace is available
|
||||
|
||||
/// <summary>
|
||||
/// Base context for an FSM.
|
||||
/// MUST inherit from Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// MUST inherit from imm.Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSelf">The concrete Context type.</typeparam>
|
||||
public abstract record class FsmContextBase<TSelf> : Recorded<TSelf>
|
||||
public abstract record class FsmContextBase<TSelf> : imm.Recorded<TSelf>
|
||||
where TSelf : FsmContextBase<TSelf>
|
||||
{
|
||||
// Required for 'with' expressions.
|
||||
protected FsmContextBase(Recorded<TSelf> original) : base(original) { }
|
||||
protected FsmContextBase(imm.Recorded<TSelf> original) : base(original) { }
|
||||
protected FsmContextBase() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base state for an FSM.
|
||||
/// MUST inherit from Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// MUST inherit from imm.Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSelf">The concrete State type.</typeparam>
|
||||
/// <typeparam name="TCtx">The concrete Context type (must be based on FsmContextBase).</typeparam>
|
||||
public abstract record class FsmStateBase<TSelf, TCtx> : Recorded<TSelf>
|
||||
public abstract record class FsmStateBase<TSelf, TCtx> : imm.Recorded<TSelf>
|
||||
where TSelf : FsmStateBase<TSelf, TCtx>
|
||||
where TCtx : FsmContextBase<TCtx>
|
||||
{
|
||||
@ -44,18 +43,18 @@ public abstract record class FsmStateBase<TSelf, TCtx> : Recorded<TSelf>
|
||||
}
|
||||
|
||||
// Required for 'with' expressions.
|
||||
protected FsmStateBase(Recorded<TSelf> original) : base(original) { }
|
||||
protected FsmStateBase(imm.Recorded<TSelf> original) : base(original) { }
|
||||
protected FsmStateBase() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An immutable FSM base class.
|
||||
/// MUST inherit from Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// MUST inherit from imm.Recorded<TSelf> or Timed<TSelf> in your concrete class.
|
||||
/// </summary>
|
||||
/// <typeparam name="TSelf">The concrete FSM type.</typeparam>
|
||||
/// <typeparam name="TState">The concrete State type.</typeparam>
|
||||
/// <typeparam name="TCtx">The concrete Context type.</typeparam>
|
||||
public abstract record class FsmBase<TSelf, TState, TCtx> : Recorded<TSelf>
|
||||
public abstract record class FsmBase<TSelf, TState, TCtx> : imm.Recorded<TSelf>
|
||||
where TSelf : FsmBase<TSelf, TState, TCtx>
|
||||
where TState : FsmStateBase<TState, TCtx>
|
||||
where TCtx : FsmContextBase<TCtx>
|
||||
@ -70,7 +69,7 @@ public abstract record class FsmBase<TSelf, TState, TCtx> : Recorded<TSelf>
|
||||
}
|
||||
|
||||
// Required for 'with' expressions.
|
||||
protected FsmBase(Recorded<TSelf> original) : base(original)
|
||||
protected FsmBase(imm.Recorded<TSelf> original) : base(original)
|
||||
{
|
||||
var o = original as FsmBase<TSelf, TState, TCtx>;
|
||||
Context = o!.Context;
|
||||
@ -79,7 +78,7 @@ public abstract record class FsmBase<TSelf, TState, TCtx> : Recorded<TSelf>
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the FSM. It automatically uses the 'Process'
|
||||
/// method appropriate for Recorded or Timed, thanks to virtual overrides.
|
||||
/// method appropriate for imm.Recorded or Timed, thanks to virtual overrides.
|
||||
/// </summary>
|
||||
public TSelf Transition(
|
||||
TState newState,
|
||||
@ -94,7 +93,7 @@ public abstract record class FsmBase<TSelf, TState, TCtx> : Recorded<TSelf>
|
||||
var (ctxAfterExit, stateAfterExit) = State.OnExit(Context, newState);
|
||||
var (ctxAfterEnter, stateAfterEnter) = newState.OnEnter(ctxAfterExit, stateAfterExit);
|
||||
|
||||
// Since 'this' is at least 'Recorded<TSelf>', we can call the
|
||||
// Since 'this' is at least 'imm.Recorded<TSelf>', we can call the
|
||||
// detailed 'Process'. If 'this' is actually 'Timed<TSelf>', C#'s
|
||||
// virtual dispatch will call the 'Timed' override automatically.
|
||||
return Process(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user