Example #1
0
        /// <summary>
        /// Called by the <see cref="LosgapSystem"/> when the module has been added (via <see cref="LosgapSystem.AddModule"/>). This
        /// method is guaranteed to only ever be called once during the lifetime of the application; and is a good place for the module
        /// to perform any initialization logic.
        /// </summary>
        void ILosgapModule.ModuleAdded()
        {
            lock (staticMutationLock) {
                PhysicsManager.EngineStart();
                physicsEngineIsStarted = true;
            }

            PhysicsManager.SetGravityOnAllBodies(Vector3.DOWN * 9.81f);

            LosgapSystem.SystemStarting += () => {
                lock (staticMutationLock) {
                    if (!physicsEngineIsStarted)
                    {
                        PhysicsManager.EngineStart();
                        physicsEngineIsStarted = true;
                    }
                }
            };

            LosgapSystem.SystemExited += () => {
                DeleteAllEntities();
                if (physicsEngineIsStarted)
                {
                    PhysicsManager.EngineStop();
                    physicsEngineIsStarted = false;
                }
            };
        }