Ejemplo n.º 1
0
        public ViewModelWindowCrateContainer(
            IStaticWorldObject worldObjectCrate,
            ObjectCratePrivateState privateState,
            Action callbackCloseWindow)
        {
            this.WorldObjectCrate = worldObjectCrate;

            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                privateState.ItemsContainer,
                callbackCloseWindow)
            {
                IsContainerTitleVisible = false
            };

            var isOwner = WorldObjectOwnersSystem.SharedIsOwner(
                ClientCurrentCharacterHelper.Character,
                worldObjectCrate);

            this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                privateState.Owners,
                canEditOwners: isOwner ||
                CreativeModeSystem.ClientIsInCreativeMode(),
                callbackServerSetOwnersList:
                ownersList => WorldObjectOwnersSystem.ClientSetOwners(this.WorldObjectCrate,
                                                                      ownersList),
                title: CoreStrings.ObjectOwnersList_Title2);

            this.ViewModelAccessModeEditor = new ViewModelWorldObjectAccessModeEditor(
                worldObjectCrate,
                canSetAccessMode: isOwner);
        }
        public static WindowCrateContainer Show(IStaticWorldObject worldObject, ObjectCratePrivateState privateState)
        {
            var instance = new WindowCrateContainer();

            Api.Client.UI.LayoutRootChildren.Add(instance);
            instance.Setup(worldObject, privateState);
            return(instance);
        }
Ejemplo n.º 3
0
        public ViewModelWindowCrateContainer(
            IStaticWorldObject worldObjectCrate,
            ObjectCratePrivateState privateState,
            Action callbackCloseWindow)
        {
            this.WorldObjectCrate = worldObjectCrate;

            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                privateState.ItemsContainer,
                callbackCloseWindow)
            {
                IsContainerTitleVisible = false
            };

            this.IsInsideFactionClaim = LandClaimSystem.SharedIsWorldObjectOwnedByFaction(worldObjectCrate);

            if (!this.HasOwnersList)
            {
                return;
            }

            if (this.IsInsideFactionClaim)
            {
                if (FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.LandClaimManagement))
                {
                    this.ViewModelFactionAccessEditor = new ViewModelWorldObjectFactionAccessEditorControl(
                        worldObjectCrate);
                }
            }
            else
            {
                var isOwner = WorldObjectOwnersSystem.SharedIsOwner(
                    ClientCurrentCharacterHelper.Character,
                    worldObjectCrate);

                this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                    privateState.Owners,
                    canEditOwners: isOwner ||
                    CreativeModeSystem.ClientIsInCreativeMode(),
                    callbackServerSetOwnersList:
                    ownersList => WorldObjectOwnersSystem.ClientSetOwners(this.WorldObjectCrate,
                                                                          ownersList),
                    title: CoreStrings.ObjectOwnersList_Title2);

                this.ViewModelDirectAccessEditor = new ViewModelWorldObjectDirectAccessEditor(
                    worldObjectCrate,
                    canSetAccessMode: isOwner);
            }
        }
Ejemplo n.º 4
0
        public ViewModelWindowFridge(
            IStaticWorldObject worldObjectFridge,
            ObjectCratePrivateState privateState,
            Action callbackCloseWindow)
        {
            this.WorldObjectFridge = worldObjectFridge;
            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                privateState.ItemsContainer,
                callbackTakeAllItemsSuccess: callbackCloseWindow);

            if (this.WorldObjectFridge.ProtoStaticWorldObject is IProtoObjectElectricityConsumer)
            {
                this.publicStatePowerConsumer = this.WorldObjectFridge
                                                .GetPublicState <IObjectElectricityConsumerPublicState>();
                this.publicStatePowerConsumer?.ClientSubscribe(
                    _ => _.ElectricityConsumerState,
                    _ => this.NotifyPropertyChanged(nameof(this.IsActive)),
                    this);
            }
        }
 private void Setup(IStaticWorldObject worldObject, ObjectCratePrivateState privateState)
 {
     this.worldObject  = worldObject;
     this.privateState = privateState;
     this.RefreshViewModel();
 }