using AfterHours.Data;
using AfterHours.Economy;
using AfterHours.Interaction;
using Unity.Netcode;
using UnityEngine;
namespace AfterHours.Shop
{
///
/// Backroom-Terminal zum Nachbestellen eines festen Produkts beim
/// Großhandel. Produkt/Menge sind pro Instanz im Inspector konfiguriert.
///
public sealed class OrderTerminal : NetworkBehaviour, IInteractable
{
[SerializeField] private ProductCatalog _catalog;
[SerializeField] private int _productId = -1;
[SerializeField] private int _orderQuantity = 50;
public string GetPrompt(ulong clientId)
{
var product = _catalog.Get(_productId);
string name = product != null ? product.DisplayName : "?";
float cost = product != null ? product.WholesalePrice * _orderQuantity : 0f;
return $"{name} nachbestellen ({_orderQuantity} Stk. — {cost:0.00} €)";
}
/// Server: löst eine Bestellung beim SupplierService aus.
public void Interact(NetworkObject actor)
{
if (!IsServer) return;
SupplierService.Instance?.PlaceOrder(_productId, _orderQuantity);
}
}
}