Skip to content

Commit

Permalink
Merge pull request #15 from techno-dwarf-works/feature/clean-up
Browse files Browse the repository at this point in the history
Version 0.1.8
  • Loading branch information
OpOpYaDev committed May 19, 2024
1 parent 97e7287 commit 9378096
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Runtime/Modules/CacheModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,20 @@ public T GetState<T>()
DebugUtility.LogException<InvalidOperationException>(message);
return state;
}

public bool RemoveState<T>() where T : TState

public T GetOrAddState<T>()
where T : TState, new()
{
if (!TryGetState(out T state))
{
state = CacheState<T>();
}

return state;
}

public bool RemoveState<T>()
where T : TState
{
var type = typeof(T);
return _stateLocator.Remove(type);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.tdw.better.statemachine",
"displayName": "Better State Machine",
"version": "0.1.7",
"version": "0.1.8",
"unity": "2021.3",
"description": " ",
"dependencies": {
Expand Down

0 comments on commit 9378096

Please sign in to comment.