Example #1
0
 private static void LandClaimAreasElementRemoved(
     NetworkSyncList <ILogicObject> source,
     int index,
     ILogicObject value)
 {
     RemoveArea(value);
 }
        private void QuestsListElementInserted(
            NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source,
            int index,
            PlayerCharacterQuests.CharacterQuestEntry value)
        {
            var vm = new ViewModelQuestEntry(value, this.ViewModelQuestEntryOnCompletedStateChanged);

            if (vm.QuestEntry.IsCompleted)
            {
                this.CompletedQuests.Insert(0, vm);
                if (this.CompletedQuests.Count == 1)
                {
                    // display completed quests
                    this.NotifyPropertyChanged(nameof(this.CompletedQuests));
                }

                this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount));
                return;
            }

            // add new active quest
            // make it expanded by default
            vm.SetIsCollapsed(false, removeNewFlag: false);
            this.ActiveQuests.Add(vm);
            if (this.ActiveQuests.Count == 1)
            {
                // remove no active quests label
                this.NotifyPropertyChanged(nameof(this.ActiveQuests));
            }

            Api.Client.Audio.PlayOneShot(new SoundResource("UI/Quests/QuestUnlocked.ogg"));
            this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount));
        }
Example #3
0
 ToObservableCollectionWithWrapper <TKey, TViewModel>(
     this NetworkSyncList <TKey> netList,
     Func <TKey, TViewModel> func)
     where TViewModel : IDisposable
 {
     return(new(netList, func));
 }
 private void MarkerRemovedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     this.RemoveMarker(droppedLootInfo);
 }
 private void QuestsListElementInserted(
     NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source,
     int index,
     PlayerCharacterQuests.CharacterQuestEntry value)
 {
     this.Register(value);
 }
Example #6
0
 private static void MarkerRemovedHandler(
     NetworkSyncList <Vector2Ushort> source,
     int index,
     Vector2Ushort removedValue)
 {
     HideLastNotification();
 }
Example #7
0
        private static void LogEntryAdded(
            NetworkSyncList <BaseFactionEventLogEntry> source,
            int index,
            BaseFactionEventLogEntry entry)
        {
            if (entry.ClientShowNotification)
            {
                var message = entry.ClientText;
                if (!string.IsNullOrEmpty(entry.ByMemberName))
                {
                    message += "[br]"
                               + string.Format(BaseFactionEventLogEntry.Text_Name_Format, entry.ByMemberName);
                }

                var notification = NotificationSystem.ClientShowNotification(CoreStrings.Faction_Title,
                                                                             message,
                                                                             entry.ClientNotificationColor,
                                                                             icon: entry.IconResource);

                if (entry.ClientIsLongNotification)
                {
                    notification.HideAfterDelay(60);
                }
            }

            entry.ClientOnReceived();
        }
 public void Init()
 {
     if (this.CurrentlyControlledDrones is null)
     {
         this.CurrentlyControlledDrones = new NetworkSyncList <IDynamicWorldObject>();
     }
 }
Example #9
0
 private void QueueElementInsertedHandler(
     NetworkSyncList <CraftingQueueItem> source,
     int index,
     CraftingQueueItem value)
 {
     this.AddControl(value);
 }
Example #10
0
        public ViewModelWorldObjectOwnersEditor(
            NetworkSyncList <string> ownersSyncList,
            Action <List <string> > callbackServerSetOwnersList,
            string title,
            string emptyListMessage = CoreStrings.ObjectOwnersList_Empty,
            bool canEditOwners      = true,
            Func <string, bool> ownersListFilter  = null,
            byte maxOwnersListLength              = byte.MaxValue,
            sbyte displayedOwnersNumberAdjustment = 0)
        {
            this.Title            = title;
            this.EmptyListMessage = emptyListMessage;
            this.CanEditOwners    = canEditOwners;

            this.ownersSyncList = ownersSyncList;
            this.callbackServerSetOwnersList = callbackServerSetOwnersList;
            this.ownersListFilter            = ownersListFilter;

            this.ownersSyncList.ClientAnyModification += this.OwnersSyncListModificationHandler;
            this.RefreshOwnersList();

            PartySystem.ClientCurrentPartyMemberAddedOrRemoved += this.CurrentPartyMemberAddedOrRemovedHandler;
            this.RefreshHasPartyMembers();

            this.maxOwnersListLength             = maxOwnersListLength;
            this.displayedOwnersNumberAdjustment = displayedOwnersNumberAdjustment;
        }
 private void ClientMarksListElementRemovedHandler(
     NetworkSyncList <WorldMapResourceMark> source,
     int index,
     WorldMapResourceMark removedValue)
 {
     ClientMarkRemoved?.Invoke(removedValue);
 }
 private void ClientMarksListElementInsertedHandler(
     NetworkSyncList <WorldMapResourceMark> source,
     int index,
     WorldMapResourceMark value)
 {
     ClientMarkAdded?.Invoke(value);
 }
Example #13
0
        public ViewModelFactionMembersListControl(bool sortByRole)
        {
            this.sortByRole   = sortByRole;
            this.privateState = Faction.GetPrivateState(FactionSystem.ClientCurrentFaction);
            this.privateState.OfficerRoleTitleBinding.ClientAnyModification
                += this.OfficerRoleTitleBindingAnyModificationHandler;

            this.membersList = this.privateState.Members;
            this.RebuildMembersList();

            // uncomment to test the long list

            /*for (var i = 0; i < 120; i++)
             * {
             *  var accessRights = (i % 10) switch
             *  {
             *      4 => FactionMemberAccessRights.Officer,
             *      _ => FactionMemberAccessRights.Member
             *  };
             *
             *  MembersList.Add(new FactionMemberViewEntry(
             *                      new FactionMemberEntry("user" + i.ToString("000"), accessRights)));
             * }*/

            this.SortMembersList();

            this.membersList.ClientElementInserted += this.MembersListElementInsertedHandler;
            this.membersList.ClientElementRemoved  += this.MembersListElementRemovedHandler;

            OnlinePlayersSystem.ClientPlayerAddedOrRemoved
                += this.OnlinePlayersSystemOnClientPlayerAddedOrRemovedHandler;
        }
Example #14
0
 private static void MarkerAddedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     ShowNotification(droppedLootInfo);
 }
Example #15
0
        public static void Init(ICharacter character)
        {
            if (droppedItemsLocations is not null)
            {
                droppedItemsLocations.ClientElementInserted -= MarkerAddedHandler;
                droppedItemsLocations.ClientElementRemoved  -= MarkerRemovedHandler;
                droppedItemsLocations = null;
            }

            foreach (var notification in Notifications)
            {
                notification.Value.Hide(quick: true);
            }

            Notifications.Clear();

            droppedItemsLocations = PlayerCharacter.GetPrivateState(character)
                                    .DroppedLootLocations;

            droppedItemsLocations.ClientElementInserted += MarkerAddedHandler;
            droppedItemsLocations.ClientElementRemoved  += MarkerRemovedHandler;

            ClientTimersSystem.AddAction(
                delaySeconds: 1,
                () =>
            {
                foreach (var droppedLootInfo in droppedItemsLocations)
                {
                    ShowNotification(droppedLootInfo);
                }
            });
        }
Example #16
0
        protected override void DisposeViewModel()
        {
            this.craftingQueueItems.ClientElementInserted -= this.QueueElementInsertedHandler;
            this.craftingQueueItems.ClientElementRemoved  -= this.QueueClientElementRemovedHandler;
            this.craftingQueueItems = null;

            base.DisposeViewModel();
        }
Example #17
0
 /// <summary>
 /// Please use <see cref="NetworkSyncListExtensions.ToObservableCollectionWithWrapper{TKey,TViewModel}" /> instead.
 /// </summary>
 public NetworkSyncListObservableWrapperWithConverter(
     NetworkSyncList <TItem> netList,
     Func <TItem, TViewModel> convertFunc)
 {
     this.netList              = netList;
     this.convertFunc          = convertFunc;
     this.observableCollection = new ObservableCollection <TViewModel>(netList.Select(convertFunc));
     this.EventsSubscribe();
 }
Example #18
0
 private void StatusEffectsInsertedHandler(
     NetworkSyncList <ILogicObject> source,
     int index,
     ILogicObject value)
 {
     if (value.ProtoGameObject is StatusEffectMedicalCooldown)
     {
         this.RefreshMedicalCooldown();
     }
 }
Example #19
0
        public static void Reset()
        {
            if (recentEventsLog is null)
            {
                return;
            }

            recentEventsLog.ClientElementInserted -= LogEntryAdded;
            recentEventsLog = null;
        }
            private void ClientUnlockedAchievementAdded(
                NetworkSyncList <PlayerCharacterAchievements.CharacterAchievementEntry> source,
                int index,
                PlayerCharacterAchievements.CharacterAchievementEntry value)
            {
                var achievementId = value.Achievement.AchievementId;

                Client.SteamApi.UnlockAchievement(achievementId);
                Logger.Important("Achievement added: " + achievementId);
            }
Example #21
0
 private static void MarkerRemovedHandler(
     NetworkSyncList <DroppedLootInfo> droppedLootInfos,
     int index,
     DroppedLootInfo droppedLootInfo)
 {
     if (Notifications.TryGetValue(droppedLootInfo, out var notificationControl))
     {
         notificationControl.Hide(quick: false);
     }
 }
Example #22
0
        public static void ServerInitialize(IStaticWorldObject tradingStation)
        {
            if (!(tradingStation.ProtoStaticWorldObject is IProtoObjectTradingStation protoTradingStation))
            {
                throw new Exception($"Not an {typeof(IProtoObjectTradingStation).FullName}: {tradingStation}");
            }

            TradingStationsMapMarksSystem.ServerTryAddMark(tradingStation);

            var privateState = GetPrivateState(tradingStation);
            var publicState  = GetPublicState(tradingStation);

            if (privateState.StockItemsContainer == null)
            {
                privateState.StockItemsContainer = ServerItems.CreateContainer(tradingStation,
                                                                               protoTradingStation
                                                                               .StockItemsContainerSlotsCount);
            }
            else
            {
                ServerItems.SetSlotsCount(privateState.StockItemsContainer,
                                          protoTradingStation.StockItemsContainerSlotsCount);
            }

            var lots = publicState.Lots;

            if (lots == null)
            {
                publicState.Lots =
                    lots         = new NetworkSyncList <TradingStationLot>(capacity: protoTradingStation.LotsCount);
            }

            // ensure that the lots count is not exceeded
            while (lots.Count > protoTradingStation.LotsCount)
            {
                lots.RemoveAt(protoTradingStation.LotsCount - 1);
            }

            for (var i = 0; i < protoTradingStation.LotsCount; i++)
            {
                if (lots.Count <= i)
                {
                    lots.Add(new TradingStationLot());
                }
                else if (lots[i] == null)
                {
                    lots[i] = new TradingStationLot();
                }
            }

            ServerRefreshTradingStationLots(tradingStation,
                                            privateState,
                                            publicState);
        }
Example #23
0
        public static void Setup(ILogicObject faction)
        {
            Reset();

            if (faction is null)
            {
                return;
            }

            recentEventsLog = Faction.GetPrivateState(faction).RecentEventsLog;
            recentEventsLog.ClientElementInserted += LogEntryAdded;
        }
        protected override void OnUnloaded()
        {
            ClientUpdateHelper.UpdateCallback     -= this.Update;
            this.questsList.ClientElementInserted -= this.QuestsListElementInserted;
            this.questsList.ClientElementRemoved  -= this.QuestsListElementRemoved;
            this.questsList = null;

            this.stateSubscriptionStorage.Dispose();
            this.stateSubscriptionStorage = null;

            this.registeredEntries.Clear();
            this.stackPanelChildren.Clear();
        }
Example #25
0
        private void QueueClientElementRemovedHandler(
            NetworkSyncList <CraftingQueueItem> source,
            int index,
            CraftingQueueItem removedValue)
        {
            if (this.craftingQueueItems.Count == 0)
            {
                // queue finished sounds
                ClientComponentTimersManager.AddAction(
                    delaySeconds: 0.3,
                    action: () => Client.Audio.PlayOneShot(new SoundResource("UI/Crafting/Completed")));
            }

            this.RemoveControl(removedValue);
        }
 private void QuestsListElementRemoved(
     NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source,
     int index,
     PlayerCharacterQuests.CharacterQuestEntry removedvalue)
 {
     foreach (var stackPanelChild in this.stackPanelChildren)
     {
         var control = (HUDQuestTrackingEntryControl)stackPanelChild;
         if (control.QuestEntry == removedvalue)
         {
             control.Hide(quick: false);
             return;
         }
     }
 }
Example #27
0
        public static void Init(ICharacter character)
        {
            if (droppedItemsLocations != null)
            {
                droppedItemsLocations.ClientElementInserted -= MarkerAddedHandler;
                droppedItemsLocations.ClientElementRemoved  -= MarkerRemovedHandler;
                droppedItemsLocations = null;
            }

            droppedItemsLocations = PlayerCharacter.GetPrivateState(character)
                                    .DroppedItemsLocations;

            droppedItemsLocations.ClientElementInserted += MarkerAddedHandler;
            droppedItemsLocations.ClientElementRemoved  += MarkerRemovedHandler;
        }
        protected override void OnLoaded()
        {
            this.registeredEntries
                = new Dictionary <PlayerCharacterQuests.CharacterQuestEntry, HUDQuestTrackingEntryControl>();
            this.stateSubscriptionStorage = new StateSubscriptionStorage();

            ClientUpdateHelper.UpdateCallback += this.Update;
            this.questsList = ClientCurrentCharacterHelper.PrivateState.Quests.Quests;
            this.questsList.ClientElementInserted += this.QuestsListElementInserted;
            this.questsList.ClientElementRemoved  += this.QuestsListElementRemoved;

            foreach (var questEntry in this.questsList)
            {
                this.Register(questEntry);
            }
        }
        public ClientWorldMapDroppedItemsVisualizer(WorldMapController worldMapController)
        {
            this.worldMapController = worldMapController;

            var playerCharacter = Api.Client.Characters.CurrentPlayerCharacter;
            this.droppedItemsLocations = PlayerCharacter.GetPrivateState(playerCharacter)
                                                        .DroppedItemsLocations;

            this.droppedItemsLocations.ClientElementInserted += this.MarkerAddedHandler;
            this.droppedItemsLocations.ClientElementRemoved += this.MarkerRemovedHandler;

            foreach (var position in this.droppedItemsLocations)
            {
                this.AddMarker(position);
            }
        }
Example #30
0
            private void ServerSetupTaskStates()
            {
                // ensure active tasks are reset
                this.ServerResetActiveTasks();

                var tasks = this.Achievement.Tasks;
                // we never modify this list but NetworkSyncList is required in order to bind its elements (AchievementTaskState) to the state owner
                var taskStates = new NetworkSyncList <PlayerTaskState>(tasks.Count);

                foreach (var task in tasks)
                {
                    var state = task.CreateState();
                    taskStates.Add(state);
                }

                this.TaskStates = taskStates;
            }