Skip to content
This repository was archived by the owner on Apr 3, 2022. It is now read-only.

Commit cb8c5fe

Browse files
committed
Add AIActionMoveAwayFromTarget2D and AIActionMoveAwayFromTarget3D nodes.
1 parent b42b725 commit cb8c5fe

8 files changed

+140
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using MoreMountains.TopDownEngine;
2+
using MoreMountains.Tools;
3+
using TheBitCave.MMToolsExtensions.AI.Graph;
4+
using UnityEngine;
5+
6+
namespace TheBitCave.TopDownEngineExensions.AI.Graph
7+
{
8+
/// <summary>
9+
/// A node representing a TopDown Engine <see cref="MoreMountains.TopDownEngine.AIActionMoveAwayFromTarget2D"/> action.
10+
/// </summary>
11+
[CreateNodeMenu("AI/Action/2D/Move Away From Target")]
12+
public class AIActionMoveAwayFromTarget2DNode : AIActionNode
13+
{
14+
public float maximumDistance = 5.0f;
15+
16+
public override AIAction AddActionComponent(GameObject go)
17+
{
18+
var action = go.AddComponent<AIActionMoveAwayFromTarget2D>();
19+
action.Label = label;
20+
action.MaximumDistance = maximumDistance;
21+
22+
return action;
23+
}
24+
}
25+
}

Common/Scripts/AI/Graph/Actions/AIActionMoveAwayFromTarget2DNode.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using MoreMountains.TopDownEngine;
2+
using MoreMountains.Tools;
3+
using TheBitCave.MMToolsExtensions.AI.Graph;
4+
using UnityEngine;
5+
6+
namespace TheBitCave.TopDownEngineExensions.AI.Graph
7+
{
8+
/// <summary>
9+
/// A node representing a TopDown Engine <see cref="MoreMountains.TopDownEngine.AIActionMoveAwayFromTarget3D"/> action.
10+
/// </summary>
11+
[CreateNodeMenu("AI/Action/3D/Move Away From Target")]
12+
public class AIActionMoveAwayFromTarget3DNode : AIActionNode
13+
{
14+
public float maximumDistance = 10.0f;
15+
16+
public override AIAction AddActionComponent(GameObject go)
17+
{
18+
var action = go.AddComponent<AIActionMoveAwayFromTarget3D>();
19+
action.Label = label;
20+
action.MaximumDistance = maximumDistance;
21+
22+
return action;
23+
}
24+
}
25+
}

Common/Scripts/AI/Graph/Actions/AIActionMoveAwayFromTarget3DNode.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using TheBitCave.MMToolsExtensions.AI.Graph;
2+
using UnityEditor;
3+
using UnityEngine;
4+
using XNodeEditor;
5+
6+
namespace TheBitCave.TopDownEngineExensions.AI.Graph
7+
{
8+
[CustomNodeEditor(typeof(AIActionMoveAwayFromTarget2DNode))]
9+
public class AIActionMoveAwayFromTarget2DNodeEditor : AIActionNodeEditor
10+
{
11+
private SerializedProperty _maximumDistance;
12+
13+
protected override void SerializeAdditionalProperties()
14+
{
15+
_maximumDistance = serializedObject.FindProperty("maximumDistance");
16+
17+
serializedObject.Update();
18+
EditorGUIUtility.labelWidth = 150;
19+
NodeEditorGUILayout.PropertyField(_maximumDistance);
20+
serializedObject.ApplyModifiedProperties();
21+
}
22+
}
23+
}

Common/Scripts/AI/Graph/Actions/Editor/AIActionMoveAwayFromTarget2DNodeEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using TheBitCave.MMToolsExtensions.AI.Graph;
2+
using UnityEditor;
3+
using UnityEngine;
4+
using XNodeEditor;
5+
6+
namespace TheBitCave.TopDownEngineExensions.AI.Graph
7+
{
8+
[CustomNodeEditor(typeof(AIActionMoveAwayFromTarget3DNode))]
9+
public class AIActionMoveAwayFromTarget3DNodeEditor : AIActionNodeEditor
10+
{
11+
private SerializedProperty _maximumDistance;
12+
13+
protected override void SerializeAdditionalProperties()
14+
{
15+
_maximumDistance = serializedObject.FindProperty("maximumDistance");
16+
17+
serializedObject.Update();
18+
EditorGUIUtility.labelWidth = 150;
19+
NodeEditorGUILayout.PropertyField(_maximumDistance);
20+
serializedObject.ApplyModifiedProperties();
21+
}
22+
}
23+
}

Common/Scripts/AI/Graph/Actions/Editor/AIActionMoveAwayFromTarget3DNodeEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)