Skip to content

Commit

Permalink
refactor(conditions): definition data is now exposed to implement cus…
Browse files Browse the repository at this point in the history
…tom runtime choice displays
  • Loading branch information
clevercrowgames committed Apr 16, 2024
1 parent fb18251 commit f7fe75f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ConditionRuntime : ICondition {
private bool _initTriggered;

public string UniqueId { get; }
public IConditionData Data => _data;

public ConditionRuntime (IDialogueController dialogueController, string uniqueId, IConditionData data) {
_data = data;
Expand Down
2 changes: 2 additions & 0 deletions Assets/com.fluid.dialogue/Runtime/Conditions/ICondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace CleverCrow.Fluid.Dialogues.Conditions {
public interface ICondition : IUniqueId {
IConditionData Data { get; }

bool GetIsValid (INode parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class NodeChoiceHub : INode {
public string UniqueId { get; }
public List<IAction> EnterActions { get; }
public List<IAction> ExitActions { get; }
public IReadOnlyList<ICondition> Conditions => _conditions;

public virtual bool IsValid =>
_conditions.Find(c => !c.GetIsValid(this)) == null;
Expand Down
2 changes: 2 additions & 0 deletions Assets/com.fluid.dialogue/Runtime/Nodes/INode.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System.Collections.Generic;
using CleverCrow.Fluid.Dialogues.Actions;
using CleverCrow.Fluid.Dialogues.Choices;
using CleverCrow.Fluid.Dialogues.Conditions;

namespace CleverCrow.Fluid.Dialogues.Nodes {
public interface INode : IUniqueId {
List<IAction> EnterActions { get; }
List<IAction> ExitActions { get; }
bool IsValid { get; }
List<IChoice> HubChoices { get; }
IReadOnlyList<ICondition> Conditions { get; }

/// <summary>
/// Returns the first valid child node
Expand Down
1 change: 1 addition & 0 deletions Assets/com.fluid.dialogue/Runtime/Nodes/NodeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public abstract class NodeBase : INode {
_conditions.Find(c => !c.GetIsValid(this)) == null;
public List<IChoice> HubChoices { get; }
public string UniqueId { get; }
public IReadOnlyList<ICondition> Conditions => _conditions;

protected List<INode> Children =>
_childrenRuntimeCache ??
Expand Down

0 comments on commit f7fe75f

Please sign in to comment.