feat : 존 기능 초기 커밋

This commit is contained in:
qornwh1
2026-04-03 01:38:36 +09:00
parent 5221261d1e
commit 17ba88e841
15 changed files with 486 additions and 96 deletions

View File

@@ -0,0 +1,89 @@
using MMOserver.Game.Engine;
namespace MMOserver.Game.Channel.Maps.ZoneData;
/*
* 존 단위로 변경시킨다.
* 기존 맵 단위로 유저관리를 존 단위로 나눈다.
* 마을 존 / 전투 필드 존 타입을 분기 시킨다.
*/
public class Zone : UserContainer
{
public Zone(AMap map, int zoneId, int row, int col, Vector3 position, Vector3 size)
{
Map = new WeakReference<AMap>(map);
ZoneId = zoneId;
Row = row;
Col = col;
Position = position;
ZoneSize = size;
}
// Map은 약한참조를 들고 있는다 순환참조 방지
public WeakReference<AMap> Map
{
get;
private set;
}
// 그리드 인덱스 (zoneId = Row * Cols + Col)
public int ZoneId
{
get;
private set;
}
public int Row
{
get;
private set;
}
public int Col
{
get;
private set;
}
// 존 중심 좌표
public Vector3 Position
{
get;
private set;
}
// 존 사이즈
public Vector3 ZoneSize
{
get;
}
// 플레이어 위치 기준 현재 존 내 분면 반환
public int GetFourquadrant(Vector3 position)
{
float dx = position.X - Position.X;
float dz = position.Z - Position.Z;
// 중앙 영역 (존 크기의 1/4 이내) → 현재 존만 브로드캐스트
float threshold = ZoneSize.X / 4;
if (Math.Abs(dx) <= threshold && Math.Abs(dz) <= threshold)
{
return 0;
}
if (dx <= 0 && dz <= 0)
{
// 좌상단
return 1;
}
if (dx > 0 && dz <= 0)
{
// 우상단
return 2;
}
if (dx > 0 && dz > 0)
{
// 우하단
return 3;
}
// 좌하단
return 4;
}
}