Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Package/Documentation/Classes/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,19 @@ public static class ActionDisabler
```csharp
foreach (var pickupAppleAction in this.actionProvider.GetActions<PickupAppleAction>())
{
pickupAppleAction.Disable(ActionDisabler.Forever);
this.actionProvider.Disable(pickupAppleAction, ActionDisabler.Forever);
this.actionProvider.Enable(pickupAppleAction);
}
```
{% endcode %}

{% code lineNumbers="true" %}
```csharp
this.actionProvider.Disable<PickupAppleAction>();
this.actionProvider.Enable<PickupAppleAction>();
```
{% endcode %}

{% code lineNumbers="true" %}
```csharp
public class EatAction : GoapActionBase<EatAction.Data>
Expand All @@ -129,7 +137,7 @@ public class EatAction : GoapActionBase<EatAction.Data>
public override void End(IMonoAgent agent, Data data)
{
// This will disable the action for 5 seconds
this.Disable(ActionDisabler.ForTime(5f));
this.Disable(agent, ActionDisabler.ForTime(5f));
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void RequestGoal<TGoal1, TGoal2, TGoal3, TGoal4, TGoal5>(bool resolve = t
void SetDistanceMultiplierSpeed(float speed);
List<TAction> GetActions<TAction>() where TAction : IGoapAction;

void Disable<TAction>(IActionDisabler disabler) where TAction : IGoapAction;
void Enable<TAction>() where TAction : IGoapAction;

#region Obsolete

[Obsolete("Use CurrentPlan.Goal instead")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,22 @@ private void ValidateSetup()
/// <returns>A list of actions of the specified type.</returns>
public List<TAction> GetActions<TAction>() where TAction : IGoapAction => this.AgentType.GetActions<TAction>();

public void Disable<TAction>(IActionDisabler disabler) where TAction : IGoapAction
{
foreach (var action in this.GetActions<TAction>())
{
this.Disable(action, disabler);
}
}

public void Enable<TAction>() where TAction : IGoapAction
{
foreach (var action in this.GetActions<TAction>())
{
this.Enable(action);
}
}

private void OnDestroy()
{
this.Logger.Dispose();
Expand Down