rrtur
This commit is contained in:
@@ -36,17 +36,24 @@ namespace AfterHours.Interaction
|
||||
|
||||
private void RefreshTarget()
|
||||
{
|
||||
var previous = _current;
|
||||
_current = null;
|
||||
CurrentPrompt = null;
|
||||
|
||||
if (!Physics.Raycast(_eyes.position, _eyes.forward, out var hit, _reach, _interactableMask))
|
||||
return;
|
||||
if (Physics.Raycast(_eyes.position, _eyes.forward, out var hit, _reach, _interactableMask)
|
||||
&& hit.collider.TryGetComponent<IInteractable>(out var interactable))
|
||||
{
|
||||
_current = interactable;
|
||||
CurrentPrompt = interactable.GetPrompt(OwnerClientId);
|
||||
}
|
||||
|
||||
if (!hit.collider.TryGetComponent<IInteractable>(out var interactable))
|
||||
return;
|
||||
|
||||
_current = interactable;
|
||||
CurrentPrompt = interactable.GetPrompt(OwnerClientId);
|
||||
// TODO: entfernen, sobald ein echter Prompt im UI angezeigt wird.
|
||||
if (_current != previous)
|
||||
{
|
||||
Debug.Log(_current != null
|
||||
? $"[PlayerInteractor] Ziel im Blick: {CurrentPrompt}"
|
||||
: "[PlayerInteractor] Kein Ziel mehr im Blick.");
|
||||
}
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Server)]
|
||||
|
||||
@@ -57,25 +57,46 @@ namespace AfterHours.Shop
|
||||
public void Interact(NetworkObject actor)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (!actor.TryGetComponent<PlayerHands>(out var hands) || hands.IsEmpty) return;
|
||||
|
||||
// TODO: Debug.Log-Zeilen entfernen, sobald Regal-Befüllen zuverlässig läuft.
|
||||
if (!actor.TryGetComponent<PlayerHands>(out var hands) || hands.IsEmpty)
|
||||
{
|
||||
Debug.Log("[ShelfSlot] Abbruch: keine PlayerHands am Actor oder Hände leer.");
|
||||
return;
|
||||
}
|
||||
|
||||
int incomingProductId = hands.ProductId;
|
||||
|
||||
// Fach ist mit anderer Ware belegt -> nichts tun.
|
||||
if (!IsEmpty && _productId.Value != hands.ProductId) return;
|
||||
if (!IsEmpty && _productId.Value != incomingProductId)
|
||||
{
|
||||
Debug.Log($"[ShelfSlot] Abbruch: Fach belegt mit ProductId {_productId.Value}, Hand trägt {incomingProductId}.");
|
||||
return;
|
||||
}
|
||||
|
||||
int free = Capacity() - _quantity.Value;
|
||||
if (free <= 0) return;
|
||||
if (free <= 0)
|
||||
{
|
||||
Debug.Log($"[ShelfSlot] Abbruch: Fach voll ({_quantity.Value}/{Capacity()}).");
|
||||
return;
|
||||
}
|
||||
|
||||
int moved = hands.TryGive(Mathf.Min(free, hands.Quantity));
|
||||
if (moved <= 0) return;
|
||||
if (moved <= 0)
|
||||
{
|
||||
Debug.Log("[ShelfSlot] Abbruch: TryGive() lieferte 0 Stück.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsEmpty)
|
||||
{
|
||||
_productId.Value = hands.ProductId >= 0 ? hands.ProductId : _productId.Value;
|
||||
_productId.Value = incomingProductId;
|
||||
var def = _catalog.Get(_productId.Value);
|
||||
if (def != null && _price.Value <= 0f) _price.Value = def.RecommendedPrice;
|
||||
}
|
||||
|
||||
_quantity.Value += moved;
|
||||
Debug.Log($"[ShelfSlot] Eingeräumt: {moved} Stück, jetzt {_quantity.Value}/{Capacity()}.");
|
||||
}
|
||||
|
||||
/// <summary>Server: Kunde entnimmt ein Stück.</summary>
|
||||
|
||||
Reference in New Issue
Block a user