Esempio n. 1
0
        public SimObjectBase createProp(String propName, Vector3 translation, Quaternion rotation)
        {
            if (subScene != null)
            {
                PropDefinition propDef;
                if (prototypes.TryGetValue(propName, out propDef))
                {
                    SimObjectDefinition definition          = propDef.SimObject;
                    Vector3             originalTranslation = definition.Translation;
                    Quaternion          originalRotation    = definition.Rotation;

                    definition.Name        = UniqueKeyGenerator.generateStringKey();
                    definition.Translation = translation;
                    definition.Rotation    = rotation;
                    SimObjectBase instance = definition.register(subScene);
                    medicalController.addSimObject(instance);
                    scene.buildScene();

                    definition.Translation = originalTranslation;
                    definition.Rotation    = originalRotation;
                    return(instance);
                }
                else
                {
                    Log.Error("Could not create prop {0}. The definition cannot be found.", propName);
                }
            }
            else
            {
                Log.Error("Could not create prop {0}. The subscene is null.", propName);
            }
            return(null);
        }
 /// <summary>
 /// Create a new SimObject and add it.
 /// </summary>
 /// <param name="definition">The definition to create.</param>
 /// <returns>A SimObject if one was created. Not returning one does not indicate an error it just means the sim object hasnt been created yet.</returns>
 public SimObject createSimObject(SimObjectDefinition definition)
 {
     simObjectManagerDefiniton.addSimObject(definition);
     if (subScene != null)
     {
         SimObjectBase instance = definition.register(subScene);
         simObjectManager.addSimObject(instance);
         controller.SceneController.createSimObjects();
         return(instance);
     }
     return(null);
 }
Esempio n. 3
0
 /// <summary>
 /// Create and add a SimObject to this manager. This is used to create
 /// objects after the build process has run during scene execution.
 /// </summary>
 /// <param name="definition">The definition of the object to create.</param>
 public SimObjectBase createLiveSimObject(SimObjectDefinition definition, SceneBuildOptions options = SceneBuildOptions.None)
 {
     if (!simObjects.ContainsKey(definition.Name))
     {
         SimObjectBase simObj = definition.register(subScene);
         addSimObject(simObj);
         subScene.buildScene(options);
         return(simObj);
     }
     else
     {
         throw new SimObjectException(String.Format("Attempted to create a SimObject {0} that already exists in sub scene {1}.", definition.Name, subScene.Name));
     }
 }