5.7 KiB
5.7 KiB
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).
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)
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>