コード例 #1
0
        public static CathodeParameter ParameterDefinitionToParameter(ParameterDefinition def)
        {
            CathodeParameter this_param = null;

            switch (def.datatype.ToUpper())
            {
            case "POSITION":
                this_param = new CathodeTransform();
                break;

            case "FLOAT":
                this_param = new CathodeFloat();
                break;

            case "FILEPATH":
            case "STRING":
                this_param = new CathodeString();
                break;

            case "SPLINEDATA":
                this_param = new CathodeSpline();
                break;

            case "BOOL":
                this_param = new CathodeBool();
                break;

            case "DIRECTION":
                this_param = new CathodeVector3();
                break;

            case "INT":
                this_param = new CathodeInteger();
                break;

                /*
                 * case "ENUM":
                 * thisParam = new CathodeEnum();
                 * ((CathodeEnum)thisParam).enumID = new cGUID("4C-B9-82-48"); //ALERTNESS_STATE is the first alphabetically
                 * break;
                 * case CathodeDataType.SHORT_GUID:
                 * thisParam = new CathodeResource();
                 * ((CathodeResource)thisParam).resourceID = new cGUID("00-00-00-00");
                 * break;
                 */
            }
            return(this_param);
        }
コード例 #2
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);
    }
コード例 #3
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);
    }
コード例 #4
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);
    }
コード例 #5
0
        private void AutoSelectDataType()
        {
            param_datatype.Enabled = true;
            switch (node.variant)
            {
            case EntityVariant.FUNCTION:
                if (!loadedParamsFromDB)
                {
                    return;
                }
                CathodeEntityDatabase.ParameterDefinition def = CathodeEntityDatabase.GetParameterFromEntity(((FunctionEntity)node).function, param_name.Text);
                if (def.name == null)
                {
                    return;
                }
                if (def.usage == CathodeEntityDatabase.ParameterUsage.TARGET)
                {
                    //"TARGET" usage type does not have a datatype since it is not data, it's an event trigger.
                    //The FLOAT datatype is a placeholder for this.
                    param_datatype.Text = "FLOAT";
                }
                else
                {
                    CathodeParameter param = CathodeEntityDatabase.ParameterDefinitionToParameter(def);
                    if (param == null)
                    {
                        return;
                    }
                    param_datatype.Text = param.dataType.ToString();
                }
                param_datatype.Enabled = false;
                break;

            default:
                return;
            }
        }
コード例 #6
0
        /* Load a entity into the UI */
        private void LoadEntity(CathodeEntity edit_node)
        {
            if (edit_node == null)
            {
                return;
            }

            ClearUI(false, false, true);
            CurrentInstance.selectedEntity = edit_node;
            Cursor.Current = Cursors.WaitCursor;

            //populate info labels
            selected_node_id.Text   = edit_node.nodeID.ToString();
            selected_node_type.Text = edit_node.variant.ToString();
            string nodetypedesc = "";

            switch (edit_node.variant)
            {
            case EntityVariant.FUNCTION:
                nodetypedesc = NodeDBEx.GetParameterName(((FunctionEntity)edit_node).function);
                node_to_flowgraph_jump.Visible = (CurrentInstance.commandsPAK.GetFlowgraph(((FunctionEntity)edit_node).function) != null);
                selected_node_name.Text        = NodeDBEx.GetEntityName(edit_node.nodeID);
#if DEBUG //TODO: PULL THIS INTO STABLE
                editCAGEAnimationKeyframes.Visible = nodetypedesc == "CAGEAnimation";
#endif
                break;

            case EntityVariant.DATATYPE:
                nodetypedesc            = "DataType " + ((DatatypeEntity)edit_node).type.ToString();
                selected_node_name.Text = NodeDBEx.GetParameterName(((DatatypeEntity)edit_node).parameter);
                break;

            case EntityVariant.PROXY:
            case EntityVariant.OVERRIDE:
                node_to_flowgraph_jump.Visible = true;
                selected_node_name.Text        = NodeDBEx.GetEntityName(edit_node.nodeID);
                break;

            default:
                selected_node_name.Text = NodeDBEx.GetEntityName(edit_node.nodeID);
                break;
            }
            selected_node_type_description.Text = nodetypedesc;

            //show resource editor button if this node has a resource reference
            cGUID resourceParamID = Utilities.GenerateGUID("resource");
            CathodeLoadedParameter resourceParam = CurrentInstance.selectedEntity.parameters.FirstOrDefault(o => o.paramID == resourceParamID);
#if DEBUG //TODO: PULL THIS INTO STABLE
            editNodeResources.Visible = ((resourceParam != null) || CurrentInstance.selectedEntity.resources.Count != 0);
#endif

            //populate parameter inputs
            int current_ui_offset = 7;
            for (int i = 0; i < edit_node.parameters.Count; i++)
            {
                if (edit_node.parameters[i].paramID == resourceParamID)
                {
                    continue;                                                     //We use the resource editor button (above) for resource parameters
                }
                CathodeParameter this_param   = edit_node.parameters[i].content;
                UserControl      parameterGUI = null;

                switch (this_param.dataType)
                {
                case CathodeDataType.POSITION:
                    parameterGUI = new GUI_TransformDataType();
                    ((GUI_TransformDataType)parameterGUI).PopulateUI((CathodeTransform)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.INTEGER:
                    parameterGUI = new GUI_NumericDataType();
                    ((GUI_NumericDataType)parameterGUI).PopulateUI_Int((CathodeInteger)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.STRING:
                    parameterGUI = new GUI_StringDataType();
                    ((GUI_StringDataType)parameterGUI).PopulateUI((CathodeString)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.BOOL:
                    parameterGUI = new GUI_BoolDataType();
                    ((GUI_BoolDataType)parameterGUI).PopulateUI((CathodeBool)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.FLOAT:
                    parameterGUI = new GUI_NumericDataType();
                    ((GUI_NumericDataType)parameterGUI).PopulateUI_Float((CathodeFloat)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.DIRECTION:
                    parameterGUI = new GUI_VectorDataType();
                    ((GUI_VectorDataType)parameterGUI).PopulateUI((CathodeVector3)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.ENUM:
                    parameterGUI = new GUI_EnumDataType();
                    ((GUI_EnumDataType)parameterGUI).PopulateUI((CathodeEnum)this_param, edit_node.parameters[i].paramID);
                    break;

                case CathodeDataType.SHORT_GUID:
                    parameterGUI = new GUI_HexDataType();
                    ((GUI_HexDataType)parameterGUI).PopulateUI((CathodeResource)this_param, edit_node.parameters[i].paramID, CurrentInstance.selectedFlowgraph);
                    break;

                case CathodeDataType.SPLINE_DATA:
                    parameterGUI = new GUI_SplineDataType();
                    ((GUI_SplineDataType)parameterGUI).PopulateUI((CathodeSpline)this_param, edit_node.parameters[i].paramID);
                    break;
                }

                parameterGUI.Location = new Point(15, current_ui_offset);
                current_ui_offset    += parameterGUI.Height + 6;
                NodeParams.Controls.Add(parameterGUI);
            }

            RefreshNodeLinks();

            Cursor.Current = Cursors.Default;
        }
コード例 #7
0
    private void LoadFlowgraphAssets()
    {
        //First, make dummy prefabs of all flowgraphs
        GameObject rootGO = new GameObject();

        AssetDatabase.StartAssetEditing();
        for (int i = 0; i < levelData.CommandsPAK.AllFlowgraphs.Count; i++)
        {
            string fullFilePath  = GetFlowgraphAssetPath(levelData.CommandsPAK.AllFlowgraphs[i]);
            string fileDirectory = GetDirectory(fullFilePath);
            if (!Directory.Exists(fileDirectory))
            {
                Directory.CreateDirectory(fileDirectory);
            }
            if (!File.Exists(fullFilePath))
            {
                PrefabUtility.SaveAsPrefabAsset(rootGO, fullFilePath);
            }
        }
        AssetDatabase.StopAssetEditing();

        //Then, populate the prefabs for all flowgraphs
        AssetDatabase.StartAssetEditing();
        for (int i = 0; i < levelData.CommandsPAK.AllFlowgraphs.Count; i++)
        {
            GameObject flowgraphGO = new GameObject(levelData.CommandsPAK.AllFlowgraphs[i].name);
            string     nodeType    = "";
            for (int x = 0; x < levelData.CommandsPAK.AllFlowgraphs[i].nodes.Count; x++)
            {
                CathodeFlowgraph flowgraphRef = levelData.CommandsPAK.GetFlowgraph(levelData.CommandsPAK.AllFlowgraphs[i].nodes[x].nodeType);
                GameObject       nodeGO       = null;
                if (flowgraphRef != null)
                {
                    //This is a reference to another flowgraph
                    GameObject flowgraphAsset = Resources.Load <GameObject>(GetFlowgraphAssetPath(flowgraphRef, true));
                    nodeGO      = PrefabUtility.InstantiatePrefab(flowgraphAsset) as GameObject;
                    nodeGO.name = flowgraphRef.name;
                }
                else
                {
                    //This is a node
                    nodeGO   = new GameObject(CathodeLib.NodeDB.GetFriendlyName(levelData.CommandsPAK.AllFlowgraphs[i].nodes[x].nodeID));
                    nodeType = CathodeLib.NodeDB.GetNodeTypeName(levelData.CommandsPAK.AllFlowgraphs[i].nodes[x].nodeType, ref levelData.CommandsPAK);
                }
                nodeGO.transform.parent = flowgraphGO.transform;
                //TODO: this can all be optimised massively
                List <uint> resourceIDs = new List <uint>();
                foreach (CathodeParameterReference paramRef in levelData.CommandsPAK.AllFlowgraphs[i].nodes[x].nodeParameterReferences)
                {
                    CathodeParameter param = levelData.CommandsPAK.GetParameter(paramRef.offset);
                    if (param == null)
                    {
                        continue;
                    }
                    switch (param.dataType)
                    {
                    case CathodeDataType.POSITION:
                        CathodeTransform transform = (CathodeTransform)param;
                        nodeGO.transform.localPosition = transform.position;
                        nodeGO.transform.localRotation = Quaternion.Euler(transform.rotation);
                        break;

                    case CathodeDataType.SHORT_GUID:
                        resourceIDs.Add(((CathodeResource)param).resourceID);
                        break;
                    }
                }
                switch (nodeType)
                {
                case "PlayerTriggerBox":
                    //nodeGO.AddComponent<BoxCollider>().bounds = new Bounds(new Vector3(0, 0, 0), new Vector3(0, 0, 0));
                    break;

                case "PositionMarker":
                    //debug render marker
                    break;

                case "Sound":
                    //nodeGO.AddComponent<AudioSource>().clip = null;
                    break;

                case "PlayEnvironmentAnimation":
                    break;

                case "ParticleEmitterReference":
                    break;

                case "ModelReference":
                    for (int y = 0; y < resourceIDs.Count; y++)
                    {
                        List <CathodeResourceReference> resourceReference = levelData.CommandsPAK.AllFlowgraphs[i].GetResourceReferencesByID(resourceIDs[y]);
                        for (int z = 0; z < resourceReference.Count; z++)
                        {
                            if (resourceReference[z].entryType != CathodeResourceReferenceType.RENDERABLE_INSTANCE)
                            {
                                continue;                                                                                         //Ignoring collision maps, etc, for now
                            }
                            //TODO: This is kinda hacked for now while we're not saving with submeshes
                            for (int p = 0; p < resourceReference[z].entryCountREDS; p++)
                            {
                                int        thisIndex        = levelData.RenderableREDS.Entries[resourceReference[z].entryIndexREDS].ModelIndex + p;
                                string     meshResourcePath = GetMeshAssetPath(thisIndex, true) + "_" + p;
                                GameObject newSubmesh       = new GameObject(meshResourcePath);
                                newSubmesh.transform.parent        = nodeGO.transform;
                                newSubmesh.transform.localScale    = new Vector3(1, 1, 1) * levelData.ModelsBIN.Models[thisIndex].ScaleFactor;
                                newSubmesh.transform.localPosition = Vector3.zero;
                                newSubmesh.transform.localRotation = Quaternion.identity;
                                newSubmesh.AddComponent <MeshFilter>().sharedMesh       = Resources.Load <Mesh>(GetMeshAssetPath(thisIndex, true) + "_" + p);
                                newSubmesh.AddComponent <MeshRenderer>().sharedMaterial = Resources.Load <Material>("DUMMY");   //TODO: replace
                            }
                        }
                    }
                    break;
                }
            }
            PrefabUtility.SaveAsPrefabAsset(flowgraphGO, GetFlowgraphAssetPath(levelData.CommandsPAK.AllFlowgraphs[i]));
            Destroy(flowgraphGO);
        }
        AssetDatabase.StopAssetEditing();
        Destroy(rootGO);
    }
コード例 #8
0
        private void createEntity(object sender, EventArgs e)
        {
            cGUID thisID = Utilities.GenerateGUID(DateTime.Now.ToString("G"));

            if (createDatatypeEntity.Checked)
            {
                //Make the DatatypeEntity
                DatatypeEntity newEntity = new DatatypeEntity(thisID);
                newEntity.type      = (CathodeDataType)entityVariant.SelectedIndex;
                newEntity.parameter = Utilities.GenerateGUID(textBox1.Text);

                //Make the parameter to give this DatatypeEntity a value (the only time you WOULDN'T want this is if the val is coming from a linked entity)
                CathodeParameter thisParam = null;
                switch (newEntity.type)
                {
                case CathodeDataType.POSITION:
                    thisParam = new CathodeTransform();
                    break;

                case CathodeDataType.FLOAT:
                    thisParam = new CathodeFloat();
                    break;

                case CathodeDataType.FILEPATH:
                case CathodeDataType.STRING:
                    thisParam = new CathodeString();
                    break;

                case CathodeDataType.SPLINE_DATA:
                    thisParam = new CathodeSpline();
                    break;

                case CathodeDataType.ENUM:
                    thisParam = new CathodeEnum();
                    ((CathodeEnum)thisParam).enumID = new cGUID("4C-B9-82-48");     //ALERTNESS_STATE is the first alphabetically
                    break;

                case CathodeDataType.SHORT_GUID:
                    thisParam = new CathodeResource();
                    ((CathodeResource)thisParam).resourceID = new cGUID("00-00-00-00");
                    break;

                case CathodeDataType.BOOL:
                    thisParam = new CathodeBool();
                    break;

                case CathodeDataType.DIRECTION:
                    thisParam = new CathodeVector3();
                    break;

                case CathodeDataType.INTEGER:
                    thisParam = new CathodeInteger();
                    break;
                }
                newEntity.parameters.Add(new CathodeLoadedParameter(newEntity.parameter, thisParam));

                //Add to flowgraph & save name
                flow.datatypes.Add(newEntity);
                if (NodeDB.GetCathodeName(newEntity.parameter) == newEntity.parameter.ToString())
                {
                    NodeDBEx.AddNewParameterName(newEntity.parameter, textBox1.Text);
                }
                NewEntity = newEntity;
            }
            else if (createFunctionEntity.Checked)
            {
                //Create FunctionEntity
                FunctionEntity newEntity = new FunctionEntity(thisID);
                switch (entityVariant.Text)
                {
                //TODO: find a nicer way of auto selecting this (E.G. can we reflect to class names?)
                case "CAGEAnimation":
                    newEntity = new CAGEAnimation(thisID);
                    break;

                case "TriggerSequence":
                    newEntity = new TriggerSequence(thisID);
                    break;
                }
                newEntity.function = CathodeEntityDatabase.GetEntityAtIndex(entityVariant.SelectedIndex).guid;
                //TODO: auto populate params here

                //Add to flowgraph & save name
                flow.functions.Add(newEntity);
                NodeDBEx.AddNewNodeName(thisID, textBox1.Text);
                NewEntity = newEntity;
            }
            else if (createFlowgraphEntity.Checked)
            {
                //Create FunctionEntity
                FunctionEntity   newEntity         = new FunctionEntity(thisID);
                CathodeFlowgraph selectedFlowgraph = availableFlows.FirstOrDefault(o => o.name == entityVariant.Text);
                if (selectedFlowgraph == null)
                {
                    MessageBox.Show("Failed to look up flowgraph!\nPlease report this issue on GitHub.\n\n" + entityVariant.Text, "Could not find flowgraph!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                newEntity.function = selectedFlowgraph.nodeID;

                //Add to flowgraph & save name
                flow.functions.Add(newEntity);
                NodeDBEx.AddNewNodeName(thisID, textBox1.Text);
                NewEntity = newEntity;
            }

            this.Close();
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (param_name.Text == "")
            {
                return;
            }
            cGUID thisParamID = Utilities.GenerateGUID(param_name.Text);

            foreach (CathodeLoadedParameter param in node.parameters)
            {
                if (param.paramID == thisParamID)
                {
                    MessageBox.Show("This parameter already exists on the entity!");
                    return;
                }
            }

            CathodeParameter thisParam = null;

            switch ((CathodeDataType)param_datatype.SelectedIndex)
            {
            case CathodeDataType.POSITION:
                thisParam = new CathodeTransform();
                break;

            case CathodeDataType.FLOAT:
                thisParam = new CathodeFloat();
                break;

            case CathodeDataType.FILEPATH:
            case CathodeDataType.STRING:
                thisParam = new CathodeString();
                break;

            case CathodeDataType.SPLINE_DATA:
                thisParam = new CathodeSpline();
                break;

            case CathodeDataType.ENUM:
                thisParam = new CathodeEnum();
                ((CathodeEnum)thisParam).enumID = new cGUID("4C-B9-82-48");     //ALERTNESS_STATE is the first alphabetically
                break;

            case CathodeDataType.SHORT_GUID:
                thisParam = new CathodeResource();
                ((CathodeResource)thisParam).resourceID = new cGUID("00-00-00-00");
                break;

            case CathodeDataType.BOOL:
                thisParam = new CathodeBool();
                break;

            case CathodeDataType.DIRECTION:
                thisParam = new CathodeVector3();
                break;

            case CathodeDataType.INTEGER:
                thisParam = new CathodeInteger();
                break;
            }
            node.parameters.Add(new CathodeLoadedParameter(thisParamID, thisParam));

            //If this parameter doesn't come up in the CATHODE string table, add it to our own
            if (NodeDB.GetCathodeName(thisParamID) == thisParamID.ToString())
            {
                NodeDBEx.AddNewParameterName(thisParamID, param_name.Text);
            }

            this.Close();
        }