add rule AI

This commit is contained in:
CuongNV
2026-03-24 12:28:56 +07:00
parent 7c9a163861
commit ed9910f365
25 changed files with 13639 additions and 10 deletions
+52
View File
@@ -0,0 +1,52 @@
# Perfect World Port Architecture
## Overview
Project này port client Perfect World từ C++ sang Unity C# và xây dựng server mới bằng .NET.
Architecture gồm 3 layer chính:
Client Layer
Unity project chịu trách nhiệm:
- UI
- rendering
- input
- local gameplay logic
- network client
Server Layer
.NET 8 server sử dụng LiteNetLib.
Server chịu trách nhiệm:
- authoritative game state
- player session
- snapshot replication
- chat routing
Shared Layer
Game.Shared chứa:
- protocol definitions
- shared data types
- serialization logic
## Architecture Diagram
Unity Client
Game.Shared (protocol)
LiteNetLib transport
Game.Server
## Main Goals
- giữ gameplay logic từ Perfect World
- thay engine bằng Unity
- thay network stack
- modernize architecture
+63
View File
@@ -0,0 +1,63 @@
# Chat System
Chat system gốc của Perfect World gồm các bước:
Network Protocol
GameSession
GameUIMan
CECPateText
Render
## Components
ChatMessage
network protocol chứa:
channel
roleid
msg
emotion
GameSession::OnPrtcChatMessage
nhận packet từ network.
GameUIMan::AddChatMessage
thêm message vào UI.
CECPateText
parse text thành các item:
TEXT
EMOTION
ITEM LINK
## Emotion System
Emotion được encode trong text:
format:
emotionSet:index
Example:
1:5
## Rendering
CECPateText chia text thành item list.
Item gồm:
type
index
color
position
+21
View File
@@ -0,0 +1,21 @@
# Common Code Patterns
Pattern: Player Name Lookup
C++
Name2IDTable
ID2NameTable
C#
Dictionary<string, int>
Dictionary<int, string>
Pattern: Chat Rendering
Parse text
create item list
render UI
+33
View File
@@ -0,0 +1,33 @@
# Data Types Mapping
Perfect World sử dụng nhiều custom types.
Mapping sang C#:
ACString → string
ACHAR → wchar_t / char
A3DCOLOR → UnityEngine.Color hoặc Color32
Octets → byte[]
pair_type → Tuple hoặc struct
AArray<T> → List<T>
DWORD → uint
BYTE → byte
BOOL → bool
## Important Note
ACString trong C++ hỗ trợ:
- formatting
- substring
- concat
C# string là immutable nên cần cẩn thận performance.
+68
View File
@@ -0,0 +1,68 @@
# C++ to C# Porting Rules
Rule 1
const ACHAR* → string
Rule 2
output parameters
C++:
int& value
C#:
ref int value
Rule 3
pointer
T* → reference
Rule 4
array
ACHAR buffer[1024]
C#:
Span<char> hoặc string builder
Rule 5
container
AArray → List
Rule 6
memory ownership
C++ có delete
C# dùng GC
Rule 7
Chat Message Handling
C++:
g_pGame->GetGameRun()->AddChatMessage(str, p->channel, p->srcroleid, NULL, 0, p->emotion,pItem ? pItem->Clone() : NULL, strMsgOrigion);
C#:
EC_Game.GetGameRun().AddChatMessage(str, p.Channel, p.Srcroleid,null, 0, p.Emotion, null, strMsgOrigion);
Rule 8
Chat Bubble on Top Player
C++:
pPlayer.SetLastSaidWords(strTemp, p.Emotion);
C#:
EventBus.PublishChannel(p.Srcroleid, new EventChatMessageOnTopPlayer(p.Srcroleid, strTemp));
+31
View File
@@ -0,0 +1,31 @@
# Network Protocol
Protocol gốc sử dụng GNET.
Structure:
Protocol
Rpc::Data
Octets serialization
## Example
ChatMessage
fields:
channel
srcroleid
srclevel
msg
emotion
## Serialization
Octets chứa raw byte array.
C# equivalent:
byte[]