/// <summary> /// Return the result of getting the actor out of the dictionary /// and returns in via the reference of the PxActor. /// </summary> /// <param name="actorName"> The physics actor name. </param> /// <param name="theActor"> The physics actor reference. </param> public bool TryGetActor(string actorName, out PxActor theActor) { // Try to get the result of getting the actor by the given // actor name, and return the result, if true theActor will // be the retrieved physical actor return(PhysicalActors.TryGetValue(actorName, out theActor)); }
/// <summary> /// Add a PxActor to the PxActorCollection by its name. /// </summary> /// <param name="name"> The physics actor name. </param> /// <param name="actor"> The physics actor. </param> public void Add(string name, PxActor actor) { lock (PhysicalActors) { // If the physical actor's name is not in our dictionary // add the physics actor to the dictionary by name if (!PhysicalActors.ContainsKey(name)) { PhysicalActors[name] = actor; } } }
/// <summary> /// Removes and releases the physical actor associated within this /// PxActorCollection by the given name, and returns the result of /// remove and releasing the physics actor. /// </summary> /// <param name="name"> The name of the physics actor. </param> public bool RemoveAndRelease(string name) { bool ret = false; // First, lock the physical actors dictionary lock (PhysicalActors) { // If the physical actor is contained within our dictionary // then get the physics actor and dispose of it as well as // remove it from the dictionary by name if (PhysicalActors.ContainsKey(name)) { PxActor beingRemoved = PhysicalActors[name]; PhysicalActors.Remove(name); beingRemoved.Dispose(); ret = true; } } return(ret); }