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

Commit d7053f7

Browse files
committed
Add AIActionRotateTowardsTarget2DNode.
1 parent b08c3cc commit d7053f7

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.AIActionRotateTowardsTarget2D"/> action.
10+
/// </summary>
11+
[CreateNodeMenu("AI/Action/2D/Rotate Towards Target")]
12+
public class AIActionRotateTowardsTarget2DNode : AIActionNode
13+
{
14+
15+
public bool lockRotationX = false;
16+
17+
public override AIAction AddActionComponent(GameObject go)
18+
{
19+
var action = go.AddComponent<AIActionRotateTowardsTarget2D>();
20+
action.Label = label;
21+
action.LockRotationX = lockRotationX;
22+
return action;
23+
}
24+
25+
}
26+
}

Common/Scripts/AI/Graph/Actions/AIActionRotateTowardsTarget2DNode.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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using TheBitCave.MMToolsExtensions.AI.Graph;
2+
using UnityEditor;
3+
using XNodeEditor;
4+
5+
namespace TheBitCave.TopDownEngineExensions.AI.Graph
6+
{
7+
[CustomNodeEditor(typeof(AIActionRotateTowardsTarget2DNode))]
8+
public class AIActionRotateTowardsTarget2DNodeEditor : AIActionNodeEditor
9+
{
10+
private SerializedProperty _lockRotationX;
11+
12+
protected override void SerializeAdditionalProperties()
13+
{
14+
_lockRotationX = serializedObject.FindProperty("lockRotationX");
15+
16+
serializedObject.Update();
17+
EditorGUIUtility.labelWidth = 200;
18+
NodeEditorGUILayout.PropertyField(_lockRotationX);
19+
serializedObject.ApplyModifiedProperties();
20+
}
21+
}
22+
}

Common/Scripts/AI/Graph/Actions/Editor/AIActionRotateTowardsTarget2DNodeEditor.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.

Common/Scripts/AI/Graph/Actions/Editor/AIActionRotateTowardsTarget3DNodeEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ protected override void SerializeAdditionalProperties()
1414
_lockRotationX = serializedObject.FindProperty("lockRotationX");
1515

1616
serializedObject.Update();
17+
EditorGUIUtility.labelWidth = 200;
1718
NodeEditorGUILayout.PropertyField(_lockRotationX);
1819
serializedObject.ApplyModifiedProperties();
1920
}

0 commit comments

Comments
 (0)