OldBlueWater/BlueWater/Assets/Behavior Designer Formations/Scripts/Tasks/Line.cs

33 lines
1.2 KiB
C#
Raw Normal View History

2023-09-26 06:12:44 +00:00
using UnityEngine;
using BehaviorDesigner.Runtime.Tasks;
using Tooltip = BehaviorDesigner.Runtime.Tasks.TooltipAttribute;
using HelpURL = BehaviorDesigner.Runtime.Tasks.HelpURLAttribute;
namespace BehaviorDesigner.Runtime.Formations.Tasks
{
[TaskCategory("Formations")]
[TaskDescription("Arrange the group in a straight horizontal line.")]
[TaskIcon("Assets/Behavior Designer Formations/Editor/Icons/{SkinColor}LineIcon.png")]
[HelpURL("https://www.opsive.com/support/documentation/behavior-designer-formations-pack/")]
public class Line : NavMeshFormationGroup
{
[Tooltip("The separation between agents")]
public SharedFloat separation = 2;
[Tooltip("Should the formation be to the right of the leader?")]
public SharedBool right;
protected override Vector3 TargetPosition(int index, float zLookAhead)
{
var leaderTransform = leader.Value == null ? transform : leader.Value.transform;
return leaderTransform.TransformPoint(separation.Value * index * (right.Value ? 1 : -1), 0, zLookAhead);
}
public override void OnReset()
{
base.OnReset();
separation = 2;
right = false;
}
}
}