Beispiel #1
0
        /// <summary>
        /// Destroys the <see cref="IEngineGameObject"/> requested approximately time seconds after this call.
        /// Based on Unity3D's: http://docs.unity3d.com/ScriptReference/Object.Destroy.html overload
        /// <param name="time">Time in seconds to approximately delay the destruction of the object.</param>
        /// <param name="toDestroy"><see cref="IEngineGameObject"/> to destroy.</param>
        /// </summary>
        /// <returns>Indicates if destruction was sucessful.</returns>
        public bool DestroyDelayed(IEngineGameObject toDestroy, float time)
        {
            //Don't unregister it yet
            TActualGameObjectType result = lifetimeManagerRegister.TryLookup(toDestroy);

            if (result == null)
            {
                return(false);
            }

            //We can't really unregister this value. We have to force the underlying engine to handle the unregistering of the object when its destruction is done.
            DestroyObject(result, time, () => lifetimeManagerRegister.TryUnregister(toDestroy));

            return(true);
        }