예제 #1
0
        public ViewModelFuelBurningState(
            FuelBurningState fuelBurningState)
        {
            this.FuelBurningState = fuelBurningState;

            this.ContainerFuel = (IClientItemsContainer)fuelBurningState?.ContainerFuel;

            this.FuelBurningState.ClientSubscribe(
                _ => _.FuelUseTimeRemainsSeconds,
                secondsToBurn => this.RefreshFuelUsage(),
                this);

            this.FuelBurningState.ClientSubscribe(
                _ => _.CurrentFuelItemType,
                newFuelItemType => this.RefreshFuelUsage(),
                this);

            this.RefreshFuelUsage();

            var character = ClientCurrentCharacterHelper.Character;

            ClientContainersExchangeManager.Register(this,
                                                     this.ContainerFuel,
                                                     allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });
        }
예제 #2
0
        public ViewModelWindowGeneratorBio(
            IStaticWorldObject objectGenerator,
            ObjectGeneratorBioPrivateState privateState)
        {
            this.objectGenerator = objectGenerator;
            this.protoGenerator  = (ProtoObjectGeneratorBio)objectGenerator.ProtoGameObject;
            this.privateState    = privateState;

            this.privateState.ClientSubscribe(
                _ => _.OrganicAmount,
                _ => this.NotifyPropertyChanged(nameof(this.OrganicAmount)),
                this);

            var character = ClientCurrentCharacterHelper.Character;

            ClientContainersExchangeManager.Register(
                this,
                this.InputItemsContainer,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            this.Refresh();
        }
예제 #3
0
        public ViewModelItemsContainerExchange(IItemsContainer container, Action callbackTakeAllItemsSuccess)
        {
            this.callbackTakeAllItemsSuccess = callbackTakeAllItemsSuccess;
            this.Container = (IClientItemsContainer)container;

            var character = ClientCurrentCharacterHelper.Character;

            ClientContainersExchangeManager.Register(
                this,
                this.Container,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            ClientContainersExchangeManager.Register(
                this,
                character.SharedGetPlayerContainerHotbar(),
                allowedTargets: new[] { this.Container });

            ClientContainersExchangeManager.Register(
                this,
                character.SharedGetPlayerContainerInventory(),
                allowedTargets: new[] { this.Container });

            // ReSharper disable once CanExtractXamlLocalizableStringCSharp
            this.inputListener = ClientInputContext
                                 .Start("Container exchange")
                                 .HandleButtonDown(GameButton.ContainerTakeAll, this.ExecuteCommandTakeAll)
                                 .HandleButtonDown(GameButton.ContainerMoveItemsMatchDown, this.ExecuteCommandMatchDown)
                                 .HandleButtonDown(GameButton.ContainerMoveItemsMatchUp, this.ExecuteCommandMatchUp);
        }
예제 #4
0
        public ViewModelWindowStorageFridgeContainer(IItem itemStorage) : base(itemStorage)
        {
            this.privateState = itemStorage.GetPrivateState <ItemStorageFridgePrivateState>();
            this.publicState  = itemStorage.GetPublicState <ItemStorageFridgePublicState>();

            var currentCharacter = Api.Client.Characters.CurrentPlayerCharacter;

            ClientContainersExchangeManager.Register(
                this,
                this.ItemsEnergyContainer,
                allowedTargets: new[]
            {
                currentCharacter.SharedGetPlayerContainerInventory(),
                currentCharacter.SharedGetPlayerContainerHotbar()
            });

            this.isOn = this.publicState.IsOn;

            this.publicState.ClientSubscribe(
                _ => _.IsOn,
                _ =>
            {
                this.isOn = this.publicState.IsOn;
                this.NotifyPropertyChanged("IsOn");
                this.NotifyPropertyChanged("IsOff");
            },
                this);
        }
예제 #5
0
        public ViewModelWindowCraftingStation(
            IReadOnlyCollection <Recipe> availableRecipes,
            int recipesCountTotal)
        {
            var currentCharacter = Api.Client.Characters.CurrentPlayerCharacter;

            this.ContainerInventory    = (IClientItemsContainer)currentCharacter.SharedGetPlayerContainerInventory();
            this.ViewModelCraftingMenu = new ViewModelCraftingMenu(availableRecipes,
                                                                   recipesCountTotal,
                                                                   validateItemsAvailabilityInPlayerInventory: true);
            this.ViewModelCraftingMenu.TrySelectRecipe(lastSelectedRecipe);

            ClientContainersExchangeManager.Register(this, this.ContainerInventory);
            ClientContainersExchangeManager.Register(this, currentCharacter.SharedGetPlayerContainerHotbar());
        }
        public ViewModelWindowObjectLight(
            IStaticWorldObject worldObject,
            ObjectLightPrivateState privateState,
            ObjectLightPublicState publicState)
        {
            this.worldObject      = worldObject;
            this.protoObjectLight = (IProtoObjectLight)worldObject.ProtoStaticWorldObject;
            this.FuelCapacity     = this.protoObjectLight.FuelCapacity;

            this.privateState   = privateState;
            this.publicState    = publicState;
            this.ContainerInput = (IClientItemsContainer)privateState.ContainerInput;

            var character = ClientCurrentCharacterHelper.Character;

            ClientContainersExchangeManager.Register(this,
                                                     this.ContainerInput,
                                                     allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            var(icon, color) = this.protoObjectLight.FuelItemsContainerPrototype.ClientGetFuelIconAndColor();
            this.FuelIcon    = Client.UI.GetTextureBrush(icon);
            this.FuelColor   = color;

            this.privateState.ClientSubscribe(
                _ => _.FuelAmount,
                _ => this.RefreshFuelAmount(),
                this);

            this.privateState.ClientSubscribe(
                _ => _.Mode,
                _ => this.RefreshMode(),
                this);

            publicState.ClientSubscribe(
                _ => _.IsLightActive,
                _ => this.RefreshIsLightActive(),
                this);

            this.RefreshFuelAmount();
            this.RefreshMode();
            this.RefreshIsLightActive();
        }
        public ViewModelWindowTinkerTable(
            IStaticWorldObject tinkerTableObject,
            ObjectTinkerTable.PrivateState privateState)
        {
            this.tinkerTableObject = tinkerTableObject;

            this.containerInput              = (IClientItemsContainer)privateState.ContainerInput;
            this.containerInput.ItemAdded   += this.AnyContainerItemAddedHandler;
            this.containerInput.ItemRemoved += this.AnyContainerItemRemovedHandler;
            this.containerInput.ItemsReset  += this.AnyContainerResetHandler;

            this.containerOutput              = (IClientItemsContainer)privateState.ContainerOutput;
            this.containerOutput.ItemAdded   += this.AnyContainerItemAddedHandler;
            this.containerOutput.ItemRemoved += this.AnyContainerItemRemovedHandler;
            this.containerOutput.ItemsReset  += this.AnyContainerResetHandler;

            ClientComponentSkillsWatcher.SkillLevelChanged += this.CharacterSkillLevelChangedHandler;
            ClientCurrentCharacterFinalStatsHelper.FinalStatsCacheChanged += this.Refresh;

            // register containers exchange
            var character = ClientCurrentCharacterHelper.Character;

            ClientContainersExchangeManager.Register(
                this,
                this.containerOutput,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            ClientContainersExchangeManager.Register(
                this,
                this.containerInput,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            this.Refresh();
        }
예제 #8
0
        public ViewModelManufacturingState(
            IStaticWorldObject worldObjectManufacturer,
            ManufacturingState manufacturingState,
            ManufacturingConfig manufacturingConfig)
        {
            this.worldObjectManufacturer = worldObjectManufacturer;
            this.ManufacturingState      = manufacturingState;
            this.ManufacturingConfig     = manufacturingConfig;

            this.ContainerInput  = (IClientItemsContainer)manufacturingState.ContainerInput;
            this.ContainerOutput = (IClientItemsContainer)manufacturingState.ContainerOutput;

            this.CommandBrowseRecipes           = new ActionCommand(this.ExecuteCommandBrowseRecipes);
            this.CommandCloseRecipesBrowser     = new ActionCommand(this.CloseRecipesBrowser);
            this.CommandSelectRecipeFromBrowser =
                new ActionCommandWithParameter(this.ExecuteCommandSelectRecipeFromBrowser);
            this.CommandApplyBestMatchingRecipe = new ActionCommand(this.ExecuteCommandApplyBestMatchingRecipe);

            this.VisibilityRecipesSelection = manufacturingConfig.IsAutoSelectRecipe
                                                  ? Visibility.Collapsed
                                                  : Visibility.Visible;

            this.SelectedRecipe = manufacturingState.SelectedRecipe;
            //this.BestMatchingRecipe = manufacturingState.BestMatchingRecipe;

            this.RefreshCraftingProgressPercents();

            this.ManufacturingState.ClientSubscribe(
                _ => _.SelectedRecipe,
                recipe => this.SelectedRecipe = recipe,
                this);

            //this.ManufacturingState.ClientSubscribe(
            //    _ => _.BestMatchingRecipe,
            //    recipe => this.BestMatchingRecipe = recipe,
            //    this);

            this.ManufacturingState.CraftingQueue.ClientSubscribe(
                _ => _.IsContainerOutputFull,
                _ => this.NotifyPropertyChanged(nameof(this.IsContainerOutputFull)),
                this);

            this.craftingQueue = this.ManufacturingState.CraftingQueue.QueueItems;
            this.craftingQueue.ClientAnyModification
                += this.CraftingQueueAnyModificationHandler;

            this.ManufacturingState.CraftingQueue.ClientSubscribe(
                _ => _.TimeRemainsToComplete,
                time => this.RefreshCraftingProgressPercents(),
                this);

            // register containers exchange
            var character = Client.Characters.CurrentPlayerCharacter;

            ClientContainersExchangeManager.Register(
                this,
                this.ManufacturingState.ContainerOutput,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            ClientContainersExchangeManager.Register(
                this,
                this.ManufacturingState.ContainerInput,
                allowedTargets: new[]
            {
                character.SharedGetPlayerContainerInventory(),
                character.SharedGetPlayerContainerHotbar()
            });

            this.ContainerInput.StateHashChanged += this.ContainerInputStateChangedHandler;

            this.RefreshIsInputMatchSelectedRecipe();
            this.RefreshBestMatchingRecipe();
        }