자원 오브젝트가 일꾼에게 자신이 가지고 있는 것 보다 많은 자원을 지급하는 문제 수정

This commit is contained in:
2026-02-02 20:44:02 +09:00
parent 958ae1cb75
commit 602cb2985c
3 changed files with 71 additions and 8 deletions

View File

@@ -78,21 +78,21 @@ namespace Northbound
return _currentWorkerId.Value == workerId;
}
public void TakeResourcesForWorker(int amount, ulong workerId)
public int TakeResourcesForWorker(int amount, ulong workerId)
{
if (!IsServer) return;
if (!IsServer) return 0;
if (!allowMultipleWorkers)
{
if (_currentWorkerId.Value != ulong.MaxValue && _currentWorkerId.Value != workerId)
return;
return 0;
}
int availableResources = _currentResources.Value;
int actualAmount = Mathf.Min(amount, availableResources);
if (actualAmount <= 0)
return;
return 0;
_currentResources.Value -= actualAmount;
_lastGatheringTime = Time.time;
@@ -108,6 +108,8 @@ namespace Northbound
}
ShowGatheringEffectClientRpc();
return actualAmount;
}
private NetworkVariable<int> _currentResources = new NetworkVariable<int>(