90 lines
5.7 KiB
Markdown
90 lines
5.7 KiB
Markdown
## <img src="https://api.iconify.design/lucide/globe.svg?color=%2333CCFF" width="28" height="28" style="vertical-align: middle;"> Kiến trúc Mạng (Advanced Netcode Architecture)
|
|
|
|
> Để đảm bảo tính công bằng trong một tựa game mang nặng yếu tố hành động lén lút và phản xạ ngàn cân treo sợi tóc, **BABA_YAGA** sử dụng **Photon Fusion (State Sync)** làm lõi đồng bộ. Hệ thống được tinh chỉnh để mô phỏng cảm giác "Độ trễ bằng 0" (Zero-Latency Feel) thông qua kiến trúc mạng tất định (Deterministic Network).
|
|
|
|
<br>
|
|
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border: none;">
|
|
<tr style="border: none;">
|
|
<td width="33%" align="center" style="border: none; padding: 15px; background: rgba(51,204,255,0.05); border-radius: 8px 0 0 8px; border-bottom: 2px solid rgba(51,204,255,0.3);">
|
|
<img src="https://api.iconify.design/lucide/fast-forward.svg?color=%2333CCFF" width="28" height="28" />
|
|
<br><br>
|
|
<strong style="color: #E0E0E0;">Client-Side Prediction</strong>
|
|
<br>
|
|
<p style="font-size: 13px; color: #999; margin-top: 5px;">Mô phỏng trước các chuyển động của người chơi trên Local Client, loại bỏ hoàn toàn độ trễ Input Delay khi di chuyển hoặc lướt.</p>
|
|
</td>
|
|
<td width="33%" align="center" style="border: none; padding: 15px; background: rgba(255,51,51,0.05); border-bottom: 2px solid rgba(255,51,51,0.3);">
|
|
<img src="https://api.iconify.design/lucide/shield-check.svg?color=%23FF3333" width="28" height="28" />
|
|
<br><br>
|
|
<strong style="color: #E0E0E0;">Server Authority</strong>
|
|
<br>
|
|
<p style="font-size: 13px; color: #999; margin-top: 5px;">Máy chủ nắm quyền quyết định cuối cùng. Ngăn chặn triệt để các hành vi gian lận như Speedhack, Teleport hay thao túng Hitbox.</p>
|
|
</td>
|
|
<td width="33%" align="center" style="border: none; padding: 15px; background: rgba(255,215,0,0.05); border-radius: 0 8px 8px 0; border-bottom: 2px solid rgba(255,215,0,0.3);">
|
|
<img src="https://api.iconify.design/lucide/history.svg?color=%23FFD700" width="28" height="28" />
|
|
<br><br>
|
|
<strong style="color: #E0E0E0;">Lag Compensation</strong>
|
|
<br>
|
|
<p style="font-size: 13px; color: #999; margin-top: 5px;">Rewind trạng thái Hitbox trên Server về đúng thời điểm Client thực hiện thao tác (Ping), đảm bảo tính chính xác cho các cú vồ/bẫy.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
|
|
### <img src="https://api.iconify.design/lucide/workflow.svg?color=%23E0E0E0" width="22" height="22" style="vertical-align: middle;"> Vòng xoay Dữ liệu Mạng (Network Data Flow Pipeline)
|
|
|
|
> Biểu đồ dưới đây mô tả luồng xử lý thông tin tại mỗi **Tick (Khung hình mạng)**. Việc phân tách rõ ràng giữa *Logical State* (trạng thái mạng) và *Visual Presentation* (hiển thị hình ảnh) giúp khung hình của game (FPS) không bị khóa vào Tickrate của Server.
|
|
|
|
*(Lưu ý: Các trích xuất HTML trong sơ đồ đã được chuẩn hóa để tương thích hoàn toàn với bộ phân tích Markdown)*
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
autonumber
|
|
|
|
%% Khai báo các thực thể
|
|
participant IR as <img src='https://api.iconify.design/lucide/mouse-pointer-2.svg?color=%23FFD700' width='20' style='vertical-align: middle;'> Input
|
|
participant CP as <img src='https://api.iconify.design/lucide/monitor.svg?color=%2333CCFF' width='20' style='vertical-align: middle;'> Local Client
|
|
participant NT as <img src='https://api.iconify.design/lucide/router.svg?color=%23E0E0E0' width='20' style='vertical-align: middle;'> Fusion Net
|
|
participant S as <img src='https://api.iconify.design/lucide/server.svg?color=%23FF3333' width='20' style='vertical-align: middle;'> Server Auth
|
|
participant RP as <img src='https://api.iconify.design/lucide/ghost.svg?color=%23888888' width='20' style='vertical-align: middle;'> Proxies
|
|
|
|
%% --- GIAI ĐOẠN 1 ---
|
|
Note over IR, CP: [PHASE 1] Data Sampling (Thu thập)
|
|
IR->>CP: Hành động (Move / Ability / Interact)
|
|
CP->>CP: Đóng gói NetworkInputStruct
|
|
|
|
%% --- GIAI ĐOẠN 2 ---
|
|
Note over CP: [PHASE 2] Client Prediction (Dự đoán)
|
|
CP->>CP: Thực thi Physics & Kinematics tức thì (Tick N)
|
|
CP->>NT: Transmit Input Payload (Gửi lên mạng)
|
|
|
|
%% --- GIAI ĐOẠN 3 ---
|
|
Note over NT, S: [PHASE 3] Server Validation (Xác thực)
|
|
NT->>S: UDP Reliable Packet Delivery
|
|
Note right of S: SERVER TICK SIMULATION
|
|
S->>S: Validate Ruleset & Apply Physics State
|
|
S-->>NT: Broadcast Global State Snapshot (Tick N)
|
|
|
|
%% --- GIAI ĐOẠN 4 ---
|
|
Note over NT, CP: [PHASE 4] Reconciliation (Điều chỉnh bù trừ)
|
|
NT-->>CP: Nhận State Snapshot Feed
|
|
Note over CP: ERROR CORRECTION PROTOCOL
|
|
CP->>CP: Detect Desync -> Snap Transform -> Resimulate Ticks
|
|
|
|
%% --- GIAI ĐOẠN 5 ---
|
|
Note over NT, RP: [PHASE 5] Proxy Update (Cập nhật thực thể bên thứ 3)
|
|
NT-->>RP: Nhận State Snapshot Feed
|
|
Note over RP: NETWORK INTERPOLATION
|
|
RP->>RP: Lerp Position/Rotation (Bù nội suy mượt mà)
|
|
|
|
%% --- GIAI ĐOẠN 6 ---
|
|
Note over CP, RP: [PHASE 6] Visual Render (Hiển thị)
|
|
CP->>CP: Trigger Camera Shake / Local VFX
|
|
RP->>RP: Cập nhật Animation Parameters & Mesh
|
|
|
|
<div align="right">
|
|
<img src="https://api.iconify.design/lucide/activity-square.svg?color=%23555555" width="14" style="vertical-align: middle;">
|
|
<small><i>Hệ thống được thiết lập chạy ở <b>60 Ticks/Second</b>, băng thông ước tính <b><10kb/s</b> mỗi Client.</i></small>
|
|
</div>
|
|
``` |