네트워크 환경에서의 비정상 동작 수정

클라이언트 접속 전에 스폰되어 있는 오브젝트의 경우, Ownership이 Distributable일 경우 클라이언트 접속 시점에 Ownership을 호스트로부터 분배받는다.
서버만 데이터를 수정해야 하는 환경이기 때문에 대부분 Distributable 대신 None을 사용하면 된다.
This commit is contained in:
2026-02-17 01:53:06 +09:00
parent cc2487e7e4
commit 63a742d5d4
40 changed files with 582 additions and 316 deletions

View File

@@ -253,6 +253,7 @@ namespace Northbound
[Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)]
private void AssignOrGatherResourceServerRpc(ulong playerId, ulong resourceId)
{
if (!IsServer) return;
bool workerAssigned = false;
@@ -286,6 +287,14 @@ namespace Northbound
private void GatherResource(ulong playerId)
{
Debug.Log($"[Resource] GatherResource called - IsServer: {IsServer}, OwnerClientId: {OwnerClientId}, Current: {_currentResources.Value}");
if (!IsServer)
{
Debug.LogError($"[Resource] GatherResource called on CLIENT! This should not happen!");
return;
}
if (!CanInteract(playerId))
return;
@@ -315,18 +324,15 @@ namespace Northbound
ShowGatheringEffectClientRpc();
}
[Rpc(SendTo.ClientsAndHost)]
[Rpc(SendTo.Owner)]
private void UpdatePlayerResourcesClientRpc(ulong playerId)
{
var playerObject = NetworkManager.Singleton.ConnectedClients[playerId].PlayerObject;
if (playerObject != null)
{
var playerInventory = playerObject.GetComponent<PlayerResourceInventory>();
if (playerInventory != null)
{
playerInventory.RequestResourceUpdateServerRpc();
}
}
var playerObject = NetworkManager.Singleton.ConnectedClients[playerId]?.PlayerObject;
if (playerObject == null)
return;
var playerInventory = playerObject.GetComponent<PlayerResourceInventory>();
playerInventory?.RequestResourceUpdateServerRpc();
}
[Rpc(SendTo.NotServer)]