Exemplo n.º 1
0
        private void ClientRemote_OnContainerOpened(IStaticWorldObject worldObject)
        {
            var privateState = GetPrivateState(worldObject);
            var itemsContainer = privateState.ItemsContainer;

            var soundClose = Client.UI.GetApplicationResource<SoundUI>("SoundWindowContainerClose");
            var menuWindow = WindowContainerExchange.Show(
                itemsContainer,
                soundClose: soundClose,
                isAutoClose: true);

            var character = Client.Characters.CurrentPlayerCharacter;
            InteractionCheckerSystem.SharedRegister(
                character,
                worldObject,
                finishAction: _ => menuWindow.CloseWindow());

            ClientInteractionUISystem.Register(
                worldObject,
                menuWindow,
                onMenuClosedByClient:
                () =>
                {
                    InteractionCheckerSystem.SharedUnregister(character, worldObject, isAbort: false);
                    if (!worldObject.IsDestroyed)
                    {
                        this.CallServer(_ => _.ServerRemote_OnClientInteractFinish(worldObject));
                    }
                });

            Logger.Important("Started object interaction with " + worldObject);

            ClientCurrentInteractionMenu.RegisterMenuWindow(menuWindow);
            ClientCurrentInteractionMenu.Open();
        }
Exemplo n.º 2
0
        protected override void ClientInteractStart(ClientObjectData data)
        {
            var worldObject = data.GameObject;
            var character   = Client.Characters.CurrentPlayerCharacter;

            var menuWindow = WindowCraftingStation.Open(this);

            ClientCurrentInteractionMenu.RegisterMenuWindow(menuWindow);

            InteractionCheckerSystem.SharedRegister(
                character,
                worldObject,
                finishAction: _ => menuWindow.CloseWindow());

            ClientInteractionUISystem.Register(
                worldObject,
                menuWindow,
                onMenuClosedByClient:
                () => InteractionCheckerSystem.SharedUnregister(
                    character,
                    worldObject,
                    isAbort: false));

            ClientCurrentInteractionMenu.Open();
        }
Exemplo n.º 3
0
        private void HotbarItemVechicleRemoteOverlayControl_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            WindowVehicleRemoteControl.Open(this.item);

            ClientInteractionUISystem.Register(
                Api.Client.Characters.CurrentPlayerCharacter,
                WindowVehicleRemoteControl.instance,
                onMenuClosedByClient:
                () =>
            {
                this.viewModel.UpdateIcon();
            });
        }
Exemplo n.º 4
0
        private async void ClientInteractStartAsync(IWorldObject worldObject)
        {
            if (this.isAwaitingServerInteraction)
            {
                return;
            }

            var character = Client.Characters.CurrentPlayerCharacter;

            if (InteractionCheckerSystem.SharedGetCurrentInteraction(character) == worldObject)
            {
                // already interacting with this object
                return;
            }

            this.isAwaitingServerInteraction = true;
            try
            {
                var requestId = ++lastRequestId;
                var isOpened  = await this.CallServer(_ => _.ServerRemote_OnClientInteractStart(worldObject));

                if (!isOpened ||
                    requestId != lastRequestId)
                {
                    return;
                }
            }
            finally
            {
                this.isAwaitingServerInteraction = false;
            }

            var objectWindow = SharedGetProto(worldObject).ClientOpenUI(worldObject);

            if (objectWindow is null)
            {
                Logger.Info("Cannot open menu for object interaction with " + worldObject);
                this.CallServer(_ => _.ServerRemote_OnClientInteractFinish(worldObject));
                return;
            }

            Api.SafeInvoke(() => ClientMenuCreated?.Invoke(worldObject, objectWindow));
            if (!(objectWindow is IMenu))
            {
                ClientCurrentInteractionMenu.RegisterMenuWindow(objectWindow);
            }
            else
            {
                ClientCurrentInteractionMenu.TryCloseCurrentMenu();
            }

            InteractionCheckerSystem.SharedRegister(
                character,
                worldObject,
                finishAction: _ => objectWindow.CloseWindow());

            ClientInteractionUISystem.Register(
                worldObject,
                objectWindow,
                onMenuClosedByClient:
                () =>
            {
                InteractionCheckerSystem.SharedUnregister(character, worldObject, isAbort: false);
                if (!worldObject.IsDestroyed)
                {
                    ++lastRequestId;
                    this.CallServer(_ => _.ServerRemote_OnClientInteractFinish(worldObject));
                }
            });

            Logger.Info("Started object interaction with " + worldObject);
            if (objectWindow is IMenu objectMenu)
            {
                if (!objectMenu.IsOpened)
                {
                    objectMenu.Toggle();
                }
            }
            else
            {
                ClientCurrentInteractionMenu.Open();
            }
        }
Exemplo n.º 5
0
 private void ClientRemote_FinishInteraction(IWorldObject worldObject)
 {
     ClientInteractionUISystem.OnServerForceFinishInteraction(worldObject);
 }
 private void ClientRemote_FinishInteraction(IWorldObject worldObject)
 {
     Logger.Info($"Server informed that the object interaction with {worldObject} is finished");
     ClientInteractionUISystem.OnServerForceFinishInteraction(worldObject);
 }
Exemplo n.º 7
0
        private async void ClientInteractStartAsync(IStaticWorldObject worldObject)
        {
            if (this.isAwaitingServerInteraction)
            {
                return;
            }

            var character = Client.Characters.CurrentPlayerCharacter;

            if (InteractionCheckerSystem.GetCurrentInteraction(character) == worldObject)
            {
                // already interacting with this object
                return;
            }

            this.isAwaitingServerInteraction = true;
            try
            {
                var requestId = ++lastRequestId;
                var isOpened  = await this.CallServer(_ => _.ServerRemote_OnClientInteractStart(worldObject));

                if (!isOpened ||
                    requestId != lastRequestId)
                {
                    return;
                }
            }
            finally
            {
                this.isAwaitingServerInteraction = false;
            }

            var menuWindow = SharedGetProto(worldObject).ClientOpenUI(worldObject);

            if (menuWindow == null)
            {
                Logger.Important("Cannot open menu for object interaction with " + worldObject);
                this.CallServer(_ => _.ServerRemote_OnClientInteractFinish(worldObject));
                return;
            }

            ClientCurrentInteractionMenu.RegisterMenuWindow(menuWindow);

            InteractionCheckerSystem.Register(
                character,
                worldObject,
                finishAction: _ => menuWindow.CloseWindow());

            ClientInteractionUISystem.Register(
                worldObject,
                menuWindow,
                onMenuClosedByClient:
                () =>
            {
                InteractionCheckerSystem.Unregister(character, worldObject, isAbort: false);
                if (!worldObject.IsDestroyed)
                {
                    ++lastRequestId;
                    this.CallServer(_ => _.ServerRemote_OnClientInteractFinish(worldObject));
                }
            });

            Logger.Important("Started object interaction with " + worldObject);
            ClientCurrentInteractionMenu.Open();
        }