Example #1
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);
        }