From 5b37ac97e34b00c75ac16e6f5fb919090bae1156 Mon Sep 17 00:00:00 2001 From: Scott Date: Wed, 2 Jan 2019 00:01:09 +0000 Subject: [PATCH] Update GoapPlanner.cs Hi, not sure if this is still maintained but I come across this code from an article online and found and issue. When I had no goals assigned I was noticing plans were still being built so I checked and found the inState() function would still return true if it's test parm was empty. The comment says it should return true so I added some code to return true when test is empty. Was also wonder if there was a reason why you did not use state.Contains(t) rather than looping over state and checking each value? I think the built in Contains() function dose pretty much the same thing? --- Assets/Standard Assets/Scripts/AI/GOAP/GoapPlanner.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/Standard Assets/Scripts/AI/GOAP/GoapPlanner.cs b/Assets/Standard Assets/Scripts/AI/GOAP/GoapPlanner.cs index 3d3b1f7..33a3f7a 100644 --- a/Assets/Standard Assets/Scripts/AI/GOAP/GoapPlanner.cs +++ b/Assets/Standard Assets/Scripts/AI/GOAP/GoapPlanner.cs @@ -132,6 +132,9 @@ private HashSet actionSubset(HashSet actions, GoapAction */ private bool inState(HashSet> test, HashSet> state) { bool allMatch = true; + if (test.Count < 1) { + return false; + } foreach (KeyValuePair t in test) { bool match = false; foreach (KeyValuePair s in state) {