자원 오브젝트가 일꾼에게 자신이 가지고 있는 것 보다 많은 자원을 지급하는 문제 수정
This commit is contained in:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user