public void AddPendingData(AbilityNodeNetworkData nodeNetworkData)
    {
        if (nodeNetworkData.nodeId == -1 || nodeNetworkData.varId == -1)
        {
            return;
        }

        // Applies it if it matches node current status
        //Debug.LogFormat("TID {0}, TVSC {1}, GVSC {2}", nodes[nodeNetworkData.nodeId].GetNodeThreadId(), networkVariableData[nodeNetworkData.nodeId].nodeCallbackCount, nodeNetworkData.variableSetCount);
        if (nodes[nodeNetworkData.nodeId] != null)
        {
            if (nodes[nodeNetworkData.nodeId].GetNodeThreadId() > -1 && networkVariableData[nodeNetworkData.nodeId].nodeCallbackCount == nodeNetworkData.variableSetCount)
            {
                //Debug.LogWarning("Pending data applied. #1");
                nodeNetworkData.ApplyDataToTargetVariable(this);
                return;
            }
        }

        // If not, add this to pending list.
        //Debug.Log("Data added to " + Tuple.Create(nodeNetworkData.nodeId, nodeNetworkData.varId, nodeNetworkData.variableSetCount));
        pendingApplyData.Add(Tuple.Create(nodeNetworkData.nodeId, nodeNetworkData.varId, nodeNetworkData.variableSetCount), nodeNetworkData);
    }
    /*public NETWORK_CLIENT_ELIGIBILITY CheckEligibility(int nodeId, int variableId) {
     *
     *  if(LoadedData.GetVariableType(subclassTypes[nodeId], variableId, VariableTypes.CLIENT_ACTIVATED)) {
     *      if(playerId != ClientProgram.clientId)
     *          return NETWORK_CLIENT_ELIGIBILITY.DENIED;
     *      else
     *          return NETWORK_CLIENT_ELIGIBILITY.GRANTED;
     *  }
     *
     *  if(LoadedData.GetVariableType(subclassTypes[nodeId], variableId, VariableTypes.HOST_ACTIVATED))
     *      if(ClientProgram.hostId != ClientProgram.clientId)
     *          return NETWORK_CLIENT_ELIGIBILITY.DENIED;
     *      else
     *          return NETWORK_CLIENT_ELIGIBILITY.GRANTED;
     *
     *
     *  return NETWORK_CLIENT_ELIGIBILITY.LOCAL_HOST;
     * }*/

    public void UpdateVariableValue <T>(int nodeId, int variableId, T value, bool runNetworkCode = true, bool runValueChanged = true)
    {
        bool reference = CheckIfReferenced(nodeId, variableId);

        // If reference is not empty, redirects it to change that variable instead.
        if (reference)
        {
            Tuple <int, int, int> refLink = instancedNodes[nodeId];

            //Debug.LogFormat("Var set, central {0}, node {1}, var {2}, value {3}", refLink.Item1, refLink.Item2, variableId, value);
            GetRootReferenceCentral(nodeId).UpdateVariableValue <T>(refLink.Item3, variableId, value, runValueChanged);
            return;
        }

        if (runNetworkCode)
        {
            if (LoadedData.GetVariableType(subclassTypes[nodeId], variableId, VariableTypes.NETWORK))
            {
                AbilityNodeNetworkData dataPacket = new AbilityNodeNetworkData <T>(nodeId, variableId, value, networkVariableData[nodeId].nodeCallbackCount);
                //Debug.Log("Input is been sent out.");
                //INodeNetworkPoint nwPointInst = nodes[progenitorData[nodeId]] as INodeNetworkPoint;
                //Debug.Log(nodes[progenitorData[nodeId]]);
                //nwPointInst.ModifyDataPacket(dataPacket);
                AddVariableNetworkData(dataPacket);
            }

            /*NETWORK_CLIENT_ELIGIBILITY nCE = CheckEligibility(nodeId, variableId);
             *
             * switch(nCE) {
             *  case NETWORK_CLIENT_ELIGIBILITY.GRANTED:
             *      //Debug.Log("Data point going");
             *      //Debug.LogFormat("Data going to be applied to: {0} to: {1}", value, GetNode(nodeId));
             *      AbilityNodeNetworkData dataPacket = new AbilityNodeNetworkData<T>(nodeId, variableId, value, networkVariableData[nodeId].nodeCallbackCount);
             *      //INodeNetworkPoint nwPointInst = nodes[progenitorData[nodeId]] as INodeNetworkPoint;
             *      //Debug.Log(nodes[progenitorData[nodeId]]);
             *      //nwPointInst.ModifyDataPacket(dataPacket);
             *      AddVariableNetworkData(dataPacket);
             *      break;
             *
             *  case NETWORK_CLIENT_ELIGIBILITY.DENIED:
             *      return;
             * }*/
        }

        // Does run value stuff here.

        /*if(runValueChanged) {
         *
         *  int totalOnCalled = RunTargettedNodes<T>(nodeId, variableId, ON_VARIABLE_CATERGORY.ON_CHANGED, value);
         *
         *  if(onCallbacks.ContainsKey(nodeId))
         *      if(onCallbacks[nodeId].ContainsKey(ON_VARIABLE_CATERGORY.ON_CHANGED))
         *          foreach(var id in onCallbacks[nodeId][ON_VARIABLE_CATERGORY.ON_CHANGED]) {
         *              AbilityCentralThreadPool centralInst = AbilitiesManager.aData[id.Item1].playerSpawnedCentrals.GetElementAt(id.Item2);
         *              totalOnCalled += centralInst.RunTargettedNodes<T>(id.Item3, variableId, ON_VARIABLE_CATERGORY.ON_CALLED, value);
         *          }
         *
         *  if(totalOnCalled > 0)
         *      return;
         * }*/

        RuntimeParameters <T> paramInst = runtimeParameters[nodeId][variableId] as RuntimeParameters <T>;
        bool varWasSet = false;

        if (paramInst != null)
        {
            paramInst.v = value;
            booleanData[nodeId][variableId] = false;
            varWasSet = true;
        }
        else if (LoadedData.GetVariableType(subclassTypes[nodeId], variableId, VariableTypes.INTERCHANGEABLE))
        {
            string varName = runtimeParameters[nodeId][variableId].n;
            //int[][] links = runtimeParameters[nodeId][variableId].links;

            //Debug.LogFormat("Var changed from {0} to {1}", runtimeParameters[nodeId][variableId].field.t, typeof(T));
            runtimeParameters[nodeId][variableId] = new RuntimeParameters <T>(varName, value);
            booleanData[nodeId][variableId]       = false;
            varWasSet = true;
        }

        if (varWasSet && runValueChanged)
        {
            //Debug.Log(value);
            IOnVariableSet oVS = CreateNewNodeIfNull(nodeId) as IOnVariableSet;

            if (oVS != null)
            {
                oVS.OnVariableSet(variableId);
            }
        }
    }