Update REAME

This commit is contained in:
2026-04-08 12:20:26 +07:00
parent 7cb68fdca2
commit 13d271ded4

183
README.md
View File

@@ -140,108 +140,106 @@ Hệ thống điều khiển nhân vật không chỉ quản lý hành động m
stateDiagram-v2
direction TB
%% Định nghĩa các Style giả lập qua ghi chú (vì stateDiagram-v2 hạn chế classDef trực tiếp)
state "🕹️ GROUND LOCOMOTION (STEALTH & SPEED)" as Ground {
%% Định nghĩa các vùng trạng thái
state "🌸 GROUND LOCOMOTION" as Ground {
[*] --> Idle
state Idle {
direction LR
I_Phys: Vel < 0.1m/s
I_Cam: Breathing Cycle (0.5Hz)
I_Phys: 📝 Vel < 0.1m/s
I_Cam: 🌡️ Breathing Cycle (0.5Hz)
}
Idle --> Moving: Input.mag > 0.1
Idle --> Moving: "Input.mag > 0.1"
state Moving {
direction LR
M_Phys: Speed 2-4m/s
M_Cam: Head Bob (1.2Hz, Amp 0.05)
M_Phys: 👟 Speed 2-4m/s
M_Cam: 🎢 Head Bob (1.2Hz)
}
Moving --> Sneaking: OnSneak (Hold)
Moving --> Sneaking: "OnSneak (Hold) ✨"
state Sneaking {
direction LR
Sn_Phys: Speed 1.5m/s | Noise -50%
Sn_Cam: Height -0.5m | FOV 55 (Focus)
Sn_Phys: 🤫 Speed 1.5m/s | Noise -50%
Sn_Cam: 📉 Height -0.5m | FOV 55
}
Moving --> Sprinting: OnSprint (Hold) && Stamina > 0
Moving --> Sprinting: "OnSprint (Hold) 🔥"
state Sprinting {
direction LR
Sp_Phys: Speed > 6.5m/s | Noise +100%
Sp_Cam: FOV 60->85 (Dynamic) | Motion Blur
Sp_Phys: Speed > 6.5m/s | Noise +100%
Sp_Cam: 🌈 Dynamic FOV (60-85)
}
Sprinting --> Moving: Stamina == 0 || !SprintInput
Sneaking --> Moving: !SneakInput
Sprinting --> Moving: "Stamina == 0 or Release"
Sneaking --> Moving: "Release Sneak"
}
state "🌪 AIRBORNE & KINETIC IMPACT" as Air {
state " AIRBORNE & IMPACT" as Air {
state Jump {
J_Phys: AddForce(Vector3.up * Power)
J_Cam: Instant Y-Kick (Recoil)
J_Phys: 🆙 AddForce Up
J_Cam: 🚀 Instant Y-Kick
}
state Falling {
F_Phys: Gravity * 1.5 (Fast Fall)
F_Cam: FOV Stretch | Wind SFX
F_Phys: 📉 Gravity x 1.5
F_Cam: 💨 Wind Distortion VFX
}
state Landing {
L_Phys: Impact Velocity Check
L_Cam: Hard/Soft Shake (Z-Axis Roll)
L_Phys: 📏 Impact Velocity Check
L_Cam: 💢 Screen Shake
}
Jump --> Falling: Vel.y < 0
Falling --> Landing: IsGrounded == true
Jump --> Falling: "Velocity.y < 0"
Falling --> Landing: "IsGrounded == true"
}
state "⚡ ACTION & ABILITY LAYER" as Utility {
state "🎀 UTILITY & ACTIONS" as Utility {
state Dashing {
D_Phys: Linear Velocity Burst (15m/s)
D_Cam: Lens Distortion (Radial) | Trail VFX
D_Phys: 💨 Burst 15m/s
D_Cam: 🍭 Lens Distortion
}
state Interacting {
Int_Phys: Root Motion Lock
Int_Cam: Contextual Smooth Look-at
Int_Phys: 🔒 Root Motion Lock
Int_Cam: 👁️ Contextual Look-at
}
}
state "🌐 NETWORK RECONCILIATION LAYER" as Net {
state "🌐 NETWORK SYNC (Fusion)" as Net {
state InputAuthority {
IA: Local Prediction (Zero Latency)
IA: Buffer Tick N
IA: 🎮 Local Prediction
IA: Buffer Tick N
}
state StateAuthority {
SA: Server Snapshot (Tick N-3)
SA: Verification & Correction
SA: 🖥️ Server Snapshot
SA: 🛠️ Reconciliation
}
IA --> SA: [Networked] CamRotation
SA --> IA: Teleport/Snap if Error > 0.5m
IA --> SA: "[Networked] CamRotation"
SA --> IA: "Correction if Error > 0.5m"
}
%% Hệ thống góc nhìn bất đối xứng (Asymmetric Views)
state "🎭 ROLE SPECIFIC VIEWPORTS" as Roles {
state "🎭 ROLE VIEWPORTS" as Roles {
state Seeker_FPS {
S_View: 1st Person POV
S_Logic: Raycast Flashlight | Noise Meter UI
S_View: 🔦 1st Person POV
S_Logic: 🔊 Noise Meter UI
}
state Trapper_STRAT {
T_View: Top-Down Orthographic / Isometric
T_Logic: Heatmap Overlay | CCTV Switcher
T_View: 🗺️ Tactical Overlay
T_Logic: 🌡️ Heatmap & CCTV
}
}
%% Transitions chính
Ground --> Air: !IsGrounded (Coyote Time: 0.2s)
Air --> Ground: OnLand Event
Ground --> Utility: OnAbilityTrigger
Utility --> Ground: OnAnimationEnd
%% Transitions chính (Đã sửa lỗi cú pháp bằng dấu "")
Ground --> Air: "!IsGrounded (Coyote Time: 0.2s)"
Air --> Ground: "OnLand Event ✨"
Ground --> Utility: "OnAbilityTrigger ⚡"
Utility --> Ground: "Action Complete ✅"
note left of Ground: Sync: [Networked] Velocity, MoveState
note right of Net: Fusion: FixedUpdateNetwork() Loop
note left of Ground: 🎵 Sync: Velocity, MoveState
note right of Net: ⚙️ Fusion: FixedUpdateNetwork Loop
```
### 2. Environment Scanner & Interaction
@@ -329,67 +327,64 @@ Sử dụng **Photon Fusion (State Sync)** với cơ chế Client-Side Predictio
sequenceDiagram
autonumber
%% Định nghĩa các bên tham gia với Icon
participant IR as 🖱️ Input Reader (Local)
box rgb(235, 245, 255) "CLIENT (Input Authority)"
participant CP as 👤 Local Player<br/>(Predictive Simulation)
%% Định nghĩa các bên tham gia với phong cách đáng yêu
participant IR as 🖱️ Input Reader
box "🌸 CLIENT (Authority)" #E3F2FD
participant CP as 🎀 Local Player<br/>(Predictive)
end
box rgb(255, 243, 224) "NETWORK LAYER"
participant NT as 🌐 Photon Fusion Buffer
box "🌐 NETWORK" #FFF3E0
participant NT as Fusion Buffer
end
box rgb(232, 245, 233) "SERVER (State Authority)"
participant S as 🖥️ Headless Server<br/>(Validation)
box "🖥️ SERVER" #E8F5E9
participant S as 👑 State Authority
end
box rgb(243, 229, 245) "OTHER CLIENTS (Proxies)"
participant RP as 👥 Remote Proxies<br/>(Interpolation)
box "👥 OTHERS" #F3E5F5
participant RP as 🍭 Remote Proxies
end
%% --- GIAI ĐOẠN 1: THU THẬP INPUT ---
rect rgb(200, 230, 250)
Note over IR, CP: [TICK N] Giai đoạn lấy dữ liệu đầu vào
IR->>CP: OnMove(Vector2), OnJump(bool)
CP->>CP: Encode NetworkInputData {Buttons, Angles}
%% --- GIAI ĐOẠN 1: THU THẬP ---
Note over IR, CP: [TICK N] Thu thập năng lượng Input ✨
IR->>CP: OnMove / OnJump Events
CP->>CP: 📦 Encode NetworkInputData
%% --- GIAI ĐOẠN 2: DỰ ĐOÁN ---
rect rgb(255, 245, 230)
Note over CP, NT: [FixedUpdateNetwork] Chạy trước tương lai! 🚀
CP->>CP: 🏃 Client-Side Prediction<br/>(Di chuyển ngay lập tức)
CP->>NT: ✉️ Send Input Packet
NT-->>S: Transport via UDP
end
%% --- GIAI ĐOẠN 2: DỰ ĐOÁN & GỬI DỮ LIỆU ---
rect rgb(255, 248, 225)
Note over CP, NT: [FixedUpdateNetwork] Khởi chạy vòng lặp mạng
CP->>CP: 🏃 Client-Side Prediction:<br/>Áp dụng vận tốc & Physics ngay lập tức
CP->>NT: Reliable/Unreliable Input Packet
NT-->>S: Transport Layer (UDP/Photon Bolt)
%% --- GIAI ĐOẠN 3: XÁC THỰC ---
rect rgb(235, 255, 235)
Note right of S: SERVER LOGIC (Tick N) ⚖️
S->>S: 📝 Verify Input & Collision
S->>S: 💾 Update [Networked] States
end
%% --- GIAI ĐOẠN 3: XÁC THỰC TẠI SERVER ---
rect rgb(232, 245, 233)
Note right of S: SERVER SIMULATION (Tick N)
S->>S: Dequeue Input từ Buffer
S->>S: Thực thi Logic: Move -> Collision Check -> Stamina
S->>S: Ghi đè [Networked] Properties (State Authority)
end
%% --- GIAI ĐOẠN 4: ĐỒNG BỘ HÓA & HIỆU CHỈNH ---
S-->>NT: Broadcast State Snapshot (Tick N)
%% --- GIAI ĐOẠN 4: ĐỒNG BỘ ---
S-->>NT: 📣 Broadcast State Snapshot
par Hồi đáp Local Player
par 💫 Hồi đáp Local Player
NT-->>CP: State Snapshot
Note over CP: 🔄 RECONCILIATION
alt Nếu vị trí sai lệch > Threshold
CP->>CP: Hard Snap / Resimulate từ Tick lỗi
else Khớp dữ liệu
CP->>CP: Tiếp tục Simulation
alt ⚠️ Sai lệch > Threshold
CP->>CP: Hard Snap & Resimulate
else ✅ Hợp lệ
CP->>CP: Tiếp tục Simulation mượt mà
end
and Cập nhật các Player khác
and 🌈 Cập nhật cho mọi người
NT-->>RP: State Snapshot
Note over RP: 🎞️ INTERPOLATION
RP->>RP: Lerp từ Snapshot (N-1) sang Snapshot (N)
RP->>RP: Lerp(Snap_N, Snap_N-1)
end
%% --- GIAI ĐOẠN 5: HIỂN THỊ (MONOBEHAVIOUR) ---
rect rgb(245, 245, 245)
Note over CP, RP: [LateUpdate / Render Loop]
CP->>CP: Update Visual: Camera Shake, VFX
RP->>RP: Render Smooth Mesh Motion
end
%% --- GIAI ĐOẠN 5: HIỂN THỊ ---
rect rgb(250, 240, 255)
Note over CP, RP: [LateUpdate] Rendering Kawaii VFX 🎨
CP->>CP: Cam Shake & Particles
RP->>RP: Smooth Mesh Movement
end
```
---