-
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
Showing
12 changed files
with
106 additions
and
92 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
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,40 @@ | ||
using System; | ||
|
||
namespace PinionCyber.StateManagement | ||
{ | ||
public class ActiverChanger<T> where T : IActivable | ||
{ | ||
T _Activable; | ||
/// <summary> | ||
/// An empty implementation is usually passed here. | ||
/// This constructor calls the IActivable.Enable on the parameter. | ||
/// </summary> | ||
/// <param name="first"></param> | ||
public ActiverChanger(T first) | ||
{ | ||
_Activable = first; | ||
_Activable.Enable(); | ||
} | ||
|
||
/// <summary> | ||
/// Changes the current activable object to the provided one and manages their active states. | ||
/// It disables the current activable object before switching to the new one, which is then enabled. | ||
/// </summary> | ||
/// <param name="activer">The new activable object to switch to.</param> | ||
public void Change(T activer) | ||
{ | ||
_Activable.Disable(); | ||
_Activable = activer; | ||
_Activable.Enable(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the current activable object. | ||
/// </summary> | ||
/// <returns>The current activable object.</returns> | ||
public T Activer() | ||
{ | ||
return _Activable; | ||
} | ||
} | ||
} |
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,8 @@ | ||
namespace PinionCyber.StateManagement | ||
{ | ||
public interface IActivable | ||
{ | ||
void Enable(); | ||
void Disable(); | ||
} | ||
} |
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 was deleted.
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
This file was deleted.
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.