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(); }
public static GameObject Instantiate(ENTITY e) { GameObject entityObject; switch (e.Classname) { case "action_animate": { entityObject = AnimateAction.Instantiate(e); break; } case "action_move": { entityObject = MoveAction.Instantiate(e); break; } case "action_rotate": { entityObject = RotateAction.Instantiate(e); break; } case "action_sequence": { entityObject = ActionSequence.Instantiate(e); break; } case "action_sound": { entityObject = SoundAction.Instantiate(e); break; } case "action_wait": { entityObject = WaitAction.Instantiate(e); break; } case "audio_source": { entityObject = AudioSourceObject.Instantiate(e); break; } case "dream_environment": { entityObject = DreamEnvironment.Instantiate(e); break; } case "!map": { entityObject = MapObject.Instantiate(e); break; } case "!model": { entityObject = ModelObject.Instantiate(e); break; } case "music_controller": { entityObject = MusicController.Instantiate(e); break; } case "player_spawn": { entityObject = PlayerSpawn.Instantiate(e); break; } case "target": { entityObject = Target.Instantiate(e); break; } case "trigger_link": { entityObject = TriggerLink.Instantiate(e); break; } case "trigger_sequence": { entityObject = TriggerSequence.Instantiate(e); break; } case "trigger_sound": { entityObject = TriggerSound.Instantiate(e); break; } case "trigger_teleport": { entityObject = TriggerTeleport.Instantiate(e); break; } default: { Debug.LogWarning("Could not instantiate entity with classname " + e.Classname); entityObject = new GameObject(e.Classname); break; } } return(entityObject); }