Esempio n. 1
0
        protected override void OnSystemAdd()
        {
            physicsSystem = (Bullet2PhysicsSystem)Services.GetService <IPhysicsSystem>();
            if (physicsSystem == null)
            {
                physicsSystem = new Bullet2PhysicsSystem(Services);
                Services.AddService <IPhysicsSystem>(physicsSystem);
                var gameSystems = Services.GetSafeServiceAs <IGameSystemCollection>();
                gameSystems.Add(physicsSystem);
            }

            ((IReferencable)physicsSystem).AddReference();

            debugShapeRendering = Services.GetService <PhysicsShapesRenderingService>();
            if (debugShapeRendering == null)
            {
                debugShapeRendering = new PhysicsShapesRenderingService(Services);
                var gameSystems = Services.GetSafeServiceAs <IGameSystemCollection>();
                gameSystems.Add(debugShapeRendering);
            }

            Simulation = physicsSystem.Create(this);

            sceneSystem = Services.GetSafeServiceAs <SceneSystem>();
        }
Esempio n. 2
0
        protected override void OnSystemAdd()
        {
            physicsSystem = (Bullet2PhysicsSystem)Services.GetService <IPhysicsSystem>();
            if (physicsSystem == null)
            {
                physicsSystem = new Bullet2PhysicsSystem(Services);
                Services.AddService <IPhysicsSystem>(physicsSystem);
                var gameSystems = Services.GetSafeServiceAs <IGameSystemCollection>();
                gameSystems.Add(physicsSystem);
            }

            ((IReferencable)physicsSystem).AddReference();

            // Check if PhysicsShapesRenderingService is created (and check if rendering is enabled with IGraphicsDeviceService)
            if (Services.GetService <Graphics.IGraphicsDeviceService>() != null && Services.GetService <PhysicsShapesRenderingService>() == null)
            {
                debugShapeRendering = new PhysicsShapesRenderingService(Services);
                var gameSystems = Services.GetSafeServiceAs <IGameSystemCollection>();
                gameSystems.Add(debugShapeRendering);
            }

            Simulation = physicsSystem.Create(this);

            sceneSystem = Services.GetSafeServiceAs <SceneSystem>();
        }
Esempio n. 3
0
        protected override void OnSystemAdd()
        {
            physicsSystem = (Bullet2PhysicsSystem)Services.GetServiceAs <IPhysicsSystem>();
            if (physicsSystem == null)
            {
                physicsSystem = new Bullet2PhysicsSystem(Services);
                var game = Services.GetServiceAs <IGame>();
                game?.GameSystems.Add(physicsSystem);
            }

            debugShapeRendering = Services.GetServiceAs <PhysicsShapesRenderingService>();
            if (debugShapeRendering == null)
            {
                debugShapeRendering = new PhysicsShapesRenderingService(Services);
                var game = Services.GetServiceAs <IGame>();
                game?.GameSystems.Add(debugShapeRendering);
            }

            Simulation = physicsSystem.Create(this);

            sceneSystem = Services.GetSafeServiceAs <SceneSystem>();
        }