36 lines
956 B
C#
36 lines
956 B
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using BlueWater.Npcs.Customers;
|
|
using UnityEngine;
|
|
using Action = BehaviorDesigner.Runtime.Tasks.Action;
|
|
|
|
namespace BlueWater.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class Vomit : Action
|
|
{
|
|
private Customer _customer;
|
|
private bool _isVomiting;
|
|
private Vector3 _vomitingPosition;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (!_customer.AIMovement.HasReachedDestination()) return TaskStatus.Running;
|
|
|
|
if (!_isVomiting)
|
|
{
|
|
_customer.Vomit();
|
|
_isVomiting = true;
|
|
return TaskStatus.Running;
|
|
}
|
|
|
|
return _customer.IsVomited ? TaskStatus.Success : TaskStatus.Running;
|
|
}
|
|
}
|
|
} |