Beispiel #1
0
        public List <AIOption> GetOptions()
        {
            List <AIOption>  options      = new List <AIOption>();
            DataIteratorNode iteratorNode = GetInputPort(nameof(DataIteratorNode)).GetInputValue <DataIteratorNode>();

            if (iteratorNode != null)
            {
                int          collectionSize = iteratorNode.CollectionCount;
                AIBrainGraph brainGraph     = (AIBrainGraph)graph;
                while (collectionSize > iteratorNode.Index)
                {
                    options.Add(new AIOption(this));
                    iteratorNode.Index++;
                    foreach (ICacheable cacheable in brainGraph.GetNodes <ICacheable>())
                    {
                        cacheable.ClearCache();
                    }
                }
                iteratorNode.Index = 0;
            }
            else
            {
                options.Add(new AIOption(this));
            }
            return(options);
        }
Beispiel #2
0
 public AIOption(OptionNode optionNode, DataIteratorNode dataIteratorNode = null)
 {
     // Saving linked optionNode
     OptionNode  = optionNode;
     Description = OptionNode.Description;
     // Calculate weight
     Weight = OptionNode.GetWeight();
     // Calculate rank
     Rank = OptionNode.GetRank();
     // Fetch actions
     foreach (ActionNode actionNode in OptionNode.GetActions())
     {
         AiActions.Add(new AIAction(actionNode));
     }
 }
Beispiel #3
0
 public override void OnBodyGUI()
 {
     if (_dataIteratorNode == null)
     {
         _dataIteratorNode = (DataIteratorNode)target;
     }
     serializedObject.Update();
     NodeEditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(_dataIteratorNode.Enumerable)));
     if (_dataIteratorNode.GetInputPort(nameof(_dataIteratorNode.Enumerable)).IsConnected&& _dataIteratorNode.ArgumentType != null)
     {
         NodeEditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(_dataIteratorNode.LinkedOption)));
         NodePort nodePort = _dataIteratorNode.GetOutputPort(_dataIteratorNode.ArgumentType.Name);
         NodeEditorGUILayout.PortField(nodePort);
     }
     serializedObject.ApplyModifiedProperties();
 }