Esempio n. 1
0
 internal void ResolveNodesAfterSerialization(CKlaxScriptObject outerScriptObject)
 {
     ScriptableObject = outerScriptObject;
     for (int i = 0; i < m_nodes.Count; i++)
     {
         if (m_nodes[i] is CKlaxVariableNode variableNode)
         {
             int varIndex = variableNode.m_sourceVariableIndex;
             variableNode.m_sourceVariable = variableNode.m_bIsLocalVariable ? m_localVariables[varIndex] : outerScriptObject.KlaxVariables[varIndex];
         }
         else if (m_nodes[i] is CExecuteCustomFunctionNode functionNode)
         {
             functionNode.ResolveFunctionReference(outerScriptObject);
         }
     }
     CScriptSerializer.ResolveNodeReferences(m_nodes);
 }
Esempio n. 2
0
        internal void PrepareNodesForSerialization(CKlaxScriptObject outerScriptObject)
        {
            CScriptSerializer.PrepareNodesForSerialization(m_nodes);
            Dictionary <CKlaxVariable, int> objectVariableToIndex = new Dictionary <CKlaxVariable, int>();

            for (var i = 0; i < outerScriptObject.KlaxVariables.Count; i++)
            {
                objectVariableToIndex.Add(outerScriptObject.KlaxVariables[i], i);
            }

            Dictionary <CKlaxVariable, int> localVariableToIndex = new Dictionary <CKlaxVariable, int>();

            for (int i = 0; i < m_localVariables.Count; i++)
            {
                localVariableToIndex.Add(m_localVariables[i], i);
            }

            for (int i = 0; i < m_nodes.Count; i++)
            {
                if (m_nodes[i] is CKlaxVariableNode variableNode)
                {
                    if (variableNode.SourceVariable == null)
                    {
                        throw new NullReferenceException("Tried to serialize a KlaxVariable node without a valid reference to an existing variable");
                    }

                    if (objectVariableToIndex.TryGetValue(variableNode.SourceVariable, out int index))
                    {
                        variableNode.m_sourceVariableIndex = index;
                        variableNode.m_bIsLocalVariable    = false;
                        continue;
                    }

                    if (localVariableToIndex.TryGetValue(variableNode.SourceVariable, out int localIndex))
                    {
                        variableNode.m_sourceVariableIndex = localIndex;
                        variableNode.m_bIsLocalVariable    = true;
                        continue;
                    }

                    throw new Exception("KlaxVariable Node Referenced a variable that does not exist in its context");
                }
            }
        }
 public CKlaxScriptNodeQueryContext(CKlaxScriptObject queryObject)
 {
     QueryObject = queryObject;
 }