CapersProject/Assets/02.Scripts/Character/Npc/Crew/Server/ServerCrew.cs

85 lines
2.6 KiB
C#
Raw Normal View History

2024-10-22 12:41:31 +00:00
using BlueWater.Interfaces;
using BlueWater.Npcs.Customers;
namespace BlueWater.Npcs.Crews.Server
{
2024-10-27 09:44:22 +00:00
public enum ActionType
{
None = 0,
Patrol,
TakeCocktail,
PlaceOnServingTable,
ServingToCustomer
}
2024-10-22 12:41:31 +00:00
public class ServerCrew : Crew
{
public Customer OrderedCustomer { get; private set; }
public IPickup CurrentPickupItem { get; private set; }
public bool IsServing { get; private set; }
2024-10-27 09:44:22 +00:00
public ActionType CurrentActionType { get; private set; }
2024-10-22 12:41:31 +00:00
public StateMachineController<ServerCrew> StateMachineController { get; private set; }
public IStateMachine<ServerCrew> IdleState { get; private set; }
public IStateMachine<ServerCrew> WalkingState { get; private set; }
public IStateMachine<ServerCrew> ServingState { get; private set; }
protected override void Update()
{
StateMachineController.UpdateState(this);
base.Update();
}
public override void Initialize()
{
2024-10-27 09:44:22 +00:00
CurrentActionType = ActionType.Patrol;
2024-10-22 12:41:31 +00:00
IdleState = new IdleState();
WalkingState = new WalkingState();
ServingState = new ServingState();
StateMachineController = new StateMachineController<ServerCrew>(this, IdleState);
base.Initialize();
}
public override void ResetMission()
{
2024-10-27 09:44:22 +00:00
CurrentActionType = ActionType.Patrol;
2024-10-22 12:41:31 +00:00
CrewInteraction = null;
IsOnMission = false;
BalloonUi.DiscardItem();
OrderedCustomer = null;
CurrentPickupItem = null;
IsServing = false;
}
public void CanNotServing()
{
CrewInteraction = null;
OrderedCustomer = null;
}
public override bool IsCompletedMission()
{
2024-10-31 05:41:13 +00:00
return !OrderedCustomer && CurrentPickupItem == null && !IsServing;
2024-10-22 12:41:31 +00:00
}
2024-10-27 09:44:22 +00:00
public void OnMission(ICrewInteraction crewInteraction, Customer orderedCustomer, ActionType actionType)
2024-10-22 12:41:31 +00:00
{
base.OnMission(crewInteraction);
OrderedCustomer = orderedCustomer;
2024-10-27 09:44:22 +00:00
CurrentActionType = actionType;
2024-10-22 12:41:31 +00:00
}
public void TakeFromServingTable(IPickup pickupItem, Customer orderedCustomer)
{
CurrentPickupItem = pickupItem;
OrderedCustomer = orderedCustomer;
CrewInteraction = OrderedCustomer;
BalloonUi.SetItemImage(CurrentPickupItem);
IsServing = true;
}
}
}