public override bool Perform(GOAP_Agent agent, float deltaTime)
    {
        StartPerform(agent);
        if (isStartingWork)
        {
            field = (Field_GOAT)target;
            if (!field.IsAvailable())
            {
                agent.ChangeCurrentWorldState(new GOAP_Worldstate(WorldStateKey.bIsWheatRipe, false, field));
                agent.ChangeCurrentWorldState(new GOAP_Worldstate(WorldStateKey.bWasFieldTended, field.IsAlreadyTendedTo, field));
                agent.Character.Log("<color=#cc0000>" + agent.Character.characterData.characterName + " could not harvest wheat, as it is not ripe.</color>");
                agent.Replan();
                return(true);
            }
        }
        UpdateWorkTime(deltaTime);

        if (completed)
        {
            if (Random.value < 0.3f)
            {
                agent.Character.Log("<color=#cc0000>" + agent.Character.characterData.characterName + "s Hoe broke.</color>");
                agent.Character.UpdateInventory(ItemType.IronHoe, false);
            }
            agent.Character.UpdateInventory(ItemType.Wheat, true, 4);
            CompletePerform(agent);
            field.Harvest();
        }
        return(completed);
    }
Beispiel #2
0
    public override bool Perform(GOAP_Agent agent, float deltaTime)
    {
        StartPerform(agent);
        if (isStartingWork)
        {
            field = (Field_GOAT)target;
            if (field.IsAlreadyTendedTo)
            {
                agent.ChangeCurrentWorldState(new GOAP_Worldstate(WorldStateKey.bWasFieldTended, true, field));
                Debug.Log("<color=#cc0000>" + agent.Character.characterData.characterName + " could not tend to the field.</color>");
                agent.Replan();
                return(true);
            }
        }
        UpdateWorkTime(deltaTime);

        if (completed)
        {
            if (Random.value < 0.3f)
            {
                Debug.Log("<color=#cc0000>" + agent.Character.characterData.characterName + "s Hoe broke.</color>");
                agent.Character.UpdateInventory(ItemType.IronHoe, false);
            }
            Debug.Log("<color=#cc00cc>" + agent.Character.characterData.characterName + "</color> hopes that the field is now ripe");
            CompletePerform(agent);
            field.TendToField();
        }
        return(completed);
    }