generated from techno-dwarf-works/unity-package-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anatoly Brizhan
committed
Apr 16, 2024
1 parent
a024a3f
commit 3e2b558
Showing
9 changed files
with
275 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using Better.Commons.Runtime.Utility; | ||
using Better.StateMachine.Runtime.States; | ||
|
||
namespace Better.StateMachine.Runtime.Modules | ||
{ | ||
public abstract class SingleModule<TState> : Module<TState> | ||
where TState : BaseState | ||
{ | ||
protected IStateMachine<TState> StateMachine { get; private set; } | ||
|
||
public override bool AllowLinkTo(IStateMachine<TState> stateMachine) | ||
{ | ||
return base.AllowLinkTo(stateMachine) && !IsLinked; | ||
} | ||
|
||
protected override void OnLinked(IStateMachine<TState> stateMachine) | ||
{ | ||
if (IsLinked) | ||
{ | ||
var message = "Already linked"; | ||
DebugUtility.LogException<InvalidOperationException>(message); | ||
|
||
stateMachine.RemoveModule(this); | ||
return; | ||
} | ||
|
||
StateMachine = stateMachine; | ||
} | ||
|
||
protected override void OnUnlinked(IStateMachine<TState> stateMachine) | ||
{ | ||
if (!IsLinked) | ||
{ | ||
var message = "Already unlinked"; | ||
DebugUtility.LogException<InvalidOperationException>(message); | ||
|
||
return; | ||
} | ||
|
||
StateMachine = null; | ||
} | ||
|
||
protected bool ValidateMachineRunning(bool targetState, bool logException = true) | ||
{ | ||
return ValidateMachineRunning(StateMachine, targetState, logException); | ||
} | ||
} | ||
|
||
public abstract class SingleModule : SingleModule<BaseState> | ||
{ | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/BetterStateMachine/Runtime/Modules/SingleModule.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.