private static void GameInit(ICharacter character)
        {
            foreach (var child in Api.Client.UI.LayoutRootChildren)
            {
                if (child is HUDLayoutControl layoutControl)
                {
                    hudLayoutControl = layoutControl;
                }
            }
            if (hudLayoutControl != null)
            {
                hudLayoutControl.Loaded += LayoutControl_Loaded;
            }
            else
            {
                Api.Logger.Error("LPNotifications: HUDLayoutControl not found.");
            }

            stateSubscriptionStorage = new StateSubscriptionStorage();
            privateState             = PlayerCharacter.GetPrivateState(character);
            lp = privateState.Technologies.LearningPoints;
            privateState.Technologies.ClientSubscribe(
                t => t.LearningPoints,
                OnLPChanged,
                stateSubscriptionStorage);
        }
        /// <summary>
        /// This method should be called only by LandClaimSystem.
        /// </summary>
        internal static void AddArea(ILogicObject area)
        {
            if (StateSubscriptionStorages.ContainsKey(area))
            {
                return;
            }

            // register for group change event
            var stateSubscriptionStorage = new StateSubscriptionStorage();

            StateSubscriptionStorages[area] = stateSubscriptionStorage;

            var areaPublicState = LandClaimArea.GetPublicState(area);

            areaPublicState.ClientSubscribe(
                o => o.LandClaimAreasGroup,
                newValue =>
            {
                //Api.Logger.Dev($"Received LandClaimAreasGroup changed: {newValue} for {area}");
                OnAreaModified(area);
            },
                stateSubscriptionStorage);

            // register area
            RendererManagerGraceAreas.RegisterArea(area);

            var renderer = LandClaimSystem.ClientIsOwnedArea(area)
                               ? RendererManagerOwnedByPlayer
                               : RendererManagerNotOwnedByPlayer;

            renderer.RegisterArea(area);

            AreaAdded?.Invoke(area);
        }
Beispiel #3
0
        public void RegisterSubscription(StateSubscriptionToken stateSubscriptionToken)
        {
            if (this.stateSubscriptionStorage == null)
            {
                this.stateSubscriptionStorage = new StateSubscriptionStorage();
            }

            this.stateSubscriptionStorage.RegisterSubscription(stateSubscriptionToken);
        }
Beispiel #4
0
        private static void GameInitHandler(ICharacter character)
        {
            playerTechnologies       = PlayerCharacter.GetPrivateState(character).Technologies;
            stateSubscriptionStorage = new StateSubscriptionStorage();
            lastLearningPoints       = playerTechnologies.LearningPoints;

            playerTechnologies.ClientSubscribe(
                t => t.LearningPoints,
                LearningPointsChangedHandler,
                stateSubscriptionStorage);
        }
Beispiel #5
0
            public void Dispose()
            {
                if (this.markControl != null)
                {
                    this.worldMapController.RemoveControl(this.markControl);
                    this.markControl = null;
                }

                this.RemoveRaidNotificationControl();

                this.stateSubscriptionStorage?.Dispose();
                this.stateSubscriptionStorage = null;
            }
        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();
        }
        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);
            }
        }
        private void Reset()
        {
            this.containerEquipmentSubscriptions?.Dispose();
            this.containerEquipmentSubscriptions = new StateSubscriptionStorage();

            this.containerEquipmentSubscriptions = new StateSubscriptionStorage();

            var powerBanks = this.containerEquipment.Items.Where(i => i.ProtoItem is IProtoItemPowerBank)
                             .Select(i => i);

            foreach (var powerBank in powerBanks)
            {
                powerBank.GetPrivateState <ItemPowerBankPrivateState>()
                .ClientSubscribe(_ => _.EnergyCharge,
                                 _ => this.Refresh(),
                                 subscriptionOwner: this.containerEquipmentSubscriptions);
            }

            this.Refresh();
        }
Beispiel #9
0
            public LandClaimMapData(ILogicObject area, WorldMapController worldMapController)
            {
                this.area                     = area;
                this.areaPrivateState         = area.GetPrivateState <LandClaimAreaPrivateState>();
                this.worldMapController       = worldMapController;
                this.stateSubscriptionStorage = new StateSubscriptionStorage();

                // add land claim mark control to map
                this.markControl = new WorldMapMarkLandClaim();
                var canvasPosition = this.GetAreaCanvasPosition();

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

                worldMapController.AddControl(this.markControl);

                this.areaPrivateState.ClientSubscribe(
                    o => o.LastRaidTime,
                    this.RefreshRaidedState,
                    this.stateSubscriptionStorage);

                this.RefreshRaidedState();
            }
Beispiel #10
0
 private static void GameResetHandler()
 {
     stateSubscriptionStorage?.Dispose();
     stateSubscriptionStorage = null;
 }
 protected override void DisposeViewModel()
 {
     this.containerEquipmentSubscriptions?.Dispose();
     this.containerEquipmentSubscriptions = null;
     base.DisposeViewModel();
 }