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