using EasyTalk.Controller; using EasyTalk.Nodes.Core; using System; using System.Collections.Generic; using UnityEngine; namespace EasyTalk.Nodes.Variable { /// /// A node for defining a variable. /// [Serializable] public class VariableNode : Node, FunctionalNode { /// /// The name of the variable. /// [SerializeField] private string variableName; /// /// The initial value of the variable. /// [SerializeField] private string variableValue; /// /// Whether the variable value should be reset to its original value when its dialogue is entered. /// [SerializeField] private bool resetOnEntry = true; /// /// Whether the variable is a global variable. /// [SerializeField] private bool isGlobal = false; /// /// Creates a new VariableNode. /// public VariableNode() { this.name = "VARIABLE"; } /// /// Gets or sets the name of the variable. /// public string VariableName { get { return this.variableName; } set { this.variableName = value; } } /// /// Gets or sets the initial value of the variable. /// public string VariableValue { get { return this.variableValue; } set { this.variableValue = value; } } /// /// Gets or sets whether the variable should be reset whenever its dialogue is entered. /// public bool ResetOnEntry { get { return this.resetOnEntry; } set { this.resetOnEntry = value; } } /// /// Gets or sets whether the variable is a global variable. /// public bool IsGlobal { get { return this.isGlobal; } set { this.isGlobal = value; } } /// public bool DetermineAndStoreValue(NodeHandler nodeHandler, Dictionary nodeValues, GameObject convoOwner = null) { NodeVariable nodeVariable = nodeHandler.GetVariable(variableName); if(nodeVariable != null) { NodeConnection output = Outputs[0]; nodeValues.TryAdd(output.ID, nodeVariable.currentValue); } return true; } /// public List GetDependencyOutputIDs() { return FindDependencyOutputIDs(); } /// public bool HasDependencies() { return FindDependencyOutputIDs().Count > 0; } } }