You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
979 B
C#

using MalbersAnimations.Scriptables;
using UnityEngine;
namespace MalbersAnimations.Controller.AI
{
[CreateAssetMenu(menuName = "Malbers Animations/Pluggable AI/Tasks/Set Strafe")]
public class SetStrafeTask : MTask
{
public override string DisplayName => "Animal/Set Strafe";
void Reset() => Description = "Enable/Disable Strafing on the Animal Controller";
[Space, Tooltip("Apply the Task to the Animal(Self) or the Target(Target)")]
public Affected affect = Affected.Self;
public BoolReference strafe = new BoolReference(true);
public override void StartTask(MAnimalBrain brain, int index)
{
var animl = brain.Animal;
if (affect == Affected.Target) animl = brain.TargetAnimal;
if (animl) setStrafe(animl);
brain.TaskDone(index); //Set Done to this task
}
public void setStrafe(MAnimal animal) => animal.Strafe = strafe.Value;
}
}