Ejemplo n.º 1
0
        private static void ClientRefreshCurrentUnstuckRequestStatus()
        {
            // invoke self again a second later
            ClientTimersSystem.AddAction(delaySeconds: 1,
                                         ClientRefreshCurrentUnstuckRequestStatus);

            var characterPublicState = ClientCurrentCharacterHelper.PublicState;

            if (ClientCurrentUnstuckNotification != null)
            {
                if (ClientCurrentUnstuckNotification.IsHiding)
                {
                    ClientCurrentUnstuckNotification = null;
                }
                else if (ClientCurrentUnstuckNotification.Tag != characterPublicState)
                {
                    // outdated notification
                    ClientCurrentUnstuckNotification?.Hide(quick: false);
                    ClientCurrentUnstuckNotification = null;
                }
            }

            if (characterPublicState == null)
            {
                ClientCurrentUnstuckNotification?.Hide(quick: false);
                ClientCurrentUnstuckNotification = null;
                return;
            }

            var timeRemains = characterPublicState.UnstuckExecutionTime
                              - Client.CurrentGame.ServerFrameTimeApproximated;

            if (timeRemains <= 0)
            {
                // no active unstuck requests
                ClientCurrentUnstuckNotification?.Hide(quick: false);
                ClientCurrentUnstuckNotification = null;
                return;
            }

            // has active unstuck request, create or update the notification
            var message = string.Format(NotificationUnstuckRequested_MessageFormat,
                                        ClientTimeFormatHelper.FormatTimeDuration(timeRemains));

            if (ClientCurrentUnstuckNotification == null)
            {
                ClientCurrentUnstuckNotification = NotificationSystem.ClientShowNotification(
                    NotificationUnstuckRequested_Title,
                    message,
                    autoHide: false);
                ClientCurrentUnstuckNotification.Tag = characterPublicState;
            }
            else
            {
                ClientCurrentUnstuckNotification.SetMessage(message);
            }
        }
            private void RemoveRaidNotification()
            {
                this.raidNotification?.Hide(quick: true);
                this.raidNotification = null;

                if (this.markRaidControl != null)
                {
                    this.worldMapController.RemoveControl(this.markRaidControl);
                    this.markRaidControl = null;
                }
            }
            private void RefreshRaidedState()
            {
                var isRaidedNow = LandClaimSystem.SharedIsAreasGroupUnderRaid(this.areasGroup);

                if (this.isRaided == isRaidedNow)
                {
                    // no changes
                    return;
                }

                // remove outdated notifications (if exists)
                this.RemoveRaidNotification();

                this.isRaided = isRaidedNow;
                if (!this.isRaided)
                {
                    return;
                }

                // was not raided, is raided now
                var worldPosition = this.GetAreasGroupWorldPosition();

                // add raid mark control to map
                this.markRaidControl = new WorldMapMarkRaid();
                var canvasPosition = this.GetAreasGroupCanvasPosition(worldPosition);

                Canvas.SetLeft(this.markRaidControl, canvasPosition.X);
                Canvas.SetTop(this.markRaidControl, canvasPosition.Y);
                Panel.SetZIndex(this.markRaidControl, 11);
                this.worldMapController.AddControl(this.markRaidControl);

                // show notification message
                var localPosition = worldPosition.ToVector2Ushort()
                                    - Api.Client.World.WorldBounds.Offset;

                this.raidNotification = NotificationSystem.ClientShowNotification(
                    NotificationBaseUnderAttack_Title,
                    string.Format(NotificationBaseUnderAttack_MessageFormat,
                                  localPosition.X,
                                  localPosition.Y),
                    NotificationColor.Bad,
                    autoHide: false,
                    icon: Api.GetProtoEntity <ObjectCharredGround>().Icon);

                // start refresh timer
                ClientTimersSystem.AddAction(delaySeconds: 1,
                                             this.RaidRefreshTimerCallback);
            }
Ejemplo n.º 4
0
        private static void Refresh()
        {
            var position   = ClientCurrentCharacterHelper.Character?.TilePosition ?? Vector2Ushort.Zero;
            var areasGroup = LandClaimSystem.ServerFindLandClaimAreasGroup(position, addGracePadding: false)
                             ?? LandClaimSystem.ServerFindLandClaimAreasGroup(position, addGracePadding: true);

            var lastRaidTime = areasGroup != null
                                   ? LandClaimAreasGroup.GetPublicState(areasGroup).LastRaidTime ?? double.MinValue
                                   : double.MinValue;

            var time = Api.Client.CurrentGame.ServerFrameTimeRounded;
            var timeSinceRaidStart   = time - lastRaidTime;
            var timeRemainsToRaidEnd = LandClaimSystemConstants.SharedRaidBlockDurationSeconds - timeSinceRaidStart;

            timeRemainsToRaidEnd = Math.Max(timeRemainsToRaidEnd, 0);

            if (timeRemainsToRaidEnd <= 0)
            {
                // no raid here - hide notification
                currentNotification?.Hide(quick: true);
                currentNotification = null;
                return;
            }

            // raid here, display/update notification
            var text = GetNotificationText(timeRemainsToRaidEnd);

            if (currentNotification != null &&
                !currentNotification.IsHiding)
            {
                currentNotification.SetMessage(text);
                return;
            }

            currentNotification = NotificationSystem.ClientShowNotification(
                title: Notification_Title,
                message: text,
                autoHide: false,
                // TODO: add custom icon here, currently we're using a placeholder icon
                icon: Api.GetProtoEntity <ItemBombModern>().Icon);
        }
Ejemplo n.º 5
0
        private void ClientRemote_ShutdownNotification(
            string shutdownReasonMessage,
            double shutdownServerTime)
        {
            this.notification?.Hide(quick: true); // hide already existing notification

            this.shutdownReasonMessage = shutdownReasonMessage;
            this.shutdownServerTime    = shutdownServerTime;

            Logger.Important(string.Format(NotificationShutdown_MessageFormat,
                                           ClientTimeFormatHelper.FormatTimeDuration(this.GetSecondsRemains()),
                                           shutdownReasonMessage));

            this.notification = NotificationSystem.ClientShowNotification(
                title: NotificationShutdown_Title,
                message: this.GetShutdownMessage(),
                color: NotificationColor.Bad,
                autoHide: false);

            this.UpdateMessage();
        }
        private static void UpdateNotification(DroppedLootInfo mark, HUDNotificationControl notification)
        {
            if (notification.IsHiding)
            {
                return;
            }

            var timeRemains = mark.DestroyAtTime - Api.Client.CurrentGame.ServerFrameTimeApproximated;

            if (timeRemains <= 0)
            {
                notification.Hide(quick: false);
                return;
            }

            notification.SetMessage(GetNotificationText(mark));

            // schedule recursive update in a second
            ClientTimersSystem.AddAction(
                delaySeconds: 1,
                () => UpdateNotification(mark, notification));
        }