added: new tasks for interactions with units
This commit is contained in:
49
Assets/Scripts/Core/Graph Tasks/IsInteractable.cs
Normal file
49
Assets/Scripts/Core/Graph Tasks/IsInteractable.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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 = agent.GetComponent<IInteractable>();
|
||||
|
||||
if (interactable == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return interactable.CanInteract();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user