added: expanded environment observers with changed types, better gizmos, some fixes
This commit is contained in:
38
Assets/Scripts/Core/Graph Tasks/CheckEnvironmentObserver.cs
Normal file
38
Assets/Scripts/Core/Graph Tasks/CheckEnvironmentObserver.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions {
|
||||
[Category("Reset")]
|
||||
public class CheckEnvironmentObserver : ConditionTask<PlayerEnvironmentManager>{
|
||||
|
||||
public BBParameter<string> observerLabel;
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit(){
|
||||
var observer = agent.FindObserverFromString(observerLabel.value);
|
||||
if (observer == null) {
|
||||
return $"An environment observer couldn't be found under the name {observerLabel.value}. Check your spelling and if it exists??";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//Called whenever the condition gets enabled.
|
||||
protected override void OnEnable() {
|
||||
agent.FindObserverFromString(observerLabel.value).active = true;
|
||||
}
|
||||
|
||||
//Called whenever the condition gets disabled.
|
||||
protected override void OnDisable() {
|
||||
agent.FindObserverFromString(observerLabel.value).active = false;
|
||||
}
|
||||
|
||||
//Called once per frame while the condition is active.
|
||||
//Return whether the condition is success or failure.
|
||||
protected override bool OnCheck(){
|
||||
return agent.EvaluateFromString(observerLabel.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95ad4bd047d9654478597c68a81b01a0
|
||||
Reference in New Issue
Block a user