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

86 lines
2.7 KiB
C#
Raw Normal View History

2025-02-10 02:13:46 +00:00
using DDD.Interfaces;
using DDD.Npcs.Customers;
2025-02-24 11:55:35 +00:00
using DDD.ScriptableObjects;
2024-10-22 12:41:31 +00:00
2025-02-10 02:13:46 +00:00
namespace DDD.Npcs.Crews.Server
2024-10-22 12:41:31 +00:00
{
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; }
2025-02-24 11:55:35 +00:00
public CraftRecipeData CurrentPickupItem { get; private set; }
2024-10-22 12:41:31 +00:00
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
}
2025-02-24 11:55:35 +00:00
public void TakeFromServingTable(CraftRecipeData pickupItem, Customer orderedCustomer)
2024-10-22 12:41:31 +00:00
{
CurrentPickupItem = pickupItem;
OrderedCustomer = orderedCustomer;
CrewInteraction = OrderedCustomer;
2025-02-24 11:55:35 +00:00
BalloonUi.SetItemImage(CurrentPickupItem.Sprite);
2024-10-22 12:41:31 +00:00
IsServing = true;
}
}
}