Example #1
0
        void SwitchToRoom()
        {
            if (currentRoom.Music == null)
            {
                Game.Sound.StopMusic();
            }
            else
            {
                Game.Sound.PlayMusic(currentRoom.Music);
            }
            scene = new Cutscene(currentRoom.OpenScripts(), Game);
            if (currentRoom.Camera != null)
            {
                scene.SetCamera(currentRoom.Camera);
            }

            /*foreach (var npc in currentRoom.Npcs)
             * {
             *      var obj = scene.Objects[npc.StandingPlace];
             *      var child = new GameObject();
             *      child.RenderComponent = new CharacterRenderer(
             *              Game.ResourceManager.GetDfm(npc.HeadMesh),
             *              Game.ResourceManager.GetDfm(npc.BodyMesh),
             *              Game.ResourceManager.GetDfm(npc.LeftHandMesh),
             *              Game.ResourceManager.GetDfm(npc.RightHandMesh)
             *      );
             *      child.Register(scene.Renderer, scene.World.Physics);
             *      child.Transform = Matrix4.CreateTranslation(0, 3, 0);
             *      obj.Object.Children.Add(child);
             * }*/
            if (currentRoom.PlayerShipPlacement != null)
            {
                var shp = Game.GameData.GetShip(session.PlayerShip);
                var obj = new GameObject(shp.Drawable, Game.ResourceManager);
                obj.PhysicsComponent = null;
                var place = scene.Objects[currentRoom.PlayerShipPlacement];
                obj.Register(scene.Renderer, scene.World.Physics);
                obj.Transform = obj.GetHardpoint("HpMount").Transform.Inverted();
                place.Object.Children.Add(obj);
            }
        }
Example #2
0
        void SetRoomCameraAndShip()
        {
            if (currentRoom.Camera != null)
            {
                scene.SetCamera(currentRoom.Camera);
            }
            ThnObject shipMarker = scene.GetObject(currentRoom.PlayerShipPlacement);

            if (shipMarker != null)
            {
                if (playerShip.HardpointExists("HpMount"))
                {
                    Matrix4x4.Invert(playerShip.GetHardpoint("HpMount").Transform, out var tr);
                    playerShip.SetLocalTransform(tr);
                }
                else
                {
                    playerShip.SetLocalTransform(Matrix4x4.Identity);
                }
                shipMarker.Object.Children.Add(playerShip);
            }
        }