コード例 #1
0
    private PreloadedFlowgraphContent PreloadFlowgraphContent(CathodeFlowgraph flowgraph, uint typeID)
    {
        PreloadedFlowgraphContent content = new PreloadedFlowgraphContent();

        content.flowraphID = flowgraph.nodeID;
        List <CathodeNodeEntity> models = GetAllOfType(ref flowgraph, typeID);

        for (int i = 0; i < models.Count; i++)
        {
            CathodeNodeEntity thisNode     = models[i];
            List <int>        modelIndexes = new List <int>();
            List <UInt32>     resourceID   = new List <UInt32>();
            foreach (CathodeParameterReference paramRef in thisNode.nodeParameterReferences)
            {
                CathodeParameter param = commandsPAK.GetParameter(paramRef.offset);
                if (param == null)
                {
                    continue;
                }
                if (param.dataType != CathodeDataType.SHORT_GUID)
                {
                    continue;
                }
                resourceID.Add(((CathodeResource)param).resourceID);
            }
            for (int x = 0; x < resourceID.Count; x++)
            {
                List <CathodeResourceReference> resRef = flowgraph.GetResourceReferencesByID(resourceID[x]);
                for (int y = 0; y < resRef.Count; y++)
                {
                    if (resRef[y].entryType != CathodeResourceReferenceType.RENDERABLE_INSTANCE)
                    {
                        continue;                                                                          //Ignoring collision maps, etc, for now
                    }
                    for (int p = 0; p < resRef[y].entryCountREDS; p++)
                    {
                        modelIndexes.Add(redsBIN[resRef[y].entryIndexREDS] + p);
                    }
                }
            }
            content.nodeModelIDs.Add(modelIndexes);
            content.nodeTransforms.Add(GetTransform(ref thisNode));
            content.half_dimensions = GetHalfDimensions(ref thisNode);
            content.nodeNames.Add(NodeDB.GetNodeTypeName(thisNode.nodeType, ref commandsPAK) + ": " + NodeDB.GetFriendlyName(thisNode.nodeID));
        }
        return(content);
    }
コード例 #2
0
    private Vector3 GetHalfDimensions(ref CathodeNodeEntity node)
    {
        Vector3 toReturn = new Vector3(0, 0, 0);

        foreach (CathodeParameterReference paramRef in node.nodeParameterReferences)
        {
            CathodeParameter param = commandsPAK.GetParameter(paramRef.offset);
            if (param == null)
            {
                continue;
            }
            if (param.dataType != CathodeDataType.DIRECTION)
            {
                continue;
            }
            CathodeVector3 transform = (CathodeVector3)param;
            toReturn = transform.value;
            break;
        }
        return(toReturn);
    }
コード例 #3
0
    private PosAndRot GetTransform(ref CathodeNodeEntity node)
    {
        PosAndRot toReturn = new PosAndRot();

        foreach (CathodeParameterReference paramRef in node.nodeParameterReferences)
        {
            CathodeParameter param = commandsPAK.GetParameter(paramRef.offset);
            if (param == null)
            {
                continue;
            }
            if (param.dataType != CathodeDataType.POSITION)
            {
                continue;
            }
            CathodeTransform transform = (CathodeTransform)param;
            toReturn.position = transform.position;
            toReturn.rotation = Quaternion.Euler(transform.rotation);
            break;
        }
        return(toReturn);
    }
コード例 #4
0
    private IEnumerator RecursiveLoad(CathodeFlowgraph flowgraph, GameObject parentTransform, System.Action <int, GameObject> loadModelCallback)
    {
        for (int i = 0; i < flowgraph.nodes.Count; i++)
        {
            CathodeNodeEntity node     = flowgraph.nodes[i];
            CathodeFlowgraph  nextCall = commandsPAK.GetFlowgraph(node.nodeType);
            if (nextCall == null)
            {
                continue;
            }
            PosAndRot  trans           = GetTransform(ref node);
            GameObject nextFlowgraphGO = new GameObject(nextCall.name);
            nextFlowgraphGO.transform.parent        = parentTransform.transform;
            nextFlowgraphGO.transform.localPosition = trans.position;
            nextFlowgraphGO.transform.localRotation = trans.rotation;
            StartCoroutine(RecursiveLoad(nextCall, nextFlowgraphGO, loadModelCallback));
        }

        StartCoroutine(LoadModelReferenceNodes(flowgraph, parentTransform, loadModelCallback));
        StartCoroutine(LoadPlayerTriggerBoxNodes(flowgraph, parentTransform, loadModelCallback));

        yield break;
    }