public override bool perform(GameObject agent) { CowStomach bag = (CowStomach)agent.GetComponent(typeof(CowStomach)); if (bag.hasMilk()) { done = true; return(true); } done = true; return(false); }
/** * Key-Value data that will feed the GOAP actions and system while planning. */ public HashSet <KeyValuePair <string, object> > getWorldState() { HashSet <KeyValuePair <string, object> > worldData = new HashSet <KeyValuePair <string, object> >(); bool grassAvaialve = false; Grass[] supplyPiles = (Grass[])UnityEngine.GameObject.FindObjectsOfType(typeof(Grass)); if (supplyPiles.Length > 0) { grassAvaialve = true; } worldData.Add(new KeyValuePair <string, object>("grassAvailable", grassAvaialve)); worldData.Add(new KeyValuePair <string, object>("hasMilk", (stomach.hasMilk()))); worldData.Add(new KeyValuePair <string, object>("drankEnoughToEat", (stomach.waterDrunk >= 10))); return(worldData); }