first commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Plays a 'Beep' in editor only")]
|
||||
public class DebugBeep : ActionTask
|
||||
{
|
||||
|
||||
protected override void OnExecute() {
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.Beep();
|
||||
#endif
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf30267370691f94dbb9ee73bc7c0db6
|
||||
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/Actions/Utility/DebugBeep.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,23 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
public class DebugDrawLine : ActionTask
|
||||
{
|
||||
|
||||
public BBParameter<Vector3> from;
|
||||
public BBParameter<Vector3> to;
|
||||
public Color color = Color.white;
|
||||
public float timeToShow = 0.1f;
|
||||
|
||||
protected override void OnExecute() {
|
||||
Debug.DrawLine(from.value, to.value, color, timeToShow);
|
||||
EndAction(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2480a88c988914a47840f2d8374b3adf
|
||||
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/Actions/Utility/DebugDrawLine.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,94 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Services;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Debug Log")]
|
||||
[Category("✫ Utility")]
|
||||
[Description("Display a UI label on the agent's position if seconds to run is not 0 and also logs the message, which can also be mapped to any variable.")]
|
||||
public class DebugLogText : ActionTask<Transform>
|
||||
{
|
||||
|
||||
public enum LogMode
|
||||
{
|
||||
Log,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
|
||||
public enum VerboseMode
|
||||
{
|
||||
LogAndDisplayLabel,
|
||||
LogOnly,
|
||||
DisplayLabelOnly,
|
||||
}
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<string> log = "Hello World";
|
||||
public float labelYOffset = 0;
|
||||
public float secondsToRun = 1f;
|
||||
public VerboseMode verboseMode;
|
||||
public LogMode logMode;
|
||||
public CompactStatus finishStatus = CompactStatus.Success;
|
||||
|
||||
protected override string info {
|
||||
get { return "Log " + log.ToString() + ( secondsToRun > 0 ? " for " + secondsToRun + " sec." : "" ); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
if ( verboseMode == VerboseMode.LogAndDisplayLabel || verboseMode == VerboseMode.LogOnly ) {
|
||||
var label = string.Format("(<b>{0}</b>) {1}", agent.gameObject.name, log.value);
|
||||
if ( logMode == LogMode.Log ) {
|
||||
ParadoxNotion.Services.Logger.Log(label, LogTag.EXECUTION, this);
|
||||
}
|
||||
if ( logMode == LogMode.Warning ) {
|
||||
ParadoxNotion.Services.Logger.LogWarning(label, LogTag.EXECUTION, this);
|
||||
}
|
||||
if ( logMode == LogMode.Error ) {
|
||||
ParadoxNotion.Services.Logger.LogError(label, LogTag.EXECUTION, this);
|
||||
}
|
||||
}
|
||||
if ( verboseMode == VerboseMode.LogAndDisplayLabel || verboseMode == VerboseMode.DisplayLabelOnly ) {
|
||||
if ( secondsToRun > 0 ) {
|
||||
MonoManager.current.onGUI += OnGUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnStop() {
|
||||
if ( verboseMode == VerboseMode.LogAndDisplayLabel || verboseMode == VerboseMode.DisplayLabelOnly ) {
|
||||
if ( secondsToRun > 0 ) {
|
||||
MonoManager.current.onGUI -= OnGUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= secondsToRun ) {
|
||||
EndAction(finishStatus == CompactStatus.Success ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
|
||||
void OnGUI() {
|
||||
if ( Camera.main == null ) { return; }
|
||||
var point = Camera.main.WorldToScreenPoint(agent.position + new Vector3(0, labelYOffset, 0));
|
||||
var size = GUI.skin.label.CalcSize(new GUIContent(log.value));
|
||||
var r = new Rect(point.x - size.x / 2, Screen.height - point.y, size.x + 10, size.y);
|
||||
GUI.color = Color.white.WithAlpha(0.5f);
|
||||
GUI.DrawTexture(r, Texture2D.whiteTexture);
|
||||
GUI.color = new Color(0.2f, 0.2f, 0.2f);
|
||||
r.x += 4;
|
||||
GUI.Label(r, log.value);
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a77a95fcaadf994fb2092927a22a96f
|
||||
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/Actions/Utility/DebugLogText.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,35 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Logs the value of a variable in the console")]
|
||||
[System.Obsolete("Use Debug Log Text")]
|
||||
public class DebugLogVariable : ActionTask
|
||||
{
|
||||
|
||||
[BlackboardOnly]
|
||||
public BBParameter<object> log;
|
||||
public BBParameter<string> prefix;
|
||||
public float secondsToRun = 1f;
|
||||
public CompactStatus finishStatus = CompactStatus.Success;
|
||||
|
||||
protected override string info {
|
||||
get { return "Log '" + log + "'" + ( secondsToRun > 0 ? " for " + secondsToRun + " sec." : "" ); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
ParadoxNotion.Services.Logger.Log(string.Format("<b>({0}) ({1}) | Var '{2}' = </b> {3}", agent.gameObject.name, prefix.value, log.name, log.value), LogTag.EXECUTION, this);
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= secondsToRun ) {
|
||||
EndAction(finishStatus == CompactStatus.Success ? true : false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70d9c927384463045955d248cf65d069
|
||||
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/Actions/Utility/DebugLogVariable.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,23 @@
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using NodeCanvas.Framework;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Force Finish the current graph this Task is assigned to.")]
|
||||
public class ForceFinishGraph : ActionTask
|
||||
{
|
||||
|
||||
public CompactStatus finishStatus = CompactStatus.Success;
|
||||
|
||||
protected override void OnExecute() {
|
||||
var graph = ownerSystem as Graph;
|
||||
if ( graph != null ) {
|
||||
graph.Stop(finishStatus == CompactStatus.Success);
|
||||
}
|
||||
EndAction(finishStatus == CompactStatus.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa28e93de05fec943aa6c17ddafdd5f9
|
||||
timeCreated: 1482234950
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Utility/ForceFinishGraph.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,67 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using System.Collections;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Name("Control Graph Owner")]
|
||||
[Category("✫ Utility")]
|
||||
[Description("Start, Resume, Pause, Stop a GraphOwner's behaviour")]
|
||||
public class GraphOwnerControl : ActionTask<GraphOwner>
|
||||
{
|
||||
|
||||
public enum Control
|
||||
{
|
||||
StartBehaviour,
|
||||
StopBehaviour,
|
||||
PauseBehaviour
|
||||
}
|
||||
|
||||
public Control control = Control.StartBehaviour;
|
||||
public bool waitActionFinish = true;
|
||||
|
||||
protected override string info {
|
||||
get { return agentInfo + "." + control.ToString(); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
|
||||
if ( control == Control.StartBehaviour ) {
|
||||
if ( waitActionFinish ) {
|
||||
agent.StartBehaviour((s) => { EndAction(s); });
|
||||
} else {
|
||||
agent.StartBehaviour();
|
||||
EndAction();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//in case target is this owner, we must yield 1 frame before pausing/stoppping
|
||||
if ( agent == ownerSystemAgent ) { StartCoroutine(YieldDo()); } else { Do(); }
|
||||
}
|
||||
|
||||
IEnumerator YieldDo() {
|
||||
yield return null;
|
||||
Do();
|
||||
}
|
||||
|
||||
void Do() {
|
||||
if ( control == Control.StopBehaviour ) {
|
||||
EndAction(null);
|
||||
agent.StopBehaviour();
|
||||
}
|
||||
|
||||
if ( control == Control.PauseBehaviour ) {
|
||||
EndAction(null);
|
||||
agent.PauseBehaviour();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnStop() {
|
||||
if ( waitActionFinish && control == Control.StartBehaviour ) {
|
||||
agent.StopBehaviour();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07354315bbc7d5746847f21393110809
|
||||
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/Actions/Utility/GraphOwnerControl.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NodeCanvas.Framework;
|
||||
using NodeCanvas.Framework.Internal;
|
||||
using ParadoxNotion.Design;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NodeCanvas.Tasks.Conditions
|
||||
{
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Invoke a defined Signal with agent as the target and optionally global.")]
|
||||
public class InvokeSignal : ActionTask<Transform>
|
||||
{
|
||||
public BBParameter<SignalDefinition> signalDefinition;
|
||||
public bool global;
|
||||
|
||||
[SerializeField]
|
||||
private Dictionary<string, BBObjectParameter> argumentsMap = new Dictionary<string, BBObjectParameter>();
|
||||
private object[] args;
|
||||
|
||||
protected override string info { get { return signalDefinition.ToString(); } }
|
||||
|
||||
protected override string OnInit() {
|
||||
if ( signalDefinition.isNoneOrNull ) { return "Missing Definition"; }
|
||||
args = new object[argumentsMap.Count];
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
var def = signalDefinition.value;
|
||||
for ( var i = 0; i < def.parameters.Count; i++ ) {
|
||||
args[i] = argumentsMap[def.parameters[i].ID].value;
|
||||
}
|
||||
def.Invoke(agent, agent, global, args);
|
||||
EndAction();
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
///---------------------------------------UNITY EDITOR-------------------------------------------
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnTaskInspectorGUI() {
|
||||
base.OnTaskInspectorGUI();
|
||||
if ( signalDefinition.isNoneOrNull ) { return; }
|
||||
var parameters = signalDefinition.value.parameters;
|
||||
EditorUtils.Separator();
|
||||
foreach ( var parameter in parameters ) {
|
||||
BBObjectParameter bbParam = null;
|
||||
if ( !argumentsMap.TryGetValue(parameter.ID, out bbParam) ) {
|
||||
bbParam = argumentsMap[parameter.ID] = new BBObjectParameter(parameter.type) { bb = ownerSystemBlackboard };
|
||||
}
|
||||
NodeCanvas.Editor.BBParameterEditor.ParameterField(parameter.name, bbParam);
|
||||
}
|
||||
|
||||
foreach ( var key in argumentsMap.Keys.ToArray() ) {
|
||||
if ( !parameters.Select(v => v.ID).Contains(key) ) {
|
||||
argumentsMap.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bdd91e4957b3d044a84ac07157bfd38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Utility/InvokeSignal.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,15 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
//Simple as that :P
|
||||
[Category("✫ Utility")]
|
||||
[Description("An action that will simply run forever and never finish")]
|
||||
public class RunForever : ActionTask
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0ea6de5e77e6c34aaf42d729709bb16
|
||||
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/Actions/Utility/RunForever.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,64 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
using ParadoxNotion.Services;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Send a graph event. If global is true, all graph owners in scene will receive this event. Use along with the 'Check Event' Condition")]
|
||||
public class SendEvent : ActionTask<GraphOwner>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<string> eventName;
|
||||
public BBParameter<float> delay;
|
||||
public bool sendGlobal;
|
||||
|
||||
protected override string info {
|
||||
get { return ( sendGlobal ? "Global " : "" ) + "Send Event [" + eventName + "]" + ( delay.value > 0 ? " after " + delay + " sec." : "" ); }
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= delay.value ) {
|
||||
if ( sendGlobal ) {
|
||||
Graph.SendGlobalEvent(eventName.value, null, this);
|
||||
} else {
|
||||
agent.SendEvent(eventName.value, null, this);
|
||||
}
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Send a graph event with T value. If global is true, all graph owners in scene will receive this event. Use along with the 'Check Event' Condition")]
|
||||
public class SendEvent<T> : ActionTask<GraphOwner>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<string> eventName;
|
||||
public BBParameter<T> eventValue;
|
||||
public BBParameter<float> delay;
|
||||
public bool sendGlobal;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("{0} Event [{1}] ({2}){3}", ( sendGlobal ? "Global " : "" ), eventName, eventValue, ( delay.value > 0 ? " after " + delay + " sec." : "" )); }
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= delay.value ) {
|
||||
if ( sendGlobal ) {
|
||||
Graph.SendGlobalEvent(eventName.value, eventValue.value, this);
|
||||
} else {
|
||||
agent.SendEvent(eventName.value, eventValue.value, this);
|
||||
}
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 990daf97a34481644b9a67d3ce07e2a1
|
||||
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/Actions/Utility/SendEvent.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Send a Graph Event to multiple gameobjects which should have a GraphOwner component attached.")]
|
||||
public class SendEventToObjects : ActionTask
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<List<GameObject>> targetObjects;
|
||||
[RequiredField]
|
||||
public BBParameter<string> eventName;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Send Event [{0}] to {1}", eventName, targetObjects); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
foreach ( var target in targetObjects.value ) {
|
||||
if ( target != null ) {
|
||||
var owner = target.GetComponent<GraphOwner>();
|
||||
if ( owner != null ) {
|
||||
owner.SendEvent(eventName.value, null, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Send a Graph Event to multiple gameobjects which should have a GraphOwner component attached.")]
|
||||
public class SendEventToObjects<T> : ActionTask
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<List<GameObject>> targetObjects;
|
||||
[RequiredField]
|
||||
public BBParameter<string> eventName;
|
||||
public BBParameter<T> eventValue;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Send Event [{0}]({1}) to {2}", eventName, eventValue, targetObjects); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
foreach ( var target in targetObjects.value ) {
|
||||
var owner = target.GetComponent<GraphOwner>();
|
||||
if ( owner != null ) {
|
||||
owner.SendEvent(eventName.value, eventValue.value, this);
|
||||
}
|
||||
}
|
||||
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e8b0c77eef74d0469b73fa0c32737cd
|
||||
timeCreated: 1470493313
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Utility/SendEventToObjects.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Sends an event to all GraphOwners within range of the agent and over time like a shockwave.")]
|
||||
public class ShoutEvent : ActionTask<Transform>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<string> eventName;
|
||||
public BBParameter<float> shoutRange = 10;
|
||||
public BBParameter<float> completionTime = 1;
|
||||
|
||||
private GraphOwner[] owners;
|
||||
private bool[] receivedOwners;
|
||||
private float traveledDistance;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Shout Event [{0}]", eventName.ToString()); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
owners = Object.FindObjectsByType<GraphOwner>(FindObjectsSortMode.None);
|
||||
receivedOwners = new bool[owners.Length];
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
traveledDistance = Mathf.Lerp(0, shoutRange.value, elapsedTime / completionTime.value);
|
||||
for ( var i = 0; i < owners.Length; i++ ) {
|
||||
var owner = owners[i];
|
||||
var distance = ( agent.position - owner.transform.position ).magnitude;
|
||||
if ( distance <= traveledDistance && receivedOwners[i] == false ) {
|
||||
owner.SendEvent(eventName.value, null, this);
|
||||
receivedOwners[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( elapsedTime >= completionTime.value ) {
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDrawGizmosSelected() {
|
||||
if ( agent != null ) {
|
||||
Gizmos.color = new Color(1, 1, 1, 0.2f);
|
||||
Gizmos.DrawWireSphere(agent.position, traveledDistance);
|
||||
Gizmos.DrawWireSphere(agent.position, shoutRange.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb8600dab96bbb147a2d5ff1ce3bea26
|
||||
timeCreated: 1429020032
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Utility/ShoutEvent.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,44 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using NodeCanvas.BehaviourTrees;
|
||||
using NodeCanvas.StateMachines;
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Switch the entire Behaviour Tree of BehaviourTreeOwner")]
|
||||
public class SwitchBehaviourTree : ActionTask<BehaviourTreeOwner>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<BehaviourTree> behaviourTree;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Switch Behaviour {0}", behaviourTree); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
agent.SwitchBehaviour(behaviourTree.value);
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("✫ Utility")]
|
||||
[Description("Switch the entire FSM of FSMTreeOwner")]
|
||||
public class SwitchFSM : ActionTask<FSMOwner>
|
||||
{
|
||||
|
||||
[RequiredField]
|
||||
public BBParameter<FSM> fsm;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Switch FSM {0}", fsm); }
|
||||
}
|
||||
|
||||
protected override void OnExecute() {
|
||||
agent.SwitchBehaviour(fsm.value);
|
||||
EndAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24099ada50558fd4eab859e6acedb8c7
|
||||
timeCreated: 1475807372
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Utility/SwitchBehaviour.cs
|
||||
uploadId: 704937
|
||||
@@ -0,0 +1,26 @@
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using ParadoxNotion.Design;
|
||||
|
||||
|
||||
namespace NodeCanvas.Tasks.Actions
|
||||
{
|
||||
|
||||
[Category("✫ Utility")]
|
||||
public class Wait : ActionTask
|
||||
{
|
||||
|
||||
public BBParameter<float> waitTime = 1f;
|
||||
public CompactStatus finishStatus = CompactStatus.Success;
|
||||
|
||||
protected override string info {
|
||||
get { return string.Format("Wait {0} sec.", waitTime); }
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( elapsedTime >= waitTime.value ) {
|
||||
EndAction(finishStatus == CompactStatus.Success ? true : false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36e14e9d9a7456345a25565776e0ed4b
|
||||
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/Actions/Utility/Wait.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user