feat : 맵 바운딩 박스 처리 / echo 패킷 구조 재 구성 / 더미 클라이언트 랜덤 이동 작업
This commit is contained in:
@@ -28,6 +28,9 @@ public class DummyClients
|
||||
private float dirX = 0f;
|
||||
private float dirZ = 0f;
|
||||
|
||||
// 맵 경계
|
||||
public MapBounds Map { get; set; } = new MapBounds(-50f, 50f, -50f, 50f);
|
||||
|
||||
// 통계
|
||||
public int SentCount
|
||||
{
|
||||
@@ -71,15 +74,6 @@ public class DummyClients
|
||||
|
||||
listener.NetworkReceiveEvent += (peer, reader, channel, deliveryMethod) =>
|
||||
{
|
||||
short code = reader.GetShort();
|
||||
short bodyLength = reader.GetShort();
|
||||
string? msg = reader.GetString();
|
||||
|
||||
if (msg != null)
|
||||
{
|
||||
RttCount++;
|
||||
}
|
||||
|
||||
ReceivedCount++;
|
||||
reader.Recycle();
|
||||
};
|
||||
@@ -104,8 +98,12 @@ public class DummyClients
|
||||
// 남은 거리가 없으면 새 방향·목표 거리 설정
|
||||
if (distance <= 0f)
|
||||
{
|
||||
// 현재 각도에서 -30~+30도 범위로 회전
|
||||
rotY = (rotY + Random.Shared.Next(-30, 31) + 360) % 360;
|
||||
// 벽에 붙어있으면 반대 방향 강제, 아니면 ±30도 회전
|
||||
int wallRotY = Map.GetRotYAwayFromWall(posX, posZ);
|
||||
rotY = wallRotY >= 0
|
||||
? (wallRotY + Random.Shared.Next(-30, 31) + 360) % 360
|
||||
: (rotY + Random.Shared.Next(-30, 31) + 360) % 360;
|
||||
|
||||
float rad = rotY * MathF.PI / 180f;
|
||||
dirX = MathF.Sin(rad);
|
||||
dirZ = MathF.Cos(rad);
|
||||
@@ -117,9 +115,14 @@ public class DummyClients
|
||||
|
||||
// 이번 틱 이동량 (남은 거리 초과 방지)
|
||||
float step = MathF.Min(moveSpeed * delta, distance);
|
||||
posX += dirX * step;
|
||||
posZ += dirZ * step;
|
||||
distance -= step;
|
||||
float nextX = posX + dirX * step;
|
||||
float nextZ = posZ + dirZ * step;
|
||||
|
||||
// 벽 충돌 시 clamp + 다음 틱에 방향 재설정
|
||||
bool hitWall = Map.Clamp(ref nextX, ref nextZ);
|
||||
posX = nextX;
|
||||
posZ = nextZ;
|
||||
distance = hitWall ? 0f : distance - step;
|
||||
|
||||
// 정수 Vector3 갱신
|
||||
position.X = (int)MathF.Round(posX);
|
||||
|
||||
Reference in New Issue
Block a user