Ejemplo n.º 1
0
        public PlayingState(Alex alex, GraphicsDevice graphics, WorldProvider worldProvider, INetworkProvider networkProvider) : base(alex)
        {
            NetworkProvider = networkProvider;

            World       = new World(alex, graphics, Options, new FirstPersonCamera(Options.VideoOptions.RenderDistance, Vector3.Zero, Vector3.Zero), networkProvider);
            SkyRenderer = new SkyBox(alex, graphics, World);

            WorldProvider = worldProvider;
            if (worldProvider is SPWorldProvider)
            {
                World.FreezeWorldTime = true;
            }

            var chat  = new ChatComponent(World);
            var title = new TitleComponent();

            WorldProvider = worldProvider;
            WorldProvider.Init(World, chat, out var info, out var chatProvider);
            World.WorldInfo              = info;
            chat.ChatProvider            = chatProvider;
            WorldProvider.TitleComponent = title;

            _playingHud = new PlayingHud(Alex, World.Player, chat, title);
            _debugInfo  = new GuiDebugInfo();
            InitDebugInfo();
        }
Ejemplo n.º 2
0
        public PlayingState(Alex alex, GraphicsDevice graphics, WorldProvider worldProvider, NetworkProvider networkProvider) : base(alex)
        {
            NetworkProvider = networkProvider;

            World = new World(alex.Services, graphics, Options, networkProvider);
            World.Player.IsFirstPersonMode = true;

            WorldProvider = worldProvider;
            if (worldProvider is SPWorldProvider)
            {
                World.DoDaylightcycle = false;
                //World.Player.SetInventory(new BedrockInventory(46));
                if (ItemFactory.TryGetItem("minecraft:diamond_sword", out var sword))
                {
                    World.Player.Inventory.MainHand = sword;
                    World.Player.Inventory[World.Player.Inventory.SelectedSlot] = sword;
                }
            }

            var title = new TitleComponent();

            WorldProvider = worldProvider;
            WorldProvider.Init(World);

            WorldProvider.TitleComponent = title;

            _playingHud = new PlayingHud(Alex, World.Player, title);
            _playingHud.Chat.Network = networkProvider;

            WorldProvider.ScoreboardView = _playingHud.Scoreboard;
            WorldProvider.ChatRecipient  = _playingHud;
            //WorldProvider.ScoreboardView

            _debugInfo = new GuiDebugInfo();
            InitDebugInfo();

            MiniMap = new GuiMiniMap(World.ChunkManager)
            {
                Anchor = Alignment.TopRight
            };

            var settings = GetService <IOptionsProvider>();

            settings.AlexOptions.VideoOptions.Minimap.Bind(OnMinimapSettingChange);
            RenderMinimap = settings.AlexOptions.VideoOptions.Minimap.Value;

            if (RenderMinimap)
            {
                _playingHud.AddChild(MiniMap);
            }

            _networkDebugHud = new NetworkDebugHud(NetworkProvider);
        }