45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using BehaviorDesigner.Runtime.Tasks;
|
|
using BlueWater.Npcs.Customers;
|
|
using BlueWater.Tycoons;
|
|
using UnityEngine;
|
|
using Action = BehaviorDesigner.Runtime.Tasks.Action;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace BlueWater.BehaviorTrees.Actions
|
|
{
|
|
[TaskCategory("Custom/Npc/Customer")]
|
|
[Serializable]
|
|
public class Vomit : Action
|
|
{
|
|
private Customer _customer;
|
|
private bool _isVomit;
|
|
private Vector3 _vomitingPosition;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
_customer = GetComponent<Customer>();
|
|
}
|
|
|
|
public override void OnStart()
|
|
{
|
|
var random = Random.Range(0f, 100f);
|
|
if (random <= TycoonManager.Instance.TycoonStageController.StageDataSo.VomitingPercent)
|
|
{
|
|
_isVomit = true;
|
|
_vomitingPosition = _customer.AIMovement.SetRandomPoint();
|
|
_customer.AIMovement.Move(_vomitingPosition);
|
|
}
|
|
}
|
|
|
|
public override TaskStatus OnUpdate()
|
|
{
|
|
if (!_isVomit) return TaskStatus.Success;
|
|
|
|
if (!_customer.AIMovement.HasReachedDestination()) return TaskStatus.Running;
|
|
|
|
_customer.Vomit();
|
|
return TaskStatus.Success;
|
|
}
|
|
}
|
|
} |