feat : 초기 존 진입 / 채널 나갈시 존에서도 나가게 구현
This commit is contained in:
@@ -86,13 +86,16 @@ public class Channel : UserContainer
|
|||||||
|
|
||||||
public override void RemoveUser(int userId)
|
public override void RemoveUser(int userId)
|
||||||
{
|
{
|
||||||
base.RemoveUser(userId);
|
// 현재 맵에서 제거 (AMap.RemoveUser가 존까지 처리)
|
||||||
// 현재 맵에서도 제거
|
if (users.TryGetValue(userId, out Player? player))
|
||||||
if (maps.TryGetValue(userId, out AMap? currentMap))
|
|
||||||
{
|
{
|
||||||
currentMap.RemoveUser(userId);
|
if (maps.TryGetValue(player.CurrentMapId, out AMap? currentMap))
|
||||||
|
{
|
||||||
|
currentMap.RemoveUser(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base.RemoveUser(userId);
|
||||||
connectPeers.Remove(userId);
|
connectPeers.Remove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,12 +113,9 @@ public class Channel : UserContainer
|
|||||||
oldMap.RemoveUser(userId);
|
oldMap.RemoveUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AMap.AddUser가 존 0 배치 + CurrentZoneId = 0 처리
|
||||||
newMap.AddUser(userId, player);
|
newMap.AddUser(userId, player);
|
||||||
player.CurrentMapId = mapId;
|
player.CurrentMapId = mapId;
|
||||||
player.CurrentZoneId = 0;
|
|
||||||
|
|
||||||
// 현재 맵에 0번 존에 추가
|
|
||||||
GetMap(mapId)?.GetZone(0)?.AddUser(player.PlayerId, player);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,25 @@ public abstract class AMap : UserContainer
|
|||||||
return (row >= 0 && row < Rows && col >= 0 && col < Cols) ? row * Cols + col : -1;
|
return (row >= 0 && row < Rows && col >= 0 && col < Cols) ? row * Cols + col : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 맵 입장 시 0번 존에 자동 배치
|
||||||
|
public override void AddUser(int userId, Player player)
|
||||||
|
{
|
||||||
|
base.AddUser(userId, player);
|
||||||
|
player.CurrentZoneId = 0;
|
||||||
|
GetZone(0)?.AddUser(userId, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 맵 퇴장 시 현재 존에서 자동 제거
|
||||||
|
public override void RemoveUser(int userId)
|
||||||
|
{
|
||||||
|
if (users.TryGetValue(userId, out Player? player))
|
||||||
|
{
|
||||||
|
GetZone(player.CurrentZoneId)?.RemoveUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.RemoveUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
// 이동시 zone업데이트
|
// 이동시 zone업데이트
|
||||||
public bool UpdatePlayerZone(int userId, Player player)
|
public bool UpdatePlayerZone(int userId, Player player)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user