-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
1 parent
8919489
commit ca3aad8
Showing
9 changed files
with
80 additions
and
59 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
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
30 changes: 29 additions & 1 deletion
30
Package/Runtime/CrashKonijn.Agent.Runtime/ActionProviderBase.cs
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 |
---|---|---|
@@ -1,11 +1,39 @@ | ||
using CrashKonijn.Agent.Core; | ||
using System.Collections.Generic; | ||
using CrashKonijn.Agent.Core; | ||
using UnityEngine; | ||
|
||
namespace CrashKonijn.Agent.Runtime | ||
{ | ||
public abstract class ActionProviderBase : MonoBehaviour, IActionProvider | ||
{ | ||
private Dictionary<IAction, IActionDisabler> disablers = new(); | ||
|
||
public abstract IActionReceiver Receiver { get; set; } | ||
public abstract void ResolveAction(); | ||
|
||
public bool IsDisabled(IAction action) | ||
{ | ||
if (!this.disablers.TryGetValue(action, out var disabler)) | ||
return true; | ||
|
||
if (this.Receiver is not IMonoAgent agent) | ||
return true; | ||
|
||
if (disabler.IsDisabled(agent)) | ||
return false; | ||
|
||
this.Enable(action); | ||
return true; | ||
} | ||
|
||
public void Enable(IAction action) | ||
{ | ||
this.disablers.Remove(action); | ||
} | ||
|
||
public void Disable(IAction action, IActionDisabler disabler) | ||
{ | ||
this.disablers[action] = disabler; | ||
} | ||
} | ||
} |
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