コード例 #1
0
    public void ProcessThreads(int threadId)
    {
        //ApplyPendingDataToVariable(currLoop);

        AbilityCentralThreadPool inst  = GetCentralInst();
        SplitterData             sData = threadMap[threadId] as SplitterData;

        //Debug.LogFormat("Thread id {0} currently {1}/{2}.", threadId, sData.numberOfLoops, inst.ReturnRuntimeParameter<int>(GetNodeId(), 0).v);

        if (sData.numberOfLoops < GetNodeVariable <int>("Number of Loops") || GetNodeVariable <int>("Number of Loops") == -1)
        {
            NodeModifierBaseThread trdInst = new NodeModifierBaseThread(threadId, this, 0);
            trdInst.SetNodeData(GetNodeId(), inst.GetNodeBranchData(GetNodeId()));

            int threadToUse = inst.AddNewThread(trdInst);
            //Debug.LogFormat("Thread {0} is starting a new journey.", threadToUse);
            //Debug.LogFormat("Thread id {0} has been created.", threadToUse);
            SetVariable <int>(threadToUse, "Number of Loops");
        }
        else
        {
            //Debug.LogFormat("Thread {0} was rmed.", threadId);
            inst.HandleThreadRemoval(threadId);
            threadMap.Remove(threadId);
        }
    }
コード例 #2
0
    void TriggerOnHostProcessed(int[] value)
    {
        AbilityCentralThreadPool newA = new AbilityCentralThreadPool(value[0]);

        AbilitiesManager.aData[value[0]].abilties[GetNodeVariable <string>("Ability Name")].CreateAbility(newA, value[1], value[2]);
        newA.StartThreads(0);
        HandlePostAbilityCreation();
    }
コード例 #3
0
    public void SendVariableManifest(AbilityCentralThreadPool inst, AbilityNodeNetworkData[] manifest)
    {
        byte[] playerId  = BitConverter.GetBytes(inst.ReturnPlayerCasted());
        byte[] centralId = BitConverter.GetBytes(inst.ReturnCentralId());

        //Debug.LogFormat("Sending out Data for {0},{1}", inst.ReturnPlayerCasted(), inst.ReturnCentralId());
        byte[] manifestData = PrepareVariableManifest(manifest);

        bytesToSend = new byte[8 + manifestData.Length];

        Buffer.BlockCopy(playerId, 0, bytesToSend, 0, 4);
        Buffer.BlockCopy(centralId, 0, bytesToSend, 4, 4);
        Buffer.BlockCopy(manifestData, 0, bytesToSend, 8, manifestData.Length);
        SendEncodedMessages();
    }
コード例 #4
0
        public int InsertSpawnedIntoFreeSpace(AbilityCentralThreadPool inst)
        {
            int index = 0;

            if (internalFreeSpaceTracker.Count > 0)
            {
                index = internalFreeSpaceTracker[0];
                internalFreeSpaceTracker.RemoveAt(0);
            }
            else
            {
                index = playerSpawnedCentrals.l.Count;
            }

            playerSpawnedCentrals.ModifyElementAt(index,inst);
            return(index);
        }
コード例 #5
0
    public void InputCallback(int i)
    {
        //AbilitiesManager.aData[playerId].abilties[]
        AbilityCentralThreadPool centralPool = new AbilityCentralThreadPool(playerId);

        SignalCentralCreation(centralPool);
        CreateAbility(centralPool,ClientProgram.clientId);

        if (ClientProgram.hostId == ClientProgram.clientId)
        {
            centralPool.StartThreads(0);
        }
        else
        {
            centralPool.StartThreads(1);
        }
        //(NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.INPUT_SIGNAL] as InputSignalEncoder).SendInputSignal(playerId, abilityId);
    }
コード例 #6
0
    public override void ThreadZeroed(int parentThread)
    {
        base.ThreadZeroed(parentThread);

        AbilityCentralThreadPool centralInst = GetCentralInst();

        int[][] variableLinks = centralInst.GetVariableLinks(0, GetNodeId(), GetVariableId("Return from Variable"));
        if (variableLinks.Length == 0)
        {
            return;
        }

        int[] modifiedReturn = variableLinks[0];

        returnTargetInst = centralInst.ReturnRuntimeParameter(modifiedReturn[0], modifiedReturn[1]);
        returnTargetInst.RunGenericBasedOnRP <int>(this, parentThread);
        threadMap.Remove(parentThread);
    }
コード例 #7
0
    public override void NodeCallback()
    {
        base.NodeCallback();

        //Debug.Log("Node was callbacked!");
        //Debug.LogFormat("NodeID {0}, Thread ID {1}", name, GetNodeThreadId());

        if (IsHost())
        {
            AbilityCentralThreadPool inst = GetCentralInst();
            AbilityCentralThreadPool newA = new AbilityCentralThreadPool(inst.GetPlayerId());
            //AbilitiesManager.aData[inst.GetPlayerId()].abilties[GetNodeVariable<string>("Ability Name")].SignalCentralCreation(newA);
            AbilitiesManager.aData[inst.GetPlayerId()].abilties[GetNodeVariable <string>("Ability Name")].CreateAbility(newA, ClientProgram.clientId);
            newA.StartThreads(0);
            GetCentralInst().UpdateVariableValue <int[]>(GetNodeId(), GetVariableId("Created Ability"), new int[] { inst.GetPlayerId(), ClientProgram.clientId, newA.ReturnCentralId() }, true, false);
            HandlePostAbilityCreation();
            return;
        }

        //if(GetNodeVariable<int[]>("Created Ability") != null)
        //TriggerOnHostProcessed(GetNodeVariable<int[]>("Created Ability"));
    }
コード例 #8
0
    /*public void CreateAbilityNetworkData() {
     *  AbilityCentralThreadPool centralPool = new AbilityCentralThreadPool(playerId);
     *  SignalCentralCreation(centralPool);
     *  CreateAbility(centralPool, ClientProgram.clientId);
     * }*/


    public void CreateAbility(AbilityCentralThreadPool threadInst,int pId,int givenPopulatedId = -1)
    {
        if (givenPopulatedId > -1)
        {
            AbilitiesManager.aData[pId].playerSpawnedCentrals.ModifyElementAt(givenPopulatedId,threadInst);
        }
        else
        {
            givenPopulatedId = AbilitiesManager.aData[pId].InsertSpawnedIntoFreeSpace(threadInst);//AbilityCentralThreadPool.globalCentralList.Add(threadInst);
        }
        //int nId = AbilityTreeNode.globalList.Add(new AbilityNodeHolder(tId.ToString(), a));
        //Variable[][] clonedCopy = CloneRuntimeParams(dataVar);

        RuntimeParameters[][] clonedRp = new RuntimeParameters[dataVar.Length][];
        int[][][][][]         linkMap  = new int[1][][][][];
        linkMap[0] = new int[dataVar.Length][][][];

        for (int i = 0; i < dataVar.Length; i++)
        {
            clonedRp[i]   = new RuntimeParameters[dataVar[i].Length];
            linkMap[0][i] = new int[dataVar[i].Length][][];

            for (int j = 0; j < dataVar[i].Length; j++)
            {
                clonedRp[i][j]   = dataVar[i][j].field.ReturnNewRuntimeParamCopy();
                linkMap[0][i][j] = dataVar[i][j].links;
            }
        }


        //Debug.Log(boolData.OutputValues());
        bool[][] clonedBoolValues = boolData.ReturnNewCopy();

        threadInst.SetCentralData(pId,givenPopulatedId,clonedRp,generatedLinks,dataType,nodeBranchingData,clonedBoolValues,autoManagedVariables,targettedNodes,nodeNetworkVariables);

        //if(startThreads)
        //    threadInst.StartThreads();
        //threadInst.SendVariableNetworkData();
    }
コード例 #9
0
    public void ParseMessage(byte[] bytesToParse)
    {
        int playerId  = BitConverter.ToInt32(bytesToParse, 0);
        int centralId = BitConverter.ToInt32(bytesToParse, 4);

        List <AbilityNodeNetworkData> cCData      = new List <AbilityNodeNetworkData>();
        AbilityCentralThreadPool      centralInst = AbilitiesManager.aData[playerId].playerSpawnedCentrals.GetElementAt(centralId);

        //Debug.LogFormat("Node data for {0}/{1}: ", playerId, centralId);
        foreach (AbilityNodeNetworkData parsedData in ParseManifest(bytesToParse, 8))
        {
            cCData.Add(parsedData);

            if (centralInst == null)
            {
                if (cCData.Count == 2)
                {
                    centralInst = new AbilityCentralThreadPool(playerId);

                    int    pId = (cCData[0] as AbilityNodeNetworkData <int>).value;
                    string aId = (cCData[1] as AbilityNodeNetworkData <string>).value;
                    AbilitiesManager.aData[pId].abilties[aId].CreateAbility(centralInst, playerId, centralId);
                }

                //Debug.Log("Continued");
                continue;
            }

            //Debug.Log("Data recieved!");
            centralInst.AddPendingData(parsedData);
        }

        if (ClientProgram.clientId == ClientProgram.hostId)
        {
            centralInst.AddVariableNetworkData(cCData.ToArray());
        }

        centralInst.StartThreads(0);
    }
コード例 #10
0
 public void SignalCentralCreation(AbilityCentralThreadPool central)
 {
     central.AddVariableNetworkData(new AbilityNodeNetworkData <int>(-1,-1,playerId));
     central.AddVariableNetworkData(new AbilityNodeNetworkData <string>(-1,-1,abilityId));
 }
コード例 #11
0
 public override void ApplyDataToTargetVariable(AbilityCentralThreadPool central)
 {
     //Debug.LogFormat("Data applied: {0} to: {1}", value, central.GetNode(nodeId));
     central.UpdateVariableValue <T>(nodeId, varId, value, false);
     central.UpdateVariableData <T>(nodeId, varId);
 }