示例#1
0
        public override bool CanBeCrafted(
            IWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (!base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft))
            {
                return(false);
            }

            var state = this.GetLiquidState((IStaticWorldObject)objectManufacturer);

            if (state.Amount < this.OutputItemLiquidCapacity)
            {
                // not enough amount
                return(false);
            }

            if (craftingQueue.ContainerOutput.OccupiedSlotsCount > 0 &&
                craftingQueue.ContainerOutput.Items.Any(
                    i => !(i.ProtoItem is TOutputProtoItem)))
            {
                // contains something other in the output container
                return(false);
            }

            return(true);
        }
示例#2
0
    private void Start()
    {
        inventory     = GetComponent <Inventory>();
        CraftingQueue = new CraftingQueue(this);

        OnCraftCompletedCallback += CompleteCraft;
    }
示例#3
0
 protected virtual bool CanBeCrafted(
     IStaticWorldObject objectManufacturer,
     CraftingQueue craftingQueue,
     ushort countToCraft)
 {
     return(base.CanBeCrafted(null, objectManufacturer, craftingQueue, countToCraft));
 }
示例#4
0
        protected override bool CanBeCrafted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (!base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft))
            {
                return(false);
            }

            var state = this.GetLiquidState(objectManufacturer);

            if (state.Amount < LiquidAmountToProduceOneOutputItem)
            {
                // not enough amount
                return(false);
            }

            if (craftingQueue.ContainerOutput.OccupiedSlotsCount > 0 &&
                craftingQueue.ContainerOutput.Items.Any(
                    i => i.ProtoItem != this.outputItem))
            {
                // contains something other in the output container
                return(false);
            }

            return(true);
        }
示例#5
0
 public override bool CanBeCrafted(
     IWorldObject characterOrStationObject,
     CraftingQueue craftingQueue,
     ushort countToCraft)
 {
     throw new Exception("Incorrect method for RecipeForStationByproduct.");
 }
示例#6
0
        public override bool CanBeCrafted(
            IWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (!base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft))
            {
                return(false);
            }

            var output      = this.outputItem;
            var protoBarrel = (IProtoObjectBarrel)objectManufacturer.ProtoWorldObject;
            var state       = protoBarrel.GetBarrelPrivateState((IStaticWorldObject)objectManufacturer);

            if (state.LiquidAmount < output.Capacity ||
                state.LiquidType != output.LiquidType)
            {
                // contains liquid of other type or not enough amount
                return(false);
            }

            if (craftingQueue.ContainerOutput.OccupiedSlotsCount > 0 &&
                craftingQueue.ContainerOutput.Items.Any(
                    i => !(i.ProtoItem is TOutputItem)))
            {
                // contains something other in the output container
                return(false);
            }

            return(true);
        }
        public override bool CanBeCrafted(
            IWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (!base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft))
            {
                return(false);
            }

            var liquidCapacity = GetLiquidCapacity(objectManufacturer);
            var state          = this.GetLiquidState(objectManufacturer);

            if (state.Amount + this.inputItem.Capacity
                > liquidCapacity)
            {
                // capacity will exceeded - cannot craft
                return(false);
            }

            if (craftingQueue.ContainerOutput.OccupiedSlotsCount > 0 &&
                craftingQueue.ContainerOutput.Items.Any(
                    i => !(i.ProtoItem is ItemBottleEmpty)))
            {
                // contains something other in the output container
                return(false);
            }

            return(true);
        }
 public override bool CanBeCrafted(
     IWorldObject objectManufacturer,
     CraftingQueue craftingQueue,
     ushort countToCraft)
 {
     // Please note: no biome check here.
     return(base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft));
 }
示例#9
0
 public override bool CanBeCrafted(
     ICharacter character,
     IStaticWorldObject objectStation,
     CraftingQueue craftingQueue,
     ushort countToCraft)
 {
     throw new Exception("Incorrect method for " + nameof(RecipeForManufacturingByproduct));
 }
示例#10
0
        public override bool CanBeCrafted(
            IWorldObject objectMulchbox,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            var privateState = GetPrivateState(objectMulchbox);

            return(privateState.OrganicAmount >= MulchOrganicValue);
        }
示例#11
0
        protected override bool CanBeCrafted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            var privateState = GetPrivateState(objectManufacturer);

            return(privateState.OrganicAmount >= MulchOrganicValue);
        }
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).DisplayShort(_sep);
            output += _sep;
            output += new CraftingQueue(_pInfo, _options).Display(_sep);

            SendOutput(output);
        }
示例#13
0
        public void Refresh()
        {
            this.craftingQueue = ClientCurrentCharacterHelper.PrivateState?.CraftingQueue;
            this.DestroyViewModel();

            if (this.craftingQueue is not null &&
                this.isLoaded)
            {
                this.CreateViewModel();
            }
        }
示例#14
0
        public override bool CanBeCrafted(
            IWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (((IStaticWorldObject)objectManufacturer).OccupiedTile.ProtoTile is IProtoTileWellAllowed protoTile &&
                protoTile.IsStaleWellWater)
            {
                return(base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft));
            }

            return(false);
        }
示例#15
0
            public override bool CanBeCrafted(
                ICharacter character,
                IStaticWorldObject objectStation,
                CraftingQueue craftingQueue,
                ushort countToCraft)
            {
                if (character is null)
                {
                    // this recipe requires a character
                    return(false);
                }

                return(base.CanBeCrafted(character, objectStation, craftingQueue, countToCraft));
            }
示例#16
0
        public sealed override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue)
        {
            // let's remove the liquid amount of the output item from the refinery liquid state
            var liquidState = this.GetLiquidState(objectManufacturer);
            var amount      = liquidState.Amount;

            amount -= this.OutputItemLiquidCapacity;

            liquidState.Amount = amount;

            this.ServerOnLiquidAmountChanged(objectManufacturer);
        }
示例#17
0
            public sealed override bool CanBeCrafted(
                ICharacter character,
                IStaticWorldObject objectStation,
                CraftingQueue craftingQueue,
                ushort countToCraft)
            {
                if (character is not null)
                {
                    // this recipe cannot be crafted by character as it's a manufacturing recipe
                    return(false);
                }

                return(this.CanBeCrafted(objectStation, craftingQueue, countToCraft));
            }
示例#18
0
        public ViewModelCraftingQueueItem(
            CraftingQueue craftingQueue,
            CraftingQueueItem craftingQueueItem,
            Action countToCraftChangedCallback)
        {
            if (IsDesignTime)
            {
                this.Icon = Brushes.BlueViolet;
                return;
            }

            this.craftingQueue               = craftingQueue;
            this.craftingQueueItem           = craftingQueueItem;
            this.countToCraftChangedCallback = countToCraftChangedCallback;
            var outputProtoItem = this.craftingQueueItem.RecipeEntry.ProtoItemSkinOverride
                                  ?? this.craftingQueueItem.RecipeEntry.Recipe.OutputItems.Items.First().ProtoItem;

            this.RecipeViewModel = new ViewModelCraftingRecipe(this.craftingQueueItem.RecipeEntry.Recipe);

            // TODO: it's not a great idea to always send this info from the server,
            // it could be calculated on Client-side with custom component (updates every frame)
            // and only sometimes sync with the server.
            craftingQueue.ClientSubscribe(
                _ => _.TimeRemainsToComplete,
                _ => this.UpdateProgress(),
                this);

            this.UpdateProgress();

            this.craftingQueueItem.ClientSubscribe(
                _ => _.CountToCraftRemains,
                newCountToCraftRemains =>
            {
                if (this.lastCountToCraft.HasValue &&
                    this.lastCountToCraft.Value > newCountToCraftRemains)
                {
                    // count to craft decreased
                    Client.Audio.PlayOneShot(new SoundResource("UI/Notifications/ItemAdded"));
                }

                this.UpdateCountToCraftRemains();
                countToCraftChangedCallback?.Invoke();
            },
                this);

            this.UpdateCountToCraftRemains();

            this.Icon = Client.UI.GetTextureBrush(outputProtoItem.Icon);
        }
示例#19
0
            public override bool CanBeCrafted(
                ICharacter character,
                IStaticWorldObject objectStation,
                CraftingQueue craftingQueue,
                ushort countToCraft)
            {
                if (character is null)
                {
                    // this recipe requires a character
                    return(false);
                }

                // Please note: base type check will perform whether the station argument is provided and valid.
                return(base.CanBeCrafted(character, objectStation, craftingQueue, countToCraft));
            }
示例#20
0
            public override bool CanBeCrafted(
                ICharacter character,
                IStaticWorldObject objectStation,
                CraftingQueue craftingQueue,
                ushort countToCraft)
            {
                if (this.RecipeType != RecipeType.Hand &&
                    (objectStation is null ||
                     !this.StationTypes.Contains(objectStation.ProtoWorldObject)))
                {
                    // requires a specific station
                    return(false);
                }

                return(base.CanBeCrafted(character, objectStation, craftingQueue, countToCraft));
            }
        public override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue)
        {
            var liquidCapacity = GetLiquidCapacity(objectManufacturer);

            // let's add liquid amount of the input item into the object liquid amount
            var privateState = GetPrivateState(objectManufacturer);
            var amount       = privateState.WaterAmount;

            amount += this.inputItem.Capacity;
            if (amount >= liquidCapacity)
            {
                // cannot exceed capacity
                amount = liquidCapacity;
            }

            privateState.SetWaterAmount(amount, liquidCapacity, GetPublicState(objectManufacturer));
        }
示例#22
0
        public override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectMulchbox,
            CraftingQueue craftingQueue)
        {
            var privateState  = GetPrivateState(objectMulchbox);
            var organicAmount = (int)privateState.OrganicAmount;

            // decrease remaining amount
            organicAmount -= MulchOrganicValue;

            if (organicAmount < 0)
            {
                // should be impossible
                Logger.Error(
                    $"Organic amount of mulchbox after crafting mulch become negative: {organicAmount}. {objectMulchbox}");
                organicAmount = 0;
            }
            privateState.OrganicAmount = (ushort)organicAmount;
        }
示例#23
0
        public ViewModelCraftingQueue(CraftingQueue craftingQueue, UIElementCollection itemsChildrenCollection)
        {
            this.craftingQueue           = craftingQueue;
            this.itemsChildrenCollection = itemsChildrenCollection;

            this.craftingQueueItems = craftingQueue.QueueItems;

            this.craftingQueueItems.ClientElementInserted += this.QueueElementInsertedHandler;
            this.craftingQueueItems.ClientElementRemoved  += this.QueueClientElementRemovedHandler;

            this.Refresh();

            foreach (var craftingQueueItem in this.craftingQueueItems)
            {
                this.AddControl(craftingQueueItem);
            }

            this.ItemControlHiddenHandler();
        }
示例#24
0
            public override bool CanBeCrafted(
                IWorldObject characterOrStationObject,
                CraftingQueue craftingQueue,
                ushort countToCraft)
            {
                if (characterOrStationObject is null)
                {
                    // require character or station
                    return(false);
                }

                if (this.RecipeType != RecipeType.Hand &&
                    !this.StationTypes.Contains(characterOrStationObject.ProtoWorldObject))
                {
                    // requires station
                    return(false);
                }

                return(base.CanBeCrafted(characterOrStationObject, craftingQueue, countToCraft));
            }
示例#25
0
        public ViewModelCraftingQueue(CraftingQueue craftingQueue, UIElementCollection itemsChildrenCollection)
        {
            this.craftingQueue           = craftingQueue;
            this.itemsChildrenCollection = itemsChildrenCollection;

            this.craftingQueueItems = craftingQueue.QueueItems;

            this.craftingQueueItems.ClientElementInserted += this.QueueElementInsertedHandler;
            this.craftingQueueItems.ClientElementRemoved  += this.QueueClientElementRemovedHandler;

            this.Refresh();

            for (var index = 0; index < this.craftingQueueItems.Count; index++)
            {
                var craftingQueueItem = this.craftingQueueItems[index];
                this.AddControl(craftingQueueItem, index);
            }

            this.ItemControlHiddenHandler();
        }
        public override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue)
        {
            // let's add liquid amount of the input item into the barrel amount
            var input       = this.inputItem;
            var protoBarrel = (IProtoObjectBarrel)objectManufacturer.ProtoWorldObject;
            var state       = protoBarrel.GetBarrelPrivateState(objectManufacturer);
            int amount      = state.LiquidAmount;

            state.LiquidType = input.LiquidType;
            amount          += input.Capacity;
            if (amount >= protoBarrel.LiquidCapacity)
            {
                // cannot exceed barrel capacity
                amount = protoBarrel.LiquidCapacity;
            }

            state.LiquidAmount = (ushort)amount;
        }
        public override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue)
        {
            var liquidCapacity = GetLiquidCapacity(objectManufacturer);

            // let's add liquid amount of the input item into the object liquid amount
            var privateState = GetPrivateState(objectManufacturer);
            var liquidState  = this.GetLiquidState(privateState);
            var amount       = liquidState.Amount;

            amount += this.inputItem.Capacity;
            if (amount >= liquidCapacity)
            {
                // cannot exceed capacity
                amount = liquidCapacity;
            }

            liquidState.Amount = amount;
            privateState.IsLiquidStatesChanged = true;
        }
示例#28
0
        public override void ServerOnManufacturingCompleted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue)
        {
            // let's remove the liquid amount of the output item from the barrel amount
            var output      = this.outputItem;
            var protoBarrel = (IProtoObjectBarrel)objectManufacturer.ProtoWorldObject;
            var state       = protoBarrel.GetBarrelPrivateState(objectManufacturer);
            int amount      = state.LiquidAmount;

            amount -= output.Capacity;
            if (amount < output.Capacity)
            {
                // consume all the remaining amount
                // that should not happens but still
                amount = 0;
                Logger.Warning("Consumed all the remaining amount of liquid in " + objectManufacturer);
            }

            state.LiquidAmount = (ushort)amount;
            state.LiquidType   = amount > 0 ? (LiquidType?)output.LiquidType : null;
        }
示例#29
0
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new StatsList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new BuffList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new SkillList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new QuestList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new SpawnpointList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new WaypointList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new FavoriteRecipeList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new UnlockedRecipeList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new CraftingQueue(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new ToolbeltList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new EquipmentList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new BagList(_pInfo, _options).Display(_sep);
            output += _sep;

            // todo:
            // friends
            // tracked friends // _pdf.trackedFriendEntityIds //List<int>
            // claims (_ppd.LPBlocks)
            // list owned storage containers and doors for the players

            SendOutput(output);
        }
示例#30
0
        protected override bool CanBeCrafted(
            IStaticWorldObject objectManufacturer,
            CraftingQueue craftingQueue,
            ushort countToCraft)
        {
            if (!base.CanBeCrafted(objectManufacturer, craftingQueue, countToCraft))
            {
                return(false);
            }

            var input       = this.inputItem;
            var protoBarrel = (IProtoObjectBarrel)objectManufacturer.ProtoWorldObject;
            var state       = protoBarrel.GetBarrelPrivateState(objectManufacturer);

            if (state.LiquidAmount > 0 &&
                state.LiquidType != input.LiquidType)
            {
                // input contains liquid of other type
                return(false);
            }

            if (state.LiquidAmount >= protoBarrel.LiquidCapacity)
            {
                // capacity exceeded
                return(false);
            }

            if (craftingQueue.ContainerOutput.OccupiedSlotsCount > 0 &&
                craftingQueue.ContainerOutput.Items.Any(
                    i => i.ProtoItem is not TOutputItem))
            {
                // contains something other in the output container
                return(false);
            }

            return(true);
        }