38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
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);
|
|
}
|
|
}
|
|
} |