85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using BlueWater.Interfaces;
|
|
using BlueWater.Npcs.Customers;
|
|
|
|
namespace BlueWater.Npcs.Crews.Server
|
|
{
|
|
public enum ActionType
|
|
{
|
|
None = 0,
|
|
Patrol,
|
|
TakeCocktail,
|
|
PlaceOnServingTable,
|
|
ServingToCustomer
|
|
}
|
|
|
|
public class ServerCrew : Crew
|
|
{
|
|
public Customer OrderedCustomer { get; private set; }
|
|
public IPickup CurrentPickupItem { get; private set; }
|
|
public bool IsServing { get; private set; }
|
|
public ActionType CurrentActionType { get; private set; }
|
|
|
|
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()
|
|
{
|
|
CurrentActionType = ActionType.Patrol;
|
|
IdleState = new IdleState();
|
|
WalkingState = new WalkingState();
|
|
ServingState = new ServingState();
|
|
|
|
StateMachineController = new StateMachineController<ServerCrew>(this, IdleState);
|
|
|
|
base.Initialize();
|
|
}
|
|
|
|
public override void ResetMission()
|
|
{
|
|
CurrentActionType = ActionType.Patrol;
|
|
|
|
CrewInteraction = null;
|
|
IsOnMission = false;
|
|
BalloonUi.DiscardItem();
|
|
|
|
OrderedCustomer = null;
|
|
CurrentPickupItem = null;
|
|
IsServing = false;
|
|
}
|
|
|
|
public void CanNotServing()
|
|
{
|
|
CrewInteraction = null;
|
|
OrderedCustomer = null;
|
|
}
|
|
|
|
public override bool IsCompletedMission()
|
|
{
|
|
return CrewInteraction == null && !OrderedCustomer && CurrentPickupItem == null && !IsServing;
|
|
}
|
|
|
|
public void OnMission(ICrewInteraction crewInteraction, Customer orderedCustomer, ActionType actionType)
|
|
{
|
|
base.OnMission(crewInteraction);
|
|
OrderedCustomer = orderedCustomer;
|
|
CurrentActionType = actionType;
|
|
}
|
|
|
|
public void TakeFromServingTable(IPickup pickupItem, Customer orderedCustomer)
|
|
{
|
|
CurrentPickupItem = pickupItem;
|
|
OrderedCustomer = orderedCustomer;
|
|
CrewInteraction = OrderedCustomer;
|
|
BalloonUi.SetItemImage(CurrentPickupItem);
|
|
IsServing = true;
|
|
}
|
|
}
|
|
} |