63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using System.Drawing;
|
|
using NodeCanvas.Framework;
|
|
using ParadoxNotion.Design;
|
|
using UnityEngine;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Reset {
|
|
[Category("Reset")]
|
|
[Description("Creates an environment observer unattached from the player, such as for checking from the Camera or another arbitray location.")]
|
|
public class CheckGenericObserver : ConditionTask<Transform>{
|
|
[Space(5)]
|
|
public BBParameter<EnvironmentObserver.CastType> castType;
|
|
|
|
public BBParameter<float> length;
|
|
public BBParameter<Vector3> direction;
|
|
public BBParameter<Vector3> offset;
|
|
public BBParameter<LayerMask> ignoreLayers;
|
|
|
|
[ShowIf("castType", ((int)EnvironmentObserver.CastType.SphereCast|(int)EnvironmentObserver.CastType.SphereOverlap))]
|
|
public BBParameter<float> width;
|
|
|
|
public BBParameter<Vector3> size;
|
|
|
|
public BBParameter<Vector3> rotation;
|
|
|
|
private EnvironmentObserver observer;
|
|
|
|
//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() {
|
|
observer = new EnvironmentObserver(){
|
|
castType = EnvironmentObserver.CastType.SphereCast,
|
|
|
|
length = length.value,
|
|
direction = direction.value,
|
|
offset = offset.value,
|
|
|
|
width = width.value,
|
|
|
|
size = size.value,
|
|
rotation = rotation.value
|
|
};
|
|
}
|
|
|
|
//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() {
|
|
return observer.Evaluate(agent.gameObject);
|
|
}
|
|
}
|
|
} |