internal override void createProduct(Engine.ObjectManagement.SimObjectBase instance, BulletScene scene) { RigidBody rbA = null; RigidBody rbB = null; SimObject other = instance.getOtherSimObject(RigidBodyASimObject); if (other != null) { rbA = other.getElement(RigidBodyAElement) as RigidBody; } other = instance.getOtherSimObject(RigidBodyBSimObject); if (other != null) { rbB = other.getElement(RigidBodyBElement) as RigidBody; } TypedConstraintElement element = createConstraint(rbA, rbB, instance, scene); if (element != null) { instance.addElement(element); } }
/// <summary> /// Destroy the SimObject named name. This will dispose the SimObject /// and it will no longer be part of the scene or usable. /// </summary> /// <param name="name">The name of the SimObject to destroy.</param> public void destroySimObject(String name) { SimObjectBase simObject = simObjects[name]; simObjects.Remove(name); simObject.Dispose(); simObject._unsetSimObjectManager(); }
/// <summary> /// Get the SimObject specified by name, will return false if the sim object is not found. /// </summary> /// <param name="name">The name of the SimObject</param> /// <param name="simObject">The out variable to put the result into.</param> /// <returns>True if the object is found, false if it is not.</returns> public bool tryGetSimObject(String name, out SimObjectBase simObject) { if (name == null) { simObject = null; return(false); } return(simObjects.TryGetValue(name, out simObject)); }
/// <summary> /// Returns a new SimObjectManager that contains all the SimObjects /// defined in this class. The SimObjects will be empty, but they will /// be registered for construction. /// </summary> /// <param name="subScene">The SimSubScene that will be used to build the objects in the returned manager.</param> /// <returns>A new SimObjectManager that contains empty SimObjects ready to be built into the given SimSubScene.</returns> public SimObjectManager createSimObjectManager(SimSubScene subScene) { SimObjectManager manager = new SimObjectManager(subScene); foreach (SimObjectDefinition instance in simObjects.Values) { SimObjectBase simObject = instance.register(subScene); manager.addSimObject(simObject); } return(manager); }
/// <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)); } }
/// <summary> /// Register this element with its factory so it can be built. /// </summary> /// <param name="subscene">The SimSubScene that will get the built product.</param> /// <param name="instance">The SimObject that will get the newly created element.</param> public abstract void registerScene(SimSubScene subscene, SimObjectBase instance);
public override void registerScene(Engine.ObjectManagement.SimSubScene subscene, Engine.ObjectManagement.SimObjectBase instance) { if (subscene.hasSimElementManagerType(typeof(BulletScene))) { BulletScene sceneManager = subscene.getSimElementManager <BulletScene>(); sceneManager.getBulletFactory().addTypedConstraint(this, instance); } else { Logging.Log.Default.sendMessage("Cannot add PhysActorDefinition {0} to SimSubScene {1} because it does not contain a BulletSceneManager.", Logging.LogLevel.Warning, BulletInterface.PluginName, Name, subscene.Name); } }
internal override void createStaticProduct(Engine.ObjectManagement.SimObjectBase instance, BulletScene scene) { }
/// <summary> /// Remove a SimObject. This does not destroy it and the caller takes /// ownership of the object for disposal. /// </summary> /// <param name="simObject">The SimObject to remove.</param> public void removeSimObject(SimObjectBase simObject) { simObjects.Remove(simObject.Name); simObject._unsetSimObjectManager(); }
/// <summary> /// Add a SimObject. It will be disposed when this manager is disposed. /// </summary> /// <param name="simObject">The SimObject to add.</param> public void addSimObject(SimObjectBase simObject) { simObjects.Add(simObject.Name, simObject); simObject._setSimObjectManager(this); }
/// <summary> /// Internal function to set the SimObject for this element. /// </summary> /// <param name="simObject">The SimObject to set.</param> internal void setSimObject(SimObjectBase simObject) { this.simObject = simObject; this.setEnabled(simObject != null && simObject.Enabled); }