Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
김산 2025-09-01 18:03:21 +09:00
commit bfb24621a1
12 changed files with 107 additions and 22 deletions

View File

@ -167,7 +167,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 2
Data: 3
- Name:
Entry: 7
Data:
@ -192,6 +192,18 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 3
Data: 8
- Name: $v
Entry: 10
Data: 1
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:

View File

@ -148,8 +148,8 @@ Transform:
m_GameObject: {fileID: 4383536863636501606}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0.01}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalPosition: {x: 0, y: -0.05, z: 0.01}
m_LocalScale: {x: 1.1, y: 1.1, z: 1.1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 4689806172687901599}

View File

@ -11,7 +11,7 @@ public VirtualItem(string itemId)
_itemId = itemId;
}
public string GetCarrierId() => _itemId;
public string GetId() => _itemId;
public CarriableType GetCarriableType() => CarriableType.VirtualItem;
public GameObject GetGameObject() => null;

View File

@ -12,8 +12,9 @@ public enum CarriableType
public interface ICarrier
{
GameObject GetCarrierGameObject();
string GetCarrierId();
string GetCurrentCarriableId();
ICarriable GetCurrentCarriable();
bool IsCarrying();
bool CanCarryTo(ICarriable carriable);
void Carry(ICarriable carriable);
void Use(ICarriable carriable);
@ -21,7 +22,7 @@ public interface ICarrier
public interface ICarriable
{
string GetCarrierId();
string GetId();
CarriableType GetCarriableType();
void OnCarried(ICarrier carrier);
bool CanCarry();
@ -40,9 +41,9 @@ public GameObject GetCarrierGameObject()
return gameObject;
}
public string GetCarrierId()
public string GetCurrentCarriableId()
{
return _currentCarriable.GetCarrierId();
return _currentCarriable.GetId();
}
public ICarriable GetCurrentCarriable()
@ -50,6 +51,11 @@ public ICarriable GetCurrentCarriable()
return _currentCarriable;
}
public bool IsCarrying()
{
return GetCurrentCarriable() != null;
}
public bool CanCarryTo(ICarriable carriable)
{
if (_currentCarriable != null) return false;
@ -65,7 +71,7 @@ public void Carry(ICarriable carriable)
_currentCarriable.OnCarried(this);
_speechBubble ??= GetComponentInChildren<ISpeechBubble>();
_speechBubble?.Show(_currentCarriable.GetCarrierId());
_speechBubble?.Show(_currentCarriable.GetId());
}
public void Use(ICarriable carriable)

View File

@ -2,6 +2,7 @@
namespace DDD.Restaurant
{
[RequireComponent(typeof(CharacterCarrier))]
[RequireComponent(typeof(PlayerMovement))]
public class PlayerCharacter : RestaurantCharacter
{

View File

@ -21,6 +21,8 @@ public class RestaurantOrderObjectState
public string RecipeId;
public string FoodId;
public string ServedFoodId;
}
public class RestaurantOrderInterrupt : IEvent

View File

@ -16,6 +16,7 @@ public string MenuId
public class RestaurantOrderEvent : IEvent
{
public RestaurantOrderObjectState OrderObjectState;
public RestaurantOrderType OrderPhase;
}
public class RestaurantOrderSolver_Order : RestaurantOrderSolverBase
@ -53,8 +54,11 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera
RestaurantOrderMenuPayload orderPayload = ScriptableObject.CreateInstance<RestaurantOrderMenuPayload>();
orderPayload.MenuId = recipeMenu;
RestaurantOrderEvent evt = new RestaurantOrderEvent();
evt.OrderObjectState = orderObject?.GetOrderObjectState();
RestaurantOrderEvent evt = new RestaurantOrderEvent
{
OrderObjectState = orderObject?.GetOrderObjectState()
, OrderPhase = RestaurantOrderType.Order
};
EventBus.Broadcast(evt);
return base.ExecuteInteractionSubsystem(interactor, interactable, payload);

View File

@ -6,11 +6,40 @@ public class RestaurantOrderSolver_Serve : RestaurantOrderSolverBase
{
public override bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{
return base.ExecuteInteractionSubsystem(interactor, interactable, payload);
var carrier = interactor?.GetInteractorGameObject()?.GetComponent<ICarrier>();
if(carrier == null) return false;
var orderObject = GetRestaurantOrderObject(interactable);
if(orderObject == null) return false;
if(carrier.GetCurrentCarriable() == null) return false;
string carriedFoodId = carrier.GetCurrentCarriableId();
orderObject.GetOrderObjectState().ServedFoodId = carriedFoodId;
bool result = base.ExecuteInteractionSubsystem(interactor, interactable, payload);
// ExecuteInteractionSubsystem 이후에 음식 제거 - 미리 제거하면 CanExecute 통과 못 함
carrier.Use(carrier.GetCurrentCarriable());
// OnFoodServed (Consume Bill Hud item)
RestaurantOrderEvent evt = new RestaurantOrderEvent
{
OrderObjectState = orderObject?.GetOrderObjectState()
, OrderPhase = RestaurantOrderType.Serve
};
EventBus.Broadcast(evt);
return result;
}
public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{
// Does interactor carry any food?
var carrier = interactor?.GetInteractorGameObject()?.GetComponent<ICarrier>();
if (carrier != null)
{
return carrier.IsCarrying();
}
return false;
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@ -8,6 +9,7 @@ public class BillHud : MonoBehaviour, IEventHandler<RestaurantOrderEvent>
{
[SerializeField] private RectTransform _billItemsLayoutTransform;
[SerializeField] private GameObject _billItemPrefab;
private readonly Dictionary<GameObject, GameObject> _billItemMap = new();
private void Start()
{
@ -18,9 +20,24 @@ private void Start()
public void HandleEvent(RestaurantOrderEvent evt)
{
var billItem = Instantiate(_billItemPrefab, _billItemsLayoutTransform);
var sprite = DataManager.Instance.GetSprite(evt.OrderObjectState?.FoodId);
billItem.GetComponent<Image>().sprite = sprite;
if (evt.OrderPhase == RestaurantOrderType.Order)
{
var orderState = evt.OrderObjectState;
if (orderState == null) return;
var billItem = Instantiate(_billItemPrefab, _billItemsLayoutTransform);
var sprite = DataManager.Instance.GetSprite(orderState.FoodId);
billItem.GetComponent<Image>().sprite = sprite;
_billItemMap[orderState.Customer] = billItem;
}
else if (evt.OrderPhase == RestaurantOrderType.Serve)
{
// Find bill item by customer from _billItemMap, then destroy it.
if (_billItemMap.TryGetValue(evt.OrderObjectState.Customer, out var billItem))
{
Destroy(billItem);
_billItemMap.Remove(evt.OrderObjectState.Customer);
}
}
}
}
}

View File

@ -32,9 +32,8 @@ protected virtual void Initialize()
Debug.LogError($"Interaction Subsystem<{typeof(T)}> is not exist");
return;
}
// TODO: 임시 나중에 제대로 수정할 것
var uiGameObject = Instantiate(new GameObject("TemporaryUi"), transform);
var uiGameObject = Instantiate(new GameObject("PropWorldUi"), transform);
_spriteRenderer = uiGameObject.AddComponent<SpriteRenderer>();
UpdateSprite();
@ -67,7 +66,7 @@ private bool GetOwnerInteractable(out IInteractable interactable)
protected virtual int GetDisplayLayer()
{
return LayerMask.NameToLayer("WorldUI");
return LayerMask.NameToLayer(LayerConstants.WorldUi);
}
protected virtual Sprite GetDisplaySprite()

View File

@ -37,7 +37,11 @@ protected override void UpdateSpriteTransform()
protected override Sprite GetDisplaySprite()
{
if (GetCurrentInteractionType() == RestaurantOrderType.Serve && _interactionSubsystemObject != null)
if (_interactionSubsystemObject == null)
return base.GetDisplaySprite();
if (GetCurrentInteractionType() == RestaurantOrderType.Serve ||
GetCurrentInteractionType() == RestaurantOrderType.Busy)
{
// Sprite by current restaurant order type. get from RestaurantOrderObject.
if (_interactionSubsystemObject is IRestaurantOrderObject orderObject)
@ -76,9 +80,14 @@ protected override Vector3 GetDisplayPosition()
protected override int GetDisplayLayer()
{
if (GetCurrentInteractionType() == RestaurantOrderType.Serve)
if (GetCurrentInteractionType() != RestaurantOrderType.Serve &&
GetCurrentInteractionType() != RestaurantOrderType.Busy)
{
return LayerMask.NameToLayer("Prop");
return LayerMask.NameToLayer(LayerConstants.Prop);
}
else
{
return LayerMask.NameToLayer(LayerConstants.WorldUi);
}
return base.GetDisplayLayer();
}

View File

@ -66,4 +66,10 @@ public static class SpriteConstants
public const string EmptyFoodSpriteKey = "EmptyFood";
public const string EmptyWorker = "EmptyWorker";
}
public static class LayerConstants
{
public const string Prop = "Prop";
public const string WorldUi = "WorldUI";
}
}