public ViewModelWindowLandClaim(
            IStaticWorldObject landClaimWorldObject,
            ILogicObject area)
        {
            this.landClaimWorldObject = landClaimWorldObject;
            this.privateState         = LandClaimArea.GetPrivateState(area);

            var protoLandClaim = (IProtoObjectLandClaim)landClaimWorldObject.ProtoStaticWorldObject;
            var canEditOwners  = protoLandClaim
                                 .SharedCanEditOwners(landClaimWorldObject, ClientCurrentCharacterHelper.Character);

            this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                this.privateState.LandOwners,
                callbackServerSetOwnersList: ownersList => LandClaimSystem.ClientSetAreaOwners(
                    area,
                    ownersList),
                title: AccessListTitle + ":",
                emptyListMessage: AccessListEmpty,
                canEditOwners: canEditOwners,
                // exclude founder name
                ownersListFilter: name => name != this.FounderName,
                maxOwnersListLength: LandClaimSystemConstants.SharedLandClaimOwnersMax,
                displayedOwnersNumberAdjustment: -1);

            this.protoObjectLandClaim =
                (IProtoObjectLandClaim)this.landClaimWorldObject.ProtoStaticWorldObject;

            var upgrade = this.protoObjectLandClaim.ConfigUpgrade.Entries.FirstOrDefault();

            if (upgrade is not null)
            {
                this.ViewModelStructureUpgrade          = new ViewModelStructureUpgrade(upgrade);
                this.ViewModelProtoLandClaimInfoUpgrade = new ViewModelProtoLandClaimInfo(
                    (IProtoObjectLandClaim)upgrade.ProtoStructure);
            }

            var objectPublicState = landClaimWorldObject.GetPublicState <ObjectLandClaimPublicState>();

            objectPublicState.ClientSubscribe(
                _ => _.LandClaimAreaObject,
                _ => this.RefreshSafeStorageAndPowerGrid(),
                this);

            this.RefreshSafeStorageAndPowerGrid();

            this.ViewModelProtoLandClaimInfoCurrent = new ViewModelProtoLandClaimInfo(this.protoObjectLandClaim);

            ItemsContainerLandClaimSafeStorage.ClientSafeItemsSlotsCapacityChanged
                += this.SafeItemsSlotsCapacityChangedHandler;

            this.RequestDecayInfoTextAsync();

            this.ViewModelShieldProtectionControl = new ViewModelShieldProtectionControl(
                LandClaimSystem.SharedGetLandClaimAreasGroup(area));
        }
Example #2
0
        public ViewModelWindowLandClaim(
            IStaticWorldObject landClaimWorldObject,
            ILogicObject area)
        {
            this.landClaimWorldObject = landClaimWorldObject;

            this.privateState = LandClaimArea.GetPrivateState(area);

            var protoStructureWithOwnersList =
                ((IProtoObjectWithOwnersList)landClaimWorldObject.ProtoStaticWorldObject);
            var canEditOwners = protoStructureWithOwnersList
                                .SharedCanEditOwners(landClaimWorldObject, ClientCurrentCharacterHelper.Character);

            this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                this.privateState.LandOwners,
                callbackServerSetOwnersList: ownersList => LandClaimSystem.ClientSetAreaOwners(
                    area,
                    ownersList),
                title: AccessListTitle + ":",
                emptyListMessage: AccessListEmpty,
                canEditOwners: canEditOwners,
                // exclude founder name
                ownersListFilter: name => name != this.FounderName);

            this.protoObjectLandClaim =
                (IProtoObjectLandClaim)this.landClaimWorldObject.ProtoStaticWorldObject;

            var upgrade = this.protoObjectLandClaim.ConfigUpgrade.Entries.FirstOrDefault();

            if (upgrade != null)
            {
                this.ViewModelStructureUpgrade          = new ViewModelStructureUpgrade(upgrade);
                this.ViewModelProtoLandClaimInfoUpgrade = new ViewModelProtoLandClaimInfo(
                    (IProtoObjectLandClaim)upgrade.ProtoStructure);
            }

            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                landClaimWorldObject.GetPrivateState <ObjectLandClaimPrivateState>().ItemsContainer,
                callbackTakeAllItemsSuccess: () => { })
            {
                IsContainerTitleVisible = false
            };

            this.ViewModelProtoLandClaimInfoCurrent = new ViewModelProtoLandClaimInfo(this.protoObjectLandClaim);
        }