示例#1
0
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var item = data.Item;

            this.CallServer(_ => _.ServerRemote_Cut(item));
            return(true);
        }
        protected override void ClientItemUseStart(ClientItemData data)
        {
            var item = data.Item;

            var playerCharacter = Client.Characters.CurrentPlayerCharacter;

            if (ItemFuelRefillSystem.Instance.SharedGetCurrentActionState(playerCharacter)
                != null)
            {
                return;
            }

            ClientTryRefill(item);
            if (ItemFuelRefillSystem.Instance.SharedGetCurrentActionState(playerCharacter)
                != null)
            {
                return;
            }

            var inputKey = ClientInputManager.GetKeyForAbstractButton(
                WrappedButton <GameButton> .GetWrappedButton(GameButton.HeadEquipmentLightToggle));

            var key = inputKey != InputKey.None
                          ? inputKey.ToString()
                          : "<" + TitleButtonNotSet + ">";

            NotificationSystem.ClientShowNotification(
                string.Format(NotificationPressKeyToActivate, key),
                icon: this.Icon);
        }
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var tilePosition = Client.Input.MousePointedTilePosition;
            var result       = SharedGetAvailablePlantAt(tilePosition, ClientCurrentCharacterHelper.Character);

            if (!result.IsSuccess)
            {
                NotificationSystem.ClientShowNotification(
                    result.ErrorTitle,
                    result.ErrorMessage,
                    NotificationColor.Bad,
                    this.Icon);
                return(false);
            }

            CallServerAsync();
            return(false); // don't play sound instantly

            async void CallServerAsync()
            {
                var isWatered = await this.CallServer(_ => _.ServerRemote_ApplyWatering(tilePosition, data.Item));

                if (isWatered)
                {
                    // play sound if success
                    this.SoundPresetItem.PlaySound(ItemSound.Use);
                }
            }
        }
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     NotificationSystem.ClientShowNotification(
         NotificationCannotUseDirectly_Title,
         NotificationCannotUseDirectly_Message,
         NotificationColor.Bad,
         this.Icon);
     return(false);
 }
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            if (isAwaitingResponse)
            {
                return(false);
            }

            this.ClientSendUseItemRequest(data);
            return(true);
        }
示例#6
0
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            if (!this.SharedIsRechargeNeeded(ClientCurrentCharacterHelper.Character))
            {
                return(false);
            }

            this.CallServer(_ => _.ServerRemote_ConsumeItem(data.Item));
            return(true);
        }
示例#7
0
        protected override void ClientItemUseStart(ClientItemData data)
        {
            if (ClientCurrentCharacterHelper.PrivateState.CurrentActionState
                    is FishingActionState fishingActionState)
            {
                fishingActionState.ClientOnItemUse();
                return;
            }

            FishingSystem.Instance.ClientTryStartAction();
        }
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var character = Client.Characters.CurrentPlayerCharacter;
            var stats     = PlayerCharacter.GetPublicState(character).CurrentStatsExtended;

            if (this.SharedCanUse(character, stats))
            {
                this.CallServer(_ => _.ServerRemote_Use(data.Item));
                return(true);
            }

            return(false);
        }
示例#9
0
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var item      = data.Item;
            var character = Client.Characters.CurrentPlayerCharacter;

            if (!this.SharedCanUse(character))
            {
                return(false);
            }

            this.ClientOnUse(character);

            this.CallServer(_ => _.ServerRemote_Use(item));
            return(true);
        }
示例#10
0
        protected override void ClientItemUseStart(ClientItemData data)
        {
            var item = data.Item;

            if (ItemFuelRefillSystem.Instance.SharedGetCurrentActionState(Client.Characters.CurrentPlayerCharacter)
                != null)
            {
                // no need for notification - after refilling it will turn on automatically
                return;
            }

            // toggle state
            var setIsActive = !data.PublicState.IsActive;

            this.ClientTrySetActiveState(item, setIsActive);
        }
        protected override void ClientItemUseStart(ClientItemData data)
        {
            // try to find well object
            var objectWell =
                Client.World.TileAtCurrentMousePosition.StaticObjects.FirstOrDefault(
                    _ => _.ProtoStaticWorldObject is ProtoObjectWell);

            if (objectWell != null ||
                data.PrivateState.WaterAmount == 0)
            {
                // try to refill
                WateringCanRefillSystem.Instance.ClientTryStartAction();
                return;
            }

            WateringSystem.Instance.ClientTryStartAction();
        }
        private async void ClientSendUseItemRequest(ClientItemData data)
        {
            isAwaitingResponse = true;

            if (Client.CurrentGame.PingGameSeconds >= 0.3)
            {
                // too big ping (>=300 ms) - show notification for immediate response
                NotificationSystem.ClientShowNotification(
                    "Decoding Data Log",
                    "...",
                    NotificationColor.Good,
                    this.Icon,
                    playSound: false);
            }

            try
            {
                var actualDataLogItem = await this.CallServer(_ => _.ServerRemote_ClientUseItem(data.Item));

                if (actualDataLogItem != null)
                {
                    NotificationSystem.ClientShowNotification(
                        "Decoding Data Log",
                        "Successfully decoded:"
                        + Environment.NewLine
                        + actualDataLogItem.ProtoItem.Name,
                        NotificationColor.Good,
                        actualDataLogItem.ProtoItem.Icon,
                        playSound: false);
                }
                else
                {
                    NotificationSystem.ClientShowNotification(
                        "Decoding Data Log",
                        "Problems with decoding the data log.",
                        NotificationColor.Bad,
                        this.Icon,
                        playSound: false);
                }
            }
            finally
            {
                isAwaitingResponse = false;
            }
        }
        protected override void ClientItemUseStart(ClientItemData data)
        {
            if (data.PrivateState.VehicleID == 0)
            {
                WindowVehicleRemoteControl.Open(data.Item);
            }
            else
            {
                var character = Api.Client.Characters.CurrentPlayerCharacter;
                if (!CharacterEnergySystem.SharedHasEnergyCharge(character, this.EngeryUse))
                {
                    CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                    return;
                }

                VehicleRemoteSystem.Instance.ClientTryStartAction();
            }
        }
示例#14
0
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var character = Client.Characters.CurrentPlayerCharacter;
            var item      = data.Item;
            var stats     = PlayerCharacter.GetPublicState(character).CurrentStatsExtended;

            if (!this.SharedCanEat(
                    new ItemEatData(item,
                                    character,
                                    stats,
                                    ItemFreshnessSystem.SharedGetFreshnessEnum(item))))
            {
                return(false);
            }

            this.CallServer(_ => _.ServerRemote_Eat(item));
            return(true);
        }
示例#15
0
        private async void ClientShowDialog(ClientItemData data)
        {
            var(cooldownDuration, cooldownRemainsSeconds)
                = await this.CallServer(_ => _.ServerRemote_GetCooldownRemainsSeconds());

            if (cooldownRemainsSeconds > 0)
            {
                // under active cooldown
                NotificationSystem.ClientShowNotification(
                    this.Name,
                    string.Format(Message_UsedRecently_Format,
                                  ClientTimeFormatHelper.FormatTimeDuration(
                                      TimeSpan.FromSeconds(
                                          Math.Max(1, cooldownRemainsSeconds)),
                                      trimRemainder: true)),
                    NotificationColor.Bad,
                    this.Icon);
            }
            else // if no active cooldown
            {
                var messageText = string.Format(Message_CannotBeUsedOften_Format,
                                                ClientTimeFormatHelper.FormatTimeDuration(
                                                    TimeSpan.FromSeconds(cooldownDuration),
                                                    trimRemainder: true));

                DialogWindow.ShowDialog(
                    string.Format(CoreStrings.Dialog_AreYouSureWantToUse_Format, this.Name),
                    messageText,
                    okAction: () =>
                {
                    if (base.ClientItemUseFinish(data))
                    {
                        this.SoundPresetItem.PlaySound(ItemSound.Use);
                    }
                },
                    cancelAction: () => { },
                    okText: this.ItemUseCaption,
                    cancelText: CoreStrings.Button_Cancel,
                    focusOnCancelButton: true);
            }
        }
示例#16
0
        protected override void ClientItemUseStart(ClientItemData data)
        {
            var item = data.Item;

            if (ItemFuelRefillSystem.Instance.SharedGetCurrentActionState(Client.Characters.CurrentPlayerCharacter)
                != null)
            {
                // no need for notification - after refilling it will turn on automatically
                //NotificationSystem.ClientShowNotification(
                //    "Cannot turn on",
                //    "Refilling...",
                //    color: NotificationColor.Bad,
                //    icon: this.Icon);
                return;
            }

            // toggle state
            var setIsActive = !data.PublicState.IsActive;

            this.ClientTrySetActiveState(item, setIsActive);
        }
        protected override bool ClientItemUseFinish(ClientItemData data)
        {
            var character             = ClientCurrentCharacterHelper.Character;
            var characterTilePosition = character.TilePosition;
            var mouseTilePosition     = Client.Input.MousePointedTilePosition;
            var dronesNumberToLaunch  = Api.Client.Input.IsKeyHeld(InputKey.Shift, evenIfHandled: true)
                                           ? this.MaxDronesToControl
                                           : 1;

            using var tempExceptDrones  = Api.Shared.GetTempList <IItem>();
            using var tempExceptTargets = Api.Shared.GetTempList <Vector2Ushort>();

            for (var index = 0; index < dronesNumberToLaunch; index++)
            {
                var showErrorNotification = index == 0;
                var itemDrone             = CharacterDroneControlSystem.ClientSelectNextDrone(tempExceptDrones.AsList());
                if (itemDrone is null)
                {
                    if (CharacterDroneControlSystem.SharedIsMaxDronesToControlNumberExceeded(
                            character,
                            clientShowErrorNotification: showErrorNotification))
                    {
                        break;
                    }

                    if (showErrorNotification)
                    {
                        CannotInteractMessageDisplay.ClientOnCannotInteract(
                            character,
                            CharacterDroneControlSystem.Notification_ErrorNoDrones_Title,
                            isOutOfRange: false);
                    }

                    break;
                }

                tempExceptDrones.Add(itemDrone);
                Vector2Ushort targetPosition;

                if (index == 0)
                {
                    targetPosition = mouseTilePosition;
                    var targetObject = CharacterDroneControlSystem
                                       .SharedGetCompatibleTarget(character,
                                                                  mouseTilePosition,
                                                                  out var hasIncompatibleTarget,
                                                                  out var isPveActionForbidden);
                    if (targetObject is null)
                    {
                        if (showErrorNotification)
                        {
                            if (isPveActionForbidden)
                            {
                                PveSystem.ClientShowNotificationActionForbidden();
                            }

                            CannotInteractMessageDisplay.ClientOnCannotInteract(
                                character,
                                hasIncompatibleTarget
                                    ? CharacterDroneControlSystem.Notification_CannotMineThat
                                    : CharacterDroneControlSystem.Notification_NothingToMineThere,
                                isOutOfRange: false);
                        }

                        return(false);
                    }

                    if (!WorldObjectClaimSystem.SharedIsAllowInteraction(character,
                                                                         targetObject,
                                                                         showClientNotification: showErrorNotification))
                    {
                        return(false);
                    }

                    if (CharacterDroneControlSystem.SharedIsTargetAlreadyScheduledForAnyActiveDrone(
                            character,
                            mouseTilePosition,
                            logError: false))
                    {
                        // already scheduled a drone mining there...try find another target of the same type
                        targetPosition = TryGetNextTargetPosition();
                        if (targetPosition == default)
                        {
                            // no further targets
                            CannotInteractMessageDisplay.ClientOnCannotInteract(
                                character,
                                CharacterDroneControlSystem.Notification_DroneAlreadySent,
                                isOutOfRange: false);
                            return(false);
                        }
                    }
                }
                else
                {
                    targetPosition = TryGetNextTargetPosition();
                    if (targetPosition == default)
                    {
                        // no further targets
                        break;
                    }
                }

                if (!CharacterDroneControlSystem.ClientTryStartDrone(itemDrone,
                                                                     targetPosition,
                                                                     showErrorNotification: showErrorNotification))
                {
                    break;
                }

                tempExceptTargets.Add(targetPosition);
            }

            // always return false as we don't want to play any device sounds
            return(false);

            Vector2Ushort TryGetNextTargetPosition()
            {
                var targetObjectProto = CharacterDroneControlSystem
                                        .SharedGetCompatibleTarget(character,
                                                                   mouseTilePosition,
                                                                   out _,
                                                                   out _)?
                                        .ProtoWorldObject;

                if (targetObjectProto is null)
                {
                    return(default);
示例#18
0
 /// <summary>
 /// Client use item start method. Called for current selected item in hotbar when Client press the left mouse button.
 /// </summary>
 protected virtual void ClientItemUseStart(ClientItemData data)
 {
 }
示例#19
0
 /// <summary>
 /// Client use item finish method. Called for current selected item in hotbar when Client release the left mouse button.
 /// </summary>
 protected virtual bool ClientItemUseFinish(ClientItemData data)
 {
     return(false);
 }
示例#20
0
 protected override void ClientItemUseStart(ClientItemData data)
 {
     DeconstructionSystem.ClientTryStartAction();
 }
示例#21
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     // never play light "use" sound - it's played when the light switched
     return(false);
 }
示例#22
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     ConstructionSystem.ClientTryAbortAction();
     // never play "use" sound
     return(false);
 }
 protected override void ClientItemUseStart(ClientItemData data)
 {
 }
示例#24
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     this.ClientUseAsync(data.Item);
     return(true);
 }
示例#25
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     this.ClientShowDialog(data);
     return(false);
 }
示例#26
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     WindowDataLog.Open(data.Item);
     return true;
 }
示例#27
0
 protected override void ClientItemUseStart(ClientItemData data)
 {
     // try to refill
     BottleRefillSystem.Instance.ClientTryStartAction();
 }
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     WateringSystem.Instance.ClientTryAbortAction();
     // never play watering can "use" sound
     return(false);
 }
示例#29
0
 protected override void ClientItemUseStart(ClientItemData data)
 {
     ConstructionSystem.ClientTryStartAction(allowReplacingCurrentConstructionAction: true);
 }
示例#30
0
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     ItemExplosiveSystem.Instance.ClientTryAbortAction();
     return(false); // don't play the sound
 }