first commit
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Collision")]
|
||||
public class CheckCollision_Rigidbody : ConditionTask<Rigidbody>
|
||||
{
|
||||
|
||||
public CollisionTypes checkType = CollisionTypes.CollisionEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactPoint;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactNormal;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onCollisionEnter += OnCollisionEnter;
|
||||
router.onCollisionExit += OnCollisionExit;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onCollisionEnter -= OnCollisionEnter;
|
||||
router.onCollisionExit -= OnCollisionExit;
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return checkType == CollisionTypes.CollisionStay ? stay : false;
|
||||
}
|
||||
|
||||
public void OnCollisionEnter(ParadoxNotion.EventData<Collision> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == CollisionTypes.CollisionEnter || checkType == CollisionTypes.CollisionStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
saveContactPoint.value = data.value.contacts[0].point;
|
||||
saveContactNormal.value = data.value.contacts[0].normal;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCollisionExit(ParadoxNotion.EventData<Collision> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == CollisionTypes.CollisionExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("System Events")]
|
||||
[DoNotList]
|
||||
public class CheckCollision : ConditionTask<Collider>
|
||||
{
|
||||
|
||||
public CollisionTypes checkType = CollisionTypes.CollisionEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactPoint;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactNormal;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onCollisionEnter += OnCollisionEnter;
|
||||
router.onCollisionExit += OnCollisionExit;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onCollisionEnter -= OnCollisionEnter;
|
||||
router.onCollisionExit -= OnCollisionExit;
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return checkType == CollisionTypes.CollisionStay ? stay : false;
|
||||
}
|
||||
|
||||
public void OnCollisionEnter(ParadoxNotion.EventData<Collision> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == CollisionTypes.CollisionEnter || checkType == CollisionTypes.CollisionStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
saveContactPoint.value = data.value.contacts[0].point;
|
||||
saveContactNormal.value = data.value.contacts[0].normal;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCollisionExit(ParadoxNotion.EventData<Collision> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == CollisionTypes.CollisionExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 531fb78139babb8409afb3a8d6af41c3
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckCollision.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,132 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Collision 2D")]
|
||||
public class CheckCollision2D_Rigidbody : ConditionTask<Rigidbody2D>
|
||||
{
|
||||
|
||||
public CollisionTypes checkType = CollisionTypes.CollisionEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactPoint;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactNormal;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return checkType == CollisionTypes.CollisionStay ? stay : false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onCollisionEnter2D += OnCollisionEnter2D;
|
||||
router.onCollisionExit2D += OnCollisionExit2D;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onCollisionEnter2D -= OnCollisionEnter2D;
|
||||
router.onCollisionExit2D -= OnCollisionExit2D;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(ParadoxNotion.EventData<Collision2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == CollisionTypes.CollisionEnter || checkType == CollisionTypes.CollisionStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
saveContactPoint.value = data.value.contacts[0].point;
|
||||
saveContactNormal.value = data.value.contacts[0].normal;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionExit2D(ParadoxNotion.EventData<Collision2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == CollisionTypes.CollisionExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Collision 2D")]
|
||||
[DoNotList]
|
||||
public class CheckCollision2D : ConditionTask<Collider2D>
|
||||
{
|
||||
|
||||
public CollisionTypes checkType = CollisionTypes.CollisionEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactPoint;
|
||||
[BlackboardOnly]
|
||||
public BBParameter<Vector3> saveContactNormal;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return checkType == CollisionTypes.CollisionStay ? stay : false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onCollisionEnter2D += OnCollisionEnter2D;
|
||||
router.onCollisionExit2D += OnCollisionExit2D;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onCollisionEnter2D -= OnCollisionEnter2D;
|
||||
router.onCollisionExit2D -= OnCollisionExit2D;
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(ParadoxNotion.EventData<Collision2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == CollisionTypes.CollisionEnter || checkType == CollisionTypes.CollisionStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
saveContactPoint.value = data.value.contacts[0].point;
|
||||
saveContactNormal.value = data.value.contacts[0].normal;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionExit2D(ParadoxNotion.EventData<Collision2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == CollisionTypes.CollisionExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fc9130e4cf37b44f9987c272ef3d3da
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckCollision2D.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,52 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
public class CheckMouse : ConditionTask<Collider>
|
||||
{
|
||||
|
||||
public MouseInteractionTypes checkType = MouseInteractionTypes.MouseEnter;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString(); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() { return false; }
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onMouseEnter += OnMouseEnter;
|
||||
router.onMouseExit += OnMouseExit;
|
||||
router.onMouseOver += OnMouseOver;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onMouseEnter -= OnMouseEnter;
|
||||
router.onMouseExit -= OnMouseExit;
|
||||
router.onMouseOver -= OnMouseOver;
|
||||
}
|
||||
|
||||
void OnMouseEnter(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseEnter ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseExit(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseExit ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseOver(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseOver ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d0698377c375144ea26e817bc5d9c6e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckMouse.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,53 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Mouse 2D")]
|
||||
public class CheckMouse2D : ConditionTask<Collider2D>
|
||||
{
|
||||
|
||||
public MouseInteractionTypes checkType = MouseInteractionTypes.MouseEnter;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString(); }
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onMouseEnter += OnMouseEnter;
|
||||
router.onMouseExit += OnMouseExit;
|
||||
router.onMouseOver += OnMouseOver;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onMouseEnter -= OnMouseEnter;
|
||||
router.onMouseExit -= OnMouseExit;
|
||||
router.onMouseOver -= OnMouseOver;
|
||||
}
|
||||
|
||||
protected override bool OnCheck() { return false; }
|
||||
|
||||
void OnMouseEnter(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseEnter ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseExit(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseExit ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseOver(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseInteractionTypes.MouseOver ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41f72cd7fdd898849b2e44eddeb6c866
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckMouse2D.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,44 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
public class CheckMouseClick : ConditionTask<Collider>
|
||||
{
|
||||
|
||||
public MouseClickEvent checkType = MouseClickEvent.MouseDown;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString(); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() { return false; }
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onMouseDown += OnMouseDown;
|
||||
router.onMouseUp += OnMouseUp;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onMouseDown -= OnMouseDown;
|
||||
router.onMouseUp -= OnMouseUp;
|
||||
}
|
||||
|
||||
void OnMouseDown(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseClickEvent.MouseDown ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseUp(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseClickEvent.MouseUp ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6cc4ca38913a374fa72f6c64974364c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckMouseClick.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,45 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Mouse Click 2D")]
|
||||
public class CheckMouseClick2D : ConditionTask<Collider2D>
|
||||
{
|
||||
|
||||
public MouseClickEvent checkType = MouseClickEvent.MouseDown;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString(); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() { return false; }
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onMouseDown += OnMouseDown;
|
||||
router.onMouseUp += OnMouseUp;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onMouseDown -= OnMouseDown;
|
||||
router.onMouseUp -= OnMouseUp;
|
||||
}
|
||||
|
||||
void OnMouseDown(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseClickEvent.MouseDown ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseUp(ParadoxNotion.EventData msg) {
|
||||
if ( checkType == MouseClickEvent.MouseUp ) {
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 795d73b741d01894ab3c478b0b9cb17d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckMouseClick2D.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,120 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Description("The agent is type of Transform so that Triggers can either work with a Collider or a Rigidbody attached.")]
|
||||
[Name("Check Trigger")]
|
||||
public class CheckTrigger_Transform : ConditionTask<Transform>
|
||||
{
|
||||
|
||||
public TriggerTypes checkType = TriggerTypes.TriggerEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField, ShowIf("specifiedTagOnly", 1)]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
if ( checkType == TriggerTypes.TriggerStay ) { return stay; }
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onTriggerEnter += OnTriggerEnter;
|
||||
router.onTriggerExit += OnTriggerExit;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onTriggerEnter -= OnTriggerEnter;
|
||||
router.onTriggerExit -= OnTriggerExit;
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(ParadoxNotion.EventData<Collider> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == TriggerTypes.TriggerEnter || checkType == TriggerTypes.TriggerStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTriggerExit(ParadoxNotion.EventData<Collider> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == TriggerTypes.TriggerExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("System Events")]
|
||||
[DoNotList]
|
||||
public class CheckTrigger : ConditionTask<Collider>
|
||||
{
|
||||
|
||||
public TriggerTypes checkType = TriggerTypes.TriggerEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField, ShowIf("specifiedTagOnly", 1)]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return checkType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
if ( checkType == TriggerTypes.TriggerStay ) { return stay; }
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onTriggerEnter += OnTriggerEnter;
|
||||
router.onTriggerExit += OnTriggerExit;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onTriggerEnter -= OnTriggerEnter;
|
||||
router.onTriggerExit -= OnTriggerExit;
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(ParadoxNotion.EventData<Collider> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( checkType == TriggerTypes.TriggerEnter || checkType == TriggerTypes.TriggerStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTriggerExit(ParadoxNotion.EventData<Collider> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( checkType == TriggerTypes.TriggerExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5964e7589993864598940e1ba5a193a
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckTrigger.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,119 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Trigger 2D")]
|
||||
[Description("The agent is type of Transform so that Triggers can either work with a Collider or a Rigidbody attached.")]
|
||||
public class CheckTrigger2D_Transform : ConditionTask<Transform>
|
||||
{
|
||||
|
||||
public TriggerTypes CheckType = TriggerTypes.TriggerEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return CheckType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return CheckType == TriggerTypes.TriggerStay ? stay : false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onTriggerEnter2D += OnTriggerEnter2D;
|
||||
router.onTriggerExit2D += OnTriggerExit2D;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onTriggerEnter2D -= OnTriggerEnter2D;
|
||||
router.onTriggerExit2D -= OnTriggerExit2D;
|
||||
}
|
||||
|
||||
public void OnTriggerEnter2D(ParadoxNotion.EventData<Collider2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( CheckType == TriggerTypes.TriggerEnter || CheckType == TriggerTypes.TriggerStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTriggerExit2D(ParadoxNotion.EventData<Collider2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( CheckType == TriggerTypes.TriggerExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("System Events")]
|
||||
[Name("Check Trigger 2D")]
|
||||
[DoNotList]
|
||||
public class CheckTrigger2D : ConditionTask<Collider2D>
|
||||
{
|
||||
|
||||
public TriggerTypes CheckType = TriggerTypes.TriggerEnter;
|
||||
public bool specifiedTagOnly;
|
||||
[TagField]
|
||||
public string objectTag = "Untagged";
|
||||
[BlackboardOnly]
|
||||
public BBParameter<GameObject> saveGameObjectAs;
|
||||
|
||||
private bool stay;
|
||||
|
||||
protected override string info {
|
||||
get { return CheckType.ToString() + ( specifiedTagOnly ? ( " '" + objectTag + "' tag" ) : "" ); }
|
||||
}
|
||||
|
||||
protected override bool OnCheck() {
|
||||
return CheckType == TriggerTypes.TriggerStay ? stay : false;
|
||||
}
|
||||
|
||||
protected override void OnEnable() {
|
||||
router.onTriggerEnter2D += OnTriggerEnter2D;
|
||||
router.onTriggerExit2D += OnTriggerExit2D;
|
||||
}
|
||||
|
||||
protected override void OnDisable() {
|
||||
router.onTriggerEnter2D -= OnTriggerEnter2D;
|
||||
router.onTriggerExit2D -= OnTriggerExit2D;
|
||||
}
|
||||
|
||||
public void OnTriggerEnter2D(ParadoxNotion.EventData<Collider2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = true;
|
||||
if ( CheckType == TriggerTypes.TriggerEnter || CheckType == TriggerTypes.TriggerStay ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTriggerExit2D(ParadoxNotion.EventData<Collider2D> data) {
|
||||
if ( !specifiedTagOnly || data.value.gameObject.CompareTag(objectTag) ) {
|
||||
stay = false;
|
||||
if ( CheckType == TriggerTypes.TriggerExit ) {
|
||||
saveGameObjectAs.value = data.value.gameObject;
|
||||
YieldReturn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f8ef35cf4d8294eab04225beb6c878
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/SystemEvents/CheckTrigger2D.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user