Example #1
0
    public void ClickedByPlayer(Crew crewStatus)
    {
        //called when the player clicks on this node.
        //if necessary, takes items from the player inventory, if they have it, and applies it to the thing node.
        if (GetCurrentBlueprintNodeTask().nodeMode == NodeModes.thing)
        {
            BlueprintNodeTask nodeTask = GetCurrentBlueprintNodeTask();

            Thing foundThing = crewStatus.FindThingFromInventory(nodeTask.requiredThingType);
            if (foundThing != null && nodeTask.quantityFilled < nodeTask.quantityRequired && foundThing.quantity > 0)
            {
                int quantityUsed = nodeTask.quantityRequired - nodeTask.quantityFilled;
                if (quantityUsed > foundThing.quantity)
                {
                    quantityUsed = foundThing.quantity;
                }

                nodeTask.quantityFilled += quantityUsed;
                crewStatus.UseThing(foundThing, quantityUsed);
            }

            UpdateNodeTask();
        }
    }