Exemple #1
0
        private static void InitGameplayMode(ICharacter currentCharacter)
        {
            ClientCurrentCharacterContainersHelper.Init(currentCharacter);
            ClientItemsManager.Init(currentCharacter);
            ClientDroppedItemsNotifier.Init(currentCharacter);

            var layoutRootChildren = Api.Client.UI.LayoutRootChildren;

            layoutRootChildren.Add(new HUDLayoutControl());
            layoutRootChildren.Add(new ChatPanel());

            ClientContainersExchangeManager.Reset();

            CraftingQueueControl.Instance?.Refresh();

            var input = Api.Client.Scene.CreateSceneObject("Input components");

            input.AddComponent <ClientComponentHotbarHelper>();
            input.AddComponent <ClientComponentWindowStructureSelectListToogle>();
            input.AddComponent <ClientComponentObjectInteractionHelper>();

            // ReSharper disable once CanExtractXamlLocalizableStringCSharp
            gameplayInputContext =
                ClientInputContext
                .Start("Menu toggles")
                .HandleButtonDown(
                    GameButton.InventoryMenu,
                    () =>
            {
                if (Menu.IsOpenedAny())
                {
                    // shortcut to close currently opened menus
                    // (basically, it's alternative to pressing ESC in such case)
                    Menu.CloseAll();
                    return;
                }

                Menu.Toggle <WindowInventory>();
            })
                .HandleButtonDown(GameButton.CraftingMenu, Menu.Toggle <WindowHandCrafting>)
                .HandleButtonDown(GameButton.MapMenu, Menu.Toggle <WindowWorldMap>)
                .HandleButtonDown(GameButton.SkillsMenu, Menu.Toggle <WindowSkills>)
                .HandleButtonDown(GameButton.TechnologiesMenu, Menu.Toggle <WindowTechnologies>)
                .HandleButtonDown(GameButton.SocialMenu, Menu.Toggle <WindowSocial>)
                .HandleButtonDown(GameButton.PoliticsMenu, Menu.Toggle <WindowPolitics>)
                .HandleButtonDown(GameButton.QuestsMenu, Menu.Toggle <WindowQuests>)
                .HandleButtonDown(GameButton.CompletionistMenu, Menu.Toggle <WindowCompletionist>)
                .HandleButtonDown(GameButton.OpenChat,
                                  () =>
            {
                if (WindowsManager.OpenedWindowsCount == 0)
                {
                    ChatPanel.Instance.Open();
                }
            });

            sceneObjectInputComponents = input;

            ClientComponentWorldCameraZoomManager.Instance.ZoomBounds = ZoomBoundsGameplayMode;
        }
Exemple #2
0
        private static void Reset()
        {
            if (!isInitialized)
            {
                return;
            }

            isInitialized = false;

            Menu.CloseAll();

            ClientComponentObjectPlacementHelper.DestroyInstanceIfExist();

            if (HUDLayoutControl.Instance is not null)
            {
                Api.Client.UI.LayoutRootChildren.Remove(HUDLayoutControl.Instance);
            }

            if (ChatPanel.Instance is not null)
            {
                Api.Client.UI.LayoutRootChildren.Remove(ChatPanel.Instance);
            }

            ResetCallback?.Invoke();

            ClientContainersExchangeManager.Reset();

            ClientCurrentCharacterContainersHelper.Reset();

            sceneObjectInputComponents?.Destroy();
            sceneObjectInputComponents = null;

            gameplayInputContext?.Stop();
            gameplayInputContext = null;
        }