47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Reset.Core {
|
|
|
|
[Category("Reset")]
|
|
[Description("Checks if the object has IInteractable and if the interactable object is available for use.")]
|
|
public class IsInteractable : ConditionTask{
|
|
public BBParameter<GameObject> target;
|
|
protected override string info{
|
|
get{
|
|
// string agentName = agent == null ? agentType.ToString() : target.ToString();
|
|
return $"<b>{target.ToString()}</b> is interactable";
|
|
}
|
|
}
|
|
|
|
//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(){
|
|
return null;
|
|
}
|
|
|
|
//Called whenever the condition gets enabled.
|
|
protected override void OnEnable() {
|
|
|
|
}
|
|
|
|
//Called whenever the condition gets disabled.
|
|
protected override void OnDisable() {
|
|
|
|
}
|
|
|
|
//Called once per frame while the condition is active.
|
|
//Return whether the condition is success or failure.
|
|
protected override bool OnCheck(){
|
|
IInteractable interactable = target.value.GetComponent<IInteractable>();
|
|
|
|
if (interactable == null) {
|
|
return false;
|
|
}
|
|
|
|
return interactable.CanInteract();
|
|
}
|
|
}
|
|
} |