From ace25e108f598d67fd91badc353c2c75f1ee8095 Mon Sep 17 00:00:00 2001 From: marcosecchi Date: Fri, 31 Dec 2021 09:14:59 +0100 Subject: [PATCH] Add AIActionSelfDestructNode. --- .../Graph/Actions/AIActionSelfDestructNode.cs | 24 +++++++++++++++++++ .../Actions/AIActionSelfDestructNode.cs.meta | 11 +++++++++ .../AI/Graph/Actions/AIActionShootNode.cs | 1 - .../Editor/AIActionSelfDestructNodeEditor.cs | 23 ++++++++++++++++++ .../AIActionSelfDestructNodeEditor.cs.meta | 11 +++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs create mode 100644 Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs.meta create mode 100644 Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs create mode 100644 Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs.meta diff --git a/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs b/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs new file mode 100644 index 0000000..0f5e7a0 --- /dev/null +++ b/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs @@ -0,0 +1,24 @@ +using MoreMountains.CorgiEngine; +using MoreMountains.Tools; +using TheBitCave.MMToolsExtensions.AI.Graph; +using UnityEngine; + +namespace TheBitCave.CorgiExensions.AI.Graph +{ + /// + /// A node representing a Corgi action. + /// + [CreateNodeMenu("AI/Action/Self Destruct")] + public class AIActionSelfDestructNode : AIActionNode + { + public bool onlyRunOnce = true; + + public override AIAction AddActionComponent(GameObject go) + { + var action = go.AddComponent(); + action.Label = label; + action.OnlyRunOnce = onlyRunOnce; + return action; + } + } +} \ No newline at end of file diff --git a/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs.meta b/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs.meta new file mode 100644 index 0000000..902b79c --- /dev/null +++ b/Common/Scripts/Agents/AI/Graph/Actions/AIActionSelfDestructNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc8ecebfc3a8f894a84f449f5b2f74e2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Common/Scripts/Agents/AI/Graph/Actions/AIActionShootNode.cs b/Common/Scripts/Agents/AI/Graph/Actions/AIActionShootNode.cs index 979acf2..26c77f2 100644 --- a/Common/Scripts/Agents/AI/Graph/Actions/AIActionShootNode.cs +++ b/Common/Scripts/Agents/AI/Graph/Actions/AIActionShootNode.cs @@ -26,6 +26,5 @@ public override AIAction AddActionComponent(GameObject go) action.TargetHandleWeapon = targetHandleWeapon; return action; } - } } \ No newline at end of file diff --git a/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs b/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs new file mode 100644 index 0000000..956d257 --- /dev/null +++ b/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs @@ -0,0 +1,23 @@ +using MoreMountains.CorgiEngine; +using TheBitCave.MMToolsExtensions.AI.Graph; +using UnityEditor; +using XNodeEditor; + +namespace TheBitCave.CorgiExensions.AI.Graph +{ + [CustomNodeEditor(typeof(AIActionSelfDestructNode))] + public class AIActionSelfDestructNodeEditor : AIActionNodeEditor + { + private SerializedProperty _onlyRunOnce; + + protected override void SerializeAdditionalProperties() + { + _onlyRunOnce = serializedObject.FindProperty("onlyRunOnce"); + + serializedObject.Update(); + EditorGUIUtility.labelWidth = 200; + NodeEditorGUILayout.PropertyField(_onlyRunOnce); + serializedObject.ApplyModifiedProperties(); + } + } +} \ No newline at end of file diff --git a/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs.meta b/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs.meta new file mode 100644 index 0000000..de30cfd --- /dev/null +++ b/Common/Scripts/Agents/AI/Graph/Actions/Editor/AIActionSelfDestructNodeEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8db4825763819274cb0f6ec65f8681f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: