Exemplo n.º 1
0
 private static void MarkerAddedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     ShowNotification(droppedLootInfo);
 }
 private void MarkerRemovedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     this.RemoveMarker(droppedLootInfo);
 }
        private void RemoveMarker(DroppedLootInfo position)
        {
            if (!this.markers.TryGetValue(position, out var control))
            {
                return;
            }

            this.markers.Remove(position);
            this.worldMapController.RemoveControl(control);
        }
Exemplo n.º 4
0
 private static void MarkerRemovedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     if (Notifications.TryGetValue(droppedLootInfo, out var notificationControl))
     {
         notificationControl.Hide(quick: false);
     }
 }
Exemplo n.º 5
0
        private static string GetNotificationText(DroppedLootInfo mark)
        {
            var secondsRemains = mark.DestroyAtTime - Api.Client.CurrentGame.ServerFrameTimeApproximated;

            if (secondsRemains < 1)
            {
                secondsRemains = 1;
            }

            return(string.Format(NotificationItemsDropped_MessageFormat,
                                 ClientTimeFormatHelper.FormatTimeDuration(
                                     secondsRemains)));
        }
        private void AddMarker(DroppedLootInfo droppedLootInfo)
        {
            if (this.markers.ContainsKey(droppedLootInfo))
            {
                Api.Logger.Warning("Dropped items already has the map visualizer: " + droppedLootInfo);
                return;
            }

            var mapControl     = new WorldMapMarkDroppedItems();
            var canvasPosition = this.worldMapController.WorldToCanvasPosition(
                droppedLootInfo.Position.ToVector2D());

            Canvas.SetLeft(mapControl, canvasPosition.X);
            Canvas.SetTop(mapControl, canvasPosition.Y);
            Panel.SetZIndex(mapControl, 12);

            this.worldMapController.AddControl(mapControl);

            this.markers[droppedLootInfo] = mapControl;
        }
        private static void ShowNotification(DroppedLootInfo droppedLootInfo)
        {
            if (Notifications.TryGetValue(droppedLootInfo, out _))
            {
                // already has a notification
                return;
            }

            var icon = Api.GetProtoEntity <ObjectPlayerLootContainer>().DefaultTexture;

            var notification = NotificationSystem.ClientShowNotification(
                title: NotificationItemsDropped_Title,
                message: GetNotificationText(droppedLootInfo),
                color: NotificationColor.Bad,
                icon: icon,
                autoHide: false);

            UpdateNotification(droppedLootInfo, notification);
            Notifications[droppedLootInfo] = notification;
        }
Exemplo n.º 8
0
        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.Message = GetNotificationText(mark);

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