first commit

This commit is contained in:
Chris
2025-03-12 14:22:16 -04:00
commit 0ad0c01249
1999 changed files with 189708 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using ParadoxNotion;
using Logger = ParadoxNotion.Services.Logger;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Check if an event is received and return true for one frame")]
public class CheckEvent : ConditionTask<GraphOwner>
{
[RequiredField]
public BBParameter<string> eventName;
protected override string info { get { return "[" + eventName.ToString() + "]"; } }
protected override void OnEnable() { router.onCustomEvent += OnCustomEvent; }
protected override void OnDisable() { router.onCustomEvent -= OnCustomEvent; }
protected override bool OnCheck() { return false; }
void OnCustomEvent(string eventName, IEventData data) {
if ( eventName.Equals(this.eventName.value, System.StringComparison.OrdinalIgnoreCase) ) {
Logger.Log(string.Format("Event Received from ({0}): '{1}'", agent.gameObject.name, name), LogTag.EVENT, this);
YieldReturn(true);
}
}
}
///----------------------------------------------------------------------------------------------
[Category("✫ Utility")]
[Description("Check if an event is received and return true for one frame. Optionaly save the received event's value")]
public class CheckEvent<T> : ConditionTask<GraphOwner>
{
[RequiredField]
public BBParameter<string> eventName;
[BlackboardOnly]
public BBParameter<T> saveEventValue;
protected override string info { get { return string.Format("Event [{0}]\n{1} = EventValue", eventName, saveEventValue); } }
protected override void OnEnable() { router.onCustomEvent += OnCustomEvent; }
protected override void OnDisable() { router.onCustomEvent -= OnCustomEvent; }
protected override bool OnCheck() { return false; }
void OnCustomEvent(string eventName, IEventData data) {
if ( eventName.Equals(this.eventName.value, System.StringComparison.OrdinalIgnoreCase) ) {
if ( data is EventData<T> ) { //avoid boxing if able
saveEventValue.value = ( (EventData<T>)data ).value;
} else if ( data.valueBoxed is T ) { saveEventValue.value = (T)data.valueBoxed; }
Logger.Log(string.Format("Event Received from ({0}): '{1}'", agent.gameObject.name, eventName), LogTag.EVENT, this);
YieldReturn(true);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: c31233ec6c59c464ab7bdd22779f353d
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/Utility/CheckEvent.cs
uploadId: 704937

View File

@@ -0,0 +1,36 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using Logger = ParadoxNotion.Services.Logger;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Check if an event is received and it's value is equal to specified value, then return true for one frame")]
public class CheckEventValue<T> : ConditionTask<GraphOwner>
{
[RequiredField]
public BBParameter<string> eventName;
[Name("Compare Value To")]
public BBParameter<T> value;
protected override string info { get { return string.Format("Event [{0}].value == {1}", eventName, value); } }
protected override void OnEnable() { router.onCustomEvent += OnCustomEvent; }
protected override void OnDisable() { router.onCustomEvent -= OnCustomEvent; }
protected override bool OnCheck() { return false; }
void OnCustomEvent(string eventName, ParadoxNotion.IEventData msg) {
if ( eventName.Equals(this.eventName.value, System.StringComparison.OrdinalIgnoreCase) ) {
var receivedValue = msg.valueBoxed;
if ( ObjectUtils.AnyEquals(receivedValue, value.value) ) {
Logger.Log(string.Format("Event Received from ({0}): '{1}'", agent.gameObject.name, eventName), LogTag.EVENT, this);
YieldReturn(true);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 0e2b345c804c7e34bad70dc7cfa41194
timeCreated: 1463673539
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/Conditions/Utility/CheckEventValue.cs
uploadId: 704937

View File

@@ -0,0 +1,74 @@
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("Check for an invoked Signal with agent as the target. If Signal was invoked as global, then the target does not matter.")]
public class CheckSignal : ConditionTask<Transform>
{
public BBParameter<SignalDefinition> signalDefinition;
[SerializeField]
private Dictionary<string, BBObjectParameter> argumentsMap = new Dictionary<string, BBObjectParameter>();
protected override string info { get { return signalDefinition.ToString(); } }
protected override string OnInit() {
if ( signalDefinition.isNoneOrNull ) { return "Missing Definition"; }
return null;
}
protected override void OnEnable() {
signalDefinition.value.onInvoke -= OnSignalInvoke;
signalDefinition.value.onInvoke += OnSignalInvoke;
}
protected override void OnDisable() {
signalDefinition.value.onInvoke -= OnSignalInvoke;
}
void OnSignalInvoke(Transform sender, Transform receiver, bool isGlobal, params object[] args) {
if ( receiver == agent || isGlobal ) {
var def = signalDefinition.value;
for ( var i = 0; i < args.Length; i++ ) {
argumentsMap[def.parameters[i].ID].value = args[i];
}
YieldReturn(true);
}
}
protected override bool OnCheck() { return false; }
///----------------------------------------------------------------------------------------------
///---------------------------------------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) { useBlackboard = true, bb = ownerSystemBlackboard };
}
NodeCanvas.Editor.BBParameterEditor.ParameterField(parameter.name, bbParam, true);
}
foreach ( var key in argumentsMap.Keys.ToArray() ) {
if ( !parameters.Select(v => v.ID).Contains(key) ) {
argumentsMap.Remove(key);
}
}
}
#endif
///----------------------------------------------------------------------------------------------
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dd31d4c07ba42964da782ef591a6d7f0
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/Conditions/Utility/CheckSignal.cs
uploadId: 704937

View File

@@ -0,0 +1,28 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using NodeCanvas.StateMachines;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Check the parent state status. This condition is only meant to be used along with an FSM system.")]
public class CheckStateStatus : ConditionTask
{
public CompactStatus status = CompactStatus.Success;
protected override string info {
get { return string.Format("State == {0}", status); }
}
protected override bool OnCheck() {
var fsm = ownerSystem as FSM;
if ( fsm != null ) {
var state = fsm.currentState;
return (int)state.status == (int)status;
}
return false;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6c9375f5ddabcc94fbabad84750284fd
timeCreated: 1487877106
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/Conditions/Utility/CheckStateStatus.cs
uploadId: 704937

View File

@@ -0,0 +1,30 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Simply use to debug return true or false by inverting the condition if needed")]
public class DebugCondition : ConditionTask
{
protected override bool OnCheck() {
return false;
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( UnityEngine.Application.isPlaying && UnityEngine.GUILayout.Button("Tick True") ) {
YieldReturn(true);
}
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: c13768b0c1c23994fbaa7af40a4dbeb7
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/Utility/DebugCondition.cs
uploadId: 704937

View File

@@ -0,0 +1,31 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Return true or false based on the probability settings. The chance is rolled for once whenever the condition is enabled.")]
public class Probability : ConditionTask
{
public BBParameter<float> probability = 0.5f;
public BBParameter<float> maxValue = 1;
private bool success;
protected override string info {
get { return ( probability.value / maxValue.value * 100 ) + "%"; }
}
protected override void OnEnable() {
success = Random.Range(0f, maxValue.value) <= probability.value;
}
protected override bool OnCheck() {
return success;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: d77aeefc417c40d42aa53a93d6897d89
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/Utility/Probability.cs
uploadId: 704937

View File

@@ -0,0 +1,27 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Will return true after a specific amount of time has passed and false while still counting down")]
public class Timeout : ConditionTask
{
public BBParameter<float> timeout = 1f;
private float startTime;
private float elapsedTime => ownerSystem.elapsedTime - startTime;
protected override string info {
get { return string.Format("Timeout {0}/{1}", elapsedTime.ToString("0.00"), timeout.ToString()); }
}
protected override void OnEnable() {
startTime = ownerSystem.elapsedTime;
}
protected override bool OnCheck() {
return elapsedTime >= timeout.value;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: a48f492380bb20044b000780f8189ee5
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/Utility/Timeout.cs
uploadId: 704937