├── KBEngine overview(cn).pptx ├── README.md ├── api ├── Index.hhk ├── Table of Contents.hhc ├── baseapp │ ├── Classes │ │ ├── Entity.html │ │ └── Proxy.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── basetypes.html ├── bots │ ├── Classes │ │ ├── Entity.html │ │ └── PyClientApp.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── cellapp │ ├── Classes │ │ └── Entity.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── client │ ├── Classes │ │ └── Entity.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── dbmgr │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── htmlhelp.exe ├── index.html ├── interfaces │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── kbengine_api.hhp ├── keywords.html ├── logger │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── loginapp │ ├── Modules │ │ └── KBEngine.html │ └── index.html └── style.css ├── api_en ├── Index.hhk ├── Table of Contents.hhc ├── baseapp │ ├── Classes │ │ ├── Entity.html │ │ └── Proxy.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── basetypes.html ├── bots │ ├── Classes │ │ ├── Entity.html │ │ └── PyClientApp.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── cellapp │ ├── Classes │ │ └── Entity.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── client │ ├── Classes │ │ └── Entity.html │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── dbmgr │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── htmlhelp.exe ├── index.html ├── interfaces │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── kbengine_api.hhp ├── keywords.html ├── logger │ ├── Modules │ │ └── KBEngine.html │ └── index.html ├── loginapp │ ├── Modules │ │ └── KBEngine.html │ └── index.html └── style.css ├── generate_python_tips.py └── python3.x_generate_python_tips.bat /KBEngine overview(cn).pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbengine/kbengine_docs/f24879e473d2fe91b9016e958b6b036e20d0522b/KBEngine overview(cn).pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | kbengine_docs 2 | ============= 3 | 4 | ## Homepage 5 | http://www.kbengine.org 6 | 7 | ## Releases 8 | sources : https://github.com/kbengine/kbengine/releases 9 | binarys : https://sourceforge.net/projects/kbengine/files/ 10 | 11 | ## Demo sources 12 | unity3d : https://github.com/kbengine/kbengine_unity3d_demo/releases 13 | unity3d : https://github.com/kbengine/kbengine_unity3d_warring/releases 14 | ogre : https://github.com/kbengine/kbengine_ogre_demo/releases 15 | html5 : https://github.com/kbengine/kbengine_html5_demo/releases 16 | 17 | 18 | ## Docs 19 | docs : http://www.kbengine.org/docs/ 20 | API : https://github.com/kbengine/kbengine/tree/master/docs 21 | 22 | ## Support 23 | Email : kbengine_maillist@googlegroups.com 24 | Maillist : https://groups.google.com/d/forum/kbengine_maillist 25 | 26 | ## QQ交流群 27 | 16535321 28 | 29 | ## What is KBEngine? 30 | An open source MMOG server engine. 31 | Just use Python scripting to be able to complete any game logic simply and efficiently (supports hotfixing). 32 | Various KBEngine plugins can be quickly combined with (Unity3D, OGRE, Cocos2d-x, HTML5, etc.) technology to 33 | form a complete game client. 34 | 35 | The engine is written in C++, and saves developers from having to re-implement common server-side 36 | technology, allowing them to concentrate on game logic development, to quickly create a variety of games. 37 | 38 | (Because it is often asked what the upper limit of the load is that KBEngine can handle, the underlying 39 | architecture has been designed as a multi-process distributed dynamic load balancing solution. In theory, 40 | by continuously expanding the hardware, the upper limit of the load can also be continuously increased. 41 | The upper limit of the capacity of a single machine depends on the complexity of the game logic itself.) 42 | 43 | ## 什么是KBEngine? 44 | 一款开源的游戏服务端引擎,使用简单的约定协议就能够使客户端与服务端进行交互, 45 | 使用KBEngine插件能够快速与(Unity3D, OGRE, Cocos2d, HTML5, 等等)技术结合形成一个完整的客户端。 46 | 47 | 服务端底层框架使用c++编写,游戏逻辑层使用Python(支持热更新),开发者无需重复的实现一些游戏服务端通用的底层技术, 48 | 将精力真正集中到游戏开发层面上来,快速的打造各种网络游戏。 49 | 50 | (经常被问到承载上限,kbengine底层架构被设计为多进程分布式动态负载均衡方案, 51 | 理论上只需要不断扩展硬件就能够不断增加承载上限,单台机器的承载上限取决于游戏逻辑本身的复杂度。) 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /api/Table of Contents.hhc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 220 | 221 | -------------------------------------------------------------------------------- /api/baseapp/Classes/Proxy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Proxy - KBEngine base 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Proxy类

12 |

[KBEngine模块]

Proxy是KBEngine模块的一部分。 更多...

import KBEngine
13 |

父类

14 | Entity 15 |
16 | 17 |

成员函数

18 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 |
21 | def disconnect( self ): 22 |
25 | def getClientType( self ): 26 |
29 | def getClientDatas( self ): 30 |
33 | def giveClientTo( self, proxy ): 34 |
37 | def streamFileToClient( self, resourceName, desc="", id=-1 ): 38 |
41 | def streamStringToClient( self, data, desc="", id=-1 ): 42 |
45 | 46 |

回调函数

47 | 48 | 49 | 52 | 53 | 56 | 57 | 60 | 61 | 64 | 65 | 68 | 69 | 72 | 73 |
50 | def onClientDeath( self ): 51 |
54 | def onClientGetCell( self ): 55 |
58 | def onClientEnabled( self ): 59 |
62 | def onGiveClientToFailure( self ): 63 |
66 | def onLogOnAttempt( self, ip, port, password ): 67 |
70 | def onStreamComplete( self, id, success ): 71 |
74 | 75 |

属性

76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 |
__ACCOUNT_NAME__  只读 string
__ACCOUNT_PASSWORD__  只读 string
clientAddr  只读
clientEnabled  只读 bool
hasClient  只读 bool
roundTripTime  只读
timeSinceHeardFromClient  只读
93 | 94 |
95 |

详细描述

96 | ProxyEntity的一个特殊类型,它继承自Entity,它有一个关联的客户端。本身来说, 97 | 它就是一个代理客户端的实体,操控所有服务端向客户端的更新。不能在脚本直接创建Proxy类对象。 98 | 99 |
100 |

成员函数文档

101 | 102 |

103 | def disconnect( self ): 104 |

105 | 106 |
107 | 断开客户端连接。 108 |
109 | 110 | 111 | 112 |

113 | def getClientType( self ): 114 |

115 | 116 |
117 | 功能说明:

118 | 这个函数返回客户端类型。 119 |
120 | 121 |

122 | 返回: 123 | 124 | 135 |
125 | UNKNOWN_CLIENT_COMPONENT_TYPE = 0,
126 | CLIENT_TYPE_MOBILE = 1, // 手机类
127 | CLIENT_TYPE_WIN = 2, // pc, 一般都是exe客户端
128 | CLIENT_TYPE_LINUX = 3 // Linux Application program
129 | CLIENT_TYPE_MAC = 4 // Mac Application program
130 | CLIENT_TYPE_BROWSER = 5, // web应用, html5,flash
131 | CLIENT_TYPE_BOTS = 6, // bots
132 | CLIENT_TYPE_MINI = 7, // Mini-Client
133 | CLIENT_TYPE_END = 8 // end
134 |
136 |

137 | 138 | 139 | 140 |

141 | def getClientDatas( self ): 142 |

143 | 144 |
145 | 功能说明:

146 | 这个函数返回客户端登录时和注册时所附带的数据。
147 | 此数据可用于运营系统扩展,如果连接了第三方账号服务,此数据会经过interfaces进程发往第三方服务系统。 148 |
149 | 150 |

151 | 返回: 152 | 153 | 157 |
154 | tuple, 固定为2个元素的tuple(登陆数据bytes,注册数据bytes),第一个元素为登陆时客户端调用登陆时传入的datas参数, 155 | 第二个元素为注册时客户端调用注册所传入的datas参数。由于可以存储任意二进制数据,因此他们都是以bytes类型存在。 156 |
158 |

159 | 160 | 161 | 162 |

163 | def giveClientTo( self, proxy ): 164 |

165 | 166 |
167 | 功能说明:

168 | 将客户端的控制器转交给另一个Proxy,当前的Proxy必须有一个客户端而目标Proxy则必须没有关联客户端,否则将会提示错误。 169 |
170 | 171 |

172 | 参看: 173 | 174 | 175 |
Proxy.onGiveClientToFailure
176 |

177 | 178 |

179 | 参数: 180 | 181 | 182 | 185 | 186 |
proxy 183 | 控制权将转交给这个实体。 184 |
187 |

188 | 189 |

190 | def streamFileToClient( self, resourceName, desc="", id=-1 ): 191 |

192 | 193 |
194 | 功能说明:

195 | 这个函数类似于streamStringToClient(),将一个资源文件发送给客户端。发送过程在不同的线程上操作,因此不会危及主线程。 196 |
197 | 198 |

199 | 参看: 200 | 201 | 202 |
Proxy.onStreamComplete
203 |

204 | 205 |

206 | 参数: 207 | 208 | 209 | 212 | 213 | 216 | 217 | 220 | 221 |
resourceName 210 | 要发送的资源名称,包含路径。 211 |
desc 214 | 一个可选的字符串,发送给客户端的资源描述。 215 |
id 218 | 一个16位的id,它的值完全取决于调用者。如果传入-1系统将会在队列里面选择一个没有在用的id。可以在客户端根据这个id做资源判断。 219 |
222 |

223 | 224 |

225 | 返回: 226 | 227 | 230 |
228 | 与这个下载关联的id。 229 |
231 |

232 | 233 |

234 | def streamStringToClient( self, data, desc="", id=-1 ): 235 |

236 | 237 |
238 | 功能说明:

239 | 发送一些数据到当前实体绑定的客户端。如果客户端端口则数据被清除, 240 | 当客户端再次绑定到实体的时候才可调用这个函数。16位的id完全取决于调用者。 241 |
242 | 如果调用者没有指定这个ID则系统会分配一个未用过的id。可以在客户端根据这个id做资源判断。 243 |

244 | 你可以在Proxy的派生类中定义回调函数(onStreamComplete),所有数据成功发送给客户端时或下载失败时会调用这个回调函数。 245 |

246 | 参看:Proxy.onStreamComplete与客户端实体Entity.onStreamDataStarted和 247 | Entity.onStreamDataRecv还有Entity.onStreamDataCompleted。 248 |
249 | 250 |

251 | 参数: 252 | 253 | 254 | 257 | 258 | 261 | 262 | 265 | 266 |
data 255 | 要发送的字符串。 256 |
desc 259 | 一个可选的字符串,发送给客户端的描述。 260 |
id 263 | 一个16位的id,它的值完全取决于调用者。如果传入-1系统将会在队列里面选择一个没有在用的id。 264 |
267 |

268 | 269 |

270 | 返回: 271 | 272 | 275 |
273 | 与这个下载关联的id。 274 |
276 |

277 | 278 |
279 |

回调函数文档

280 | 281 | 282 |

283 | def onClientDeath( self ): 284 |

285 | 286 |
如果在脚本中实现了此回调,这个方法将在客户端断开连接时被调用。 这个方法没有参数。 287 |
288 | 289 |

290 | def onClientGetCell( self ): 291 |

292 | 293 |
如果在脚本中实现了此回调,当客户端能够调用实体的cell属性时,该回调被调用。 294 |
295 | 296 |

297 | def onClientEnabled( self ): 298 |

299 | 300 |
如果在脚本中实现了此回调,当实体可用时( 各种初始化完毕并且可以与客户端通讯 )该回调被调用。 这个方法没有参数。
301 | 注意:giveClientTo将控制权赋给了该实体时也会导致该回调被调用。 302 |
303 | 304 |

305 | def onGiveClientToFailure( self ): 306 |

307 | 308 |
309 | 如果在脚本中实现了此回调,当实体调用giveClientTo失败时,该回调被调用。这个方法没有参数。 310 |
311 | 312 | 313 |

314 | def onLogOnAttempt( self, ip, port, password ): 315 |

316 | 317 |
如果在脚本中实现了此回调,这个函数在客户端尝试使用当前账号实体进行登录时触发回调。
318 | 这种情况通常是实体存在于内存中处于有效状态,最明显的例子是用户A使用此账号登录了,用户B使用同一账号进行登录,此时回调触发。 319 |

320 | 这个回调函数可以返回如下常量值:
321 | KBEngine.LOG_ON_ACCEPT:允许新的客户端与实体进行绑定,如果实体已经绑定了一个客户端,之前的客户端将被踢出。
322 | KBEngine.LOG_ON_REJECT:拒绝新的客户端与实体绑定。 323 |
KBEngine.LOG_ON_WAIT_FOR_DESTROY:等待实体销毁后再进行客户端绑定。 324 |

325 |
326 | 327 |

328 | 参数: 329 | 330 | 331 | 333 | 334 | 336 | 337 | 339 | 340 |
ip 尝试登录的客户端IP地址。 332 |
port 尝试登录的客户端连接的端口。 335 |
password 用户登录时使用的MD5密码。 338 |
341 |

342 | 343 |

344 | def onStreamComplete( self, id, success ): 345 |

346 | 347 |
如果在脚本中实现了此回调,当用户使用Proxy.streamStringToClient()或Proxy.streamFileToClient()完成时,该回调被调用。 348 | 349 | 350 |
351 | 352 |

353 | 参数: 354 | 355 | 356 | 358 | 359 | 361 | 362 |
id 与下载关联的id。 357 |
success 成功与否。 360 |
363 |

364 | 365 |
366 |

属性文档

367 | 368 |

369 | __ACCOUNT_NAME__ 370 |

371 | 372 |
373 | 说明:

374 | 如果proxy是帐号则可以访问__ACCOUNT_NAME__得到帐号名。 375 |
376 | 377 |

378 | __ACCOUNT_PASSWORD__ 379 |

380 | 381 |
382 | 说明:

383 | 如果proxy是帐号则可以访问__ACCOUNT_PASSWORD__得到帐号MD5密码。 384 |
385 | 386 |

387 | clientAddr 388 |

389 | 390 |
这是一个tuple对象,包含了客户端的ip与端口。 391 |
392 | 393 |

394 | clientEnabled 395 |

396 | 397 |
实体是否已经可用。在实体可用之前脚本不能与客户端进行通讯。 398 |
399 | 400 |

401 | hasClient 402 |

403 | 404 |
Proxy是否绑定了一个客户端连接。 405 |
406 | 407 |

408 | roundTripTime 409 |

410 | 411 |
在一段时间内服务器与这个Proxy绑定的客户端通讯平均往返时间。这个属性只在Linux下生效。 412 |
413 | 414 |

415 | timeSinceHeardFromClient 416 |

417 | 418 |
最后一次收到客户端数据包时到目前为止所过去的时间(秒)。 419 |
420 | 421 |
422 | 423 | 424 | 425 | -------------------------------------------------------------------------------- /api/baseapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine baseapp 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Baseapp进程

12 | Baseapp进程主要负责与客户端通讯、与空间或位置无关类游戏逻辑(公会管理器、聊天系统、游戏大厅、排行榜等等)、存档与备份等等。 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /api/basetypes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Base Types 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

基本数据类型

15 |

16 |
17 | [Name]			[Bytes]
18 | 
19 | UINT8			1
20 | UINT16			2
21 | UINT32			4
22 | UINT64			8
23 | 
24 | INT8			1
25 | INT16			2
26 | INT32			4
27 | INT64			8
28 | 
29 | FLOAT			4
30 | DOUBLE			8
31 | 
32 | VECTOR2			12
33 | VECTOR3			16
34 | VECTOR4			20
35 | 
36 | STRING			N
37 | UNICODE			N
38 | PYTHON			N
39 | PY_DICT			N
40 | PY_TUPLE			N
41 | PY_LIST			N
42 | ENTITYCALL		N
43 | BLOB			N
44 | 
45 | 46 |

47 |

48 |

49 |

50 |
51 | 52 |
53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /api/bots/Classes/PyClientApp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PyClientApp - KBEngine bots 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

PyClientApp类

12 | 13 |

[KBEngine模块]

PyClientApp是KBEngine模块的一部分,由C++底层模拟一个客户端时创建的客户端对象,脚本层不可直接创建。

14 | 15 |

成员函数

16 | 17 | 18 | 21 | 22 | 25 | 26 |
19 | def getSpaceData( key ): 20 |
23 | def player( ): 24 |
27 | 28 |

回调函数

29 | 30 | 31 |
32 | 33 |

属性

34 | 35 | 36 | 37 | 39 | 40 |
id  只读 Integer 38 |
entities  Entities 41 | 42 |
43 | 44 |
45 |

详细描述

46 | 类Entity的实例代表着在client上的游戏对象。 47 |

48 | 49 |

50 | 一个Entity可以通过ENTITYCALL访问在base和cell应用程序上的等价的实体。这需要 51 | 一组远程调用的函数(在实体的.def文件里指定)。 52 | 53 |
54 |

成员函数文档

55 | 56 |

57 | def getSpaceData( key ): 58 |

59 | 60 |
61 | 功能说明:

62 | 获取指定key的space数据。 63 |
64 | space数据由用户在服务端通过setSpaceData设置。 65 |
66 | 67 |

68 | 参数: 69 | 70 | 71 | 74 |
key 72 | string,一个字符串关键字。 73 |
75 |

76 | 77 |

78 | 返回: 79 | 80 | 83 |
81 | string,指定key的字符串数据。 82 |
84 |

85 | 86 | 87 | 88 |

89 | def player( ): 90 |

91 | 92 |
93 | 功能说明:

94 | 获得当前客户端所控制的实体。
95 |
96 |
97 | 98 | 99 | 100 | 101 | 102 |
103 |

回调函数文档

104 | 105 | 106 | 107 |
108 |

属性文档

109 | 110 |

111 | entities 112 |

113 | 114 |
115 | 说明:

116 | entities是一个字典对象,包含当前进程上所有的实体。
117 |
118 | 119 |

120 | 类型: 121 | 122 | 124 |
Entities 123 |
125 |

126 | 127 | 128 | 129 |
130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /api/bots/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine bots 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine模块

12 | KBEngine模块提供了逻辑脚本层访问实体的部分, 以及当前进程其他客户端的数据等等。 13 |

14 | 15 | 16 | 19 | 20 | 23 | 24 |
17 | Entity 18 |
21 | PyClientApp 22 |
25 | 26 |

成员函数

27 | 28 | 29 | 32 | 33 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 52 | 53 | 56 | 57 | 60 |
30 | def addBots( reqCreateAndLoginTotalCount, reqCreateAndLoginTickCount=0, reqCreateAndLoginTickTime=0 ): 31 |
34 | def callback( initialOffset, callbackObj ): 35 |
38 | def cancelCallback( id ): 39 |
42 | def genUUID64( ): 43 |
46 | def getWatcher( path ): 47 |
50 | def getWatcherDir( path ): 51 |
54 | def scriptLogType( logType ): 55 |
58 | def urlopen( url, callback, postData, headers ): 59 |
61 | 62 |

回调函数

63 | 64 | 67 | 68 | 71 |
65 | def onInit( isReload ): 66 |
69 | def onFinish( ): 70 |
72 | 73 |

属性

74 | 75 | 76 | 79 | 80 | 81 | 82 |
bots  bots 77 | 78 |
component  只读 string
83 | 84 |
85 |

成员函数文档

86 | 87 |

88 | def addBots( reqCreateAndLoginTotalCount, reqCreateAndLoginTickCount=0, reqCreateAndLoginTickTime=0 ): 89 |

90 | 91 |
92 | 功能说明:

93 | 向服务端添加机器人。 94 |

95 | 例子: 96 | 97 |
# 这里是使用addBots的一个例子
 98 |         import KBEngine
 99 |  
100 |         # 一次性向服务器添加5个机器人(瞬时完成)
101 |         KBEngine.addBots( 5 )
102 |  
103 |         # 一共向服务器添加1000个机器人,每次添加5个,每次添加所用时间(s)
104 |         KBEngine.addBots( 1000, 5, 10 )
105 | 
106 |
107 |
108 | 109 |

110 | 参数: 111 | 112 | 113 | 116 | 117 | 120 | 121 | 124 | 125 |
reqCreateAndLoginTotalCount 114 | integer,向服务器添加的机器人总数。 115 |
reqCreateAndLoginTickCount 118 | integer,每次向服务器添加的机器人数量。 119 |
reqCreateAndLoginTickTime 122 | integer,每次添加所用时间(秒)。 123 |
126 |

127 | 128 | 129 | 130 | 131 |

132 | def callback( initialOffset, callbackObj ): 133 |

134 | 135 |
136 | 功能说明:

137 | 注册一个回调,回调函数callbackObj触发,回调函数将在"initialOffset"秒后被执行。 138 |

139 | 例子: 140 | 141 |
# 这里是使用callback的一个例子
142 |         import KBEngine
143 |  
144 |         # 增加一个定时器,1秒后执行
145 |         KBEngine.callback( 1, onCallbackfun )
146 |  
147 |     def onCallbackfun( ):
148 |         print "onCallbackfun called“
149 | 	
150 |
151 |
152 | 153 |

154 | 参数: 155 | 156 | 157 | 160 | 161 | 164 | 165 |
initialOffset 158 | float,指定回调从注册到回调的时间间隔(秒)。 159 |
callbackObj 162 | function,指定的回调函数对象。 163 |
166 |

167 | 168 |

169 | 返回: 170 | 171 | 173 |
integer,该函数返回callback的内部id,这个id可用于cancelCallback移除回调。 172 |
174 |

175 | 176 | 177 | 178 |

179 | def cancelCallback( id ): 180 |

181 | 182 |
183 | 功能说明:

184 | 函数cancelCallback用于移除一个注册但还未触发的回调,移除后的回调不再执行。 185 | 如果cancelCallback函数使用一个无效的id(例如已经移除),将会产生错误。 186 |

187 | 到KBEngine.callback参考回调的一个使用例子。 188 |
189 | 190 |

191 | 参数: 192 | 193 | 194 | 197 | 198 |
id 195 | integer,它指定要移除的回调id。 196 |
199 |

200 | 201 | 202 | 203 |

204 | def genUUID64( ): 205 |

206 | 207 |
208 | 功能说明:

209 | 该函数生成一个64位的唯一ID。
210 | 注意:这个函数依赖于Cellapps服务进程启动参数gus,请正确设置启动参数保持唯一性。
211 | 另外如果gus超过65535则该函数只能在当前进程上保持唯一性。 212 |
213 |
214 | 用途:
215 | 多个服务进程上产生唯一物品ID并且在合服时不会产生冲突。
216 | 多个服务进程上产生一个房间ID,不需要进行唯一性校验。
217 |
218 | 219 |

220 | 返回: 221 | 222 | 225 |
223 | 返回一个64位的integer。 224 |
226 |

227 | 228 | 229 | 230 |

231 | def getWatcher( path ): 232 |

233 | 234 |
235 | 功能说明:

236 | 从KBEngine调试系统中获取一个监视变量的值。 237 |
238 |
239 | 例子:在baseapp1的Python命令行输入:
240 | >>>KBEngine.getWatcher("/root/stats/runningTime") 241 |
242 | 12673648533 243 |
244 |
245 | >>>KBEngine.getWatcher("/root/scripts/players") 246 |
247 | 32133 248 |
249 | 250 |

251 | 参数: 252 | 253 | 254 | 257 | 258 |
path 255 | string,该变量的绝对路径包括变量名(可以在GUIConsole的watcher页查看)。 256 |
259 |

260 | 261 |

262 | 返回: 263 | 264 | 267 |
265 | 该变量的值。 266 |
268 |

269 | 270 | 271 | 272 |

273 | def getWatcherDir( path ): 274 |

275 | 276 |
277 | 功能说明:

278 | 从KBEngine调试系统中获取一个监视目录下的元素列表(目录、变量名)。 279 |
280 |
281 | 例子:在baseapp1的Python命令行输入:
282 | >>>KBEngine.getWatcher("/root") 283 |
284 | ('stats', 'objectPools', 'network', 'syspaths', 'ThreadPool', 'cprofiles', 'scripts', 'numProxices', 'componentID', 'componentType', 'uid', 'numClients', 'globalOrder', 'username', 'load', 'gametime', 'entitiesSize', 'groupOrder') 285 |
286 | 287 |

288 | 参数: 289 | 290 | 291 | 294 | 295 |
path 292 | string,该变量的绝对路径(可以在GUIConsole的watcher页查看)。 293 |
296 |

297 | 298 |

299 | 返回: 300 | 301 | 304 |
302 | 监视目录下的元素列表(目录、变量名)。 303 |
305 |

306 | 307 | 308 | 309 |

310 | def scriptLogType( logType ): 311 |

312 | 313 |
314 | 功能说明:

315 | 设置当前Python.print输出的信息类型(参考: KBEngine.LOG_TYPE_*)。 316 |
317 | 318 | 319 | 320 |

321 | def urlopen( url, callback, postData, headers ): 322 |

323 | 324 |
325 | 功能说明:

326 | 这个脚本函数在提供对外HTTP/HTTPS异步请求。 327 |
328 | 329 |

330 | 参数: 331 | 332 | 333 | 336 | 337 | 338 | 356 | 357 | 360 | 361 | 364 | 365 |
url 334 | 有效的HTTP/HTTPS网址,字符串类型。 335 |
callback

339 | 可选参数,带有请求执行结果的回调对象(比如说是一个函数)。这个回调带有5个参数:HTTP请求返回码(如:200),返回的内容,返回的HTTP协议头,是否成功,请求的网址。 340 |
341 | 声明样例:
342 | def 343 | onHttpCallback(httpcode, data, headers, success, url):
344 |     print(httpcode, data, headers, success, url)
345 |
346 | 如同上面的例子所示: 347 |

httpcode:参数对应的就是“HTTP请求返回码”,这个结果集合参数是一个整形值。 348 |

data:参数则是“返回的内容”,它是一个字符串。 349 |

350 |

headers:参数是“服务器返回的HTTP协议头”,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 351 |

success:则对应了“执行是否成功”,当请求执行有错误时,为False,可以通过httpcode进一步判断错误信息。 352 |

353 |

url:是“请求所用的网址。 354 |

355 |
postData 358 | 可选参数,默认是GET方式请求服务器,如果需要POST方式请提供需要POST的内容,引擎将自动使用POST方式请求服务器,它是一个bytes。 359 |
headers 362 | 可选参数,请求时使用的HTTP头,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 363 |
366 |

367 | 368 | 369 | 370 |
371 |

回调函数文档

372 | 373 |

374 | 375 |

376 | def onInit( isReload ): 377 |

378 | 379 |
380 | 功能说明:

381 | 当引擎启动后初始化完所有的脚本后这个接口被调用。 382 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 383 |
384 | 385 |

386 | 参数: 387 | 388 | 389 | 392 | 393 |
isReload 390 | bool,是否是被重写加载脚本后触发的。 391 |
394 |

395 | 396 | 397 | 398 |

399 | def onFinish( ): 400 |

401 | 402 |
403 | 功能说明:

404 | 进程关闭会回调此函数。 405 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 406 |
407 | 408 | 409 |

410 | 411 | 412 |
413 |

属性文档

414 | 415 |

416 | bots 417 |

418 | 419 |
420 | 说明:

421 | bots是一个字典对象,包含当前进程上所有的客户端对象。
422 |
423 | 424 |

425 | 类型: 426 | 427 | 429 |
PyBots 428 |
430 |

431 | 432 | 433 |

434 | component 435 |

436 | 437 |
438 | 说明:

439 | 这是正运行在当前脚本环境的组件。(至今为止)可能值有'cellapp', 'baseapp', 'client', 'dbmgr', 'bots' 和 'editor'。 440 |
441 | 442 | 443 | 444 | 445 |
446 | 447 | 448 | -------------------------------------------------------------------------------- /api/bots/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine bots 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Bots进程

12 | Bots是一种对服务端进行模拟测试的轻量级客户端程序,Bots没有渲染等部分,通过大量的模拟客户端与服务端进行逻辑交互能够测试出服务端隐含的BUG与压力,从而使得开发人员能够有效的针对性的对服务端进行优化。 13 |
14 |
15 | 注意:Bots进程需要在scripts/bots下实现相关客户端代码,由Python脚本来扩展实现。 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /api/cellapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine cellapp 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Cellapp进程

12 | Cellapp进程主要负责与空间位置有关类游戏逻辑,提供将不同Baseapp上的玩家聚合在一个空间中实时交互的功能,Cellapp上通常可实现场景、NPC/怪物、战斗、关卡房间相关逻辑。 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /api/client/Classes/Entity.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Entity - KBEngine client 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Entity类

12 | 13 |

[KBEngine模块]

Entity是KBEngine模块的一部分。 更多...

import KBEngine
14 | 15 |

成员函数

16 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 | 34 | 37 | 38 | 41 | 42 | 45 | 46 |
19 | def baseCall( self, methodName, methodArgs ): 20 |
23 | def cellCall( self, methodName, methodArgs ): 24 |
27 | def isPlayer( self ): 28 |
31 | def getComponent( self, componentName, all ): 32 |
35 | def fireEvent( self, eventName, *args ): 36 |
39 | def registerEvent( self, eventName, callback ): 40 |
43 | def deregisterEvent( self, eventName, callback ): 44 |
47 | 48 |

回调函数

49 | 50 | 51 | 54 | 55 | 58 | 59 | 62 | 63 | 66 | 67 | 70 |
52 | def onDestroy( self ): 53 |
56 | def onEnterWorld( self ): 57 |
60 | def onLeaveWorld( self ): 61 |
64 | def onEnterSpace( self ): 65 |
68 | def onLeaveSpace( self ): 69 |
71 | 72 |

属性

73 | 74 | 75 | 77 | 78 | 80 | 81 | 83 | 84 | 86 | 87 | 89 | 90 | 92 | 93 | 95 | 96 |
direction  Tuple of 3 floats as (roll, pitch, yaw) 76 |
id  只读 Integer 79 |
position  Vector3 82 |
spaceID  只读 uint32 85 |
isOnGround  只读 bool 88 |
inWorld  只读 bool 91 |
className  只读 string 94 |
97 | 98 |
99 |

详细描述

100 | 类Entity的实例代表着在client上的游戏对象。 101 |

102 | 103 |

104 | 一个Entity可以通过ENTITYCALL访问在base和cell应用程序上的等价的实体。这需要 105 | 一组远程调用的函数(在实体的.def文件里指定)。 106 | 107 |
108 |

成员函数文档

109 | 110 |

111 | def baseCall( self, methodName, methodArgs ): 112 |

113 | 114 |
115 | 功能说明:

116 | 调用该实体的base部分的方法。
117 | 注意:实体在服务端必须有base部分,在客户端只有客户端控制的玩家实体才可以访问该方法。 118 |

119 | 120 | 例子:
121 | js插件: entity.baseCall("reqCreateAvatar", roleType, name);
122 | c#插件: entity.baseCall("reqCreateAvatar", new object[]{roleType, name}); 123 |
124 | 125 |

126 | 参数: 127 | 128 | 129 | 132 | 133 | 136 | 137 |
methodName 130 | string,方法名称。 131 |
methodArgs 134 | objects,方法参数列表。 135 |
138 |

139 | 140 |

141 | 返回: 142 | 143 | 146 |
144 | 由于是远程调用,不可能阻塞等待返回,因此无返回值。 145 |
147 |

148 | 149 | 150 | 151 |

152 | def cellCall( self, methodName, methodArgs ): 153 |

154 | 155 |
156 | 功能说明:

157 | 调用该实体的cell部分的方法。
158 | 注意:实体在服务端必须有cell部分,在客户端只有客户端控制的玩家实体才可以访问该方法。 159 |

160 | 161 | 例子:
162 | js插件: entity.cellCall("xxx", roleType, name);
163 | c#插件: entity.cellCall("xxx", new object[]{roleType, name}); 164 |
165 | 166 |

167 | 参数: 168 | 169 | 170 | 173 | 174 | 177 | 178 |
methodName 171 | string,方法名称。 172 |
methodArgs 175 | objects,方法参数列表。 176 |
179 |

180 | 181 |

182 | 返回: 183 | 184 | 187 |
185 | 由于是远程调用,不可能阻塞等待返回,因此无返回值。 186 |
188 |

189 | 190 |

191 | def isPlayer( self ): 192 |

193 | 194 |
195 | 功能说明:

196 | 这个函数返回这个Entity是否为当前客户端所控制的Player。 197 |
198 | 199 |

200 | 返回: 201 | 202 | 204 |
bool, 如果是当前客户端所控制的Player返回True,否则返回False。 203 |
205 |

206 | 207 | 208 |

209 | def getComponent( self, componentName, all ): 210 |

211 | 212 |
213 | 功能说明:

214 | 该函数用于获取实体所绑定的某一类组件实例。 215 |
216 | 217 |

218 | 参数: 219 | 220 | 221 | 224 | 225 | 228 |
componentName 222 | string,组件类型名称,组件的模块名称。 223 |
all 226 | bool,如果为True,返回所有同类组件实例,否则只返回第一个或空列表。 227 |
229 |

230 | 231 | 232 |

233 | def fireEvent( self, eventName, *args ): 234 |

235 | 236 |
237 | 功能说明:

238 | 该函数用于触发实体事件。 239 |
240 | 241 |

242 | 参数: 243 | 244 | 245 | 248 | 249 | 252 |
eventName 246 | string,要触发的事件名称。 247 |
args 250 | 要附带的事件数据,可变参数。 251 |
253 |

254 | 255 | 256 |

257 | def registerEvent( self, eventName, callback ): 258 |

259 | 260 |
261 | 功能说明:

262 | 该函数用于注册实体事件。 263 |
264 | 265 |

266 | 参数: 267 | 268 | 269 | 272 | 273 | 276 |
eventName 270 | string,要注册监听的事件名称。 271 |
callback 274 | 当事件触发时,用于响应该事件的回调方法。 275 |
277 |

278 | 279 | 280 |

281 | def deregisterEvent( self, eventName, callback ): 282 |

283 | 284 |
285 | 功能说明:

286 | 该函数用于注销监听实体事件。 287 |
288 | 289 |

290 | 参数: 291 | 292 | 293 | 296 | 297 | 300 |
eventName 294 | string,要注销监听的事件名称。 295 |
callback 298 | 要注销监听的回调方法。 299 |
301 |

302 | 303 | 304 |
305 |

回调函数文档

306 | 307 | 308 |

309 | def onDestroy( self ): 310 |

311 | 312 |
实体被销毁时调用。 313 |
314 | 315 | 316 |

317 | def onEnterWorld( self ): 318 |

319 | 320 |
如果实体非客户端控制实体,则表明实体进入了服务端上客户端控制的实体的View范围,此时客户端可以看见这个实体了。
321 | 如果实体是客户端控制的实体则表明该实体已经在服务端创建了cell并进入了space。 322 |
323 | 324 | 325 | 326 |

327 | def onLeaveWorld( self ): 328 |

329 | 330 |
如果实体非客户端控制实体,则表明实体离开了服务端上客户端控制的实体的View范围,此时客户端看不见这个实体了。
331 | 如果实体是客户端控制的实体则表明该实体已经在服务端销毁了cell并离开了space。 332 |
333 | 334 | 335 | 336 |

337 | def onEnterSpace( self ): 338 |

339 | 340 |
客户端控制的实体进入了一个新的space。 341 |
342 | 343 | 344 | 345 |

346 | def onLeaveSpace( self ): 347 |

348 | 349 |
客户端控制的实体离开了当前的space。 350 |
351 | 352 | 353 | 354 |
355 |

属性文档

356 | 357 |

358 | className 359 |

360 | 361 |
实体的类名。 362 |
363 | 364 |

365 | 类型: 366 | 367 | 369 |
只读,string 368 |
370 |

371 | 372 | 373 | 374 |

375 | position 376 |

377 | 378 |
这个实体在世界空间中的坐标(x, y, z),数据由服务端同步到客户端。 379 | 380 |

381 | 382 |
383 | 384 |

385 | 类型: 386 | 387 | 389 |
Vector3 388 |
390 |

391 | 392 | 393 |

394 | direction 395 |

396 | 397 |
这个属性描述的是Entity在世界空间中的朝向,数据由服务端同步到客户端。 398 |
399 | 400 |

401 | 类型: 402 | 403 | 405 |
Vector3, 其中包含(roll, pitch, yaw),以弧度表示。 404 |
406 |

407 | 408 | 409 |

410 | isOnGround 411 |

412 | 413 |
如果这个属性的值为True,Entity在地面上,否则为False。
414 | 如果是客户端控制的实体该属性将会在改变时同步到服务端,其他实体则由服务端同步到客户端,客户端可以判断这个值来强制贴地避免精度带来的影响。 415 |
416 | 417 |

418 | 类型: 419 | 420 | 422 |
可读写, bool 421 |
423 |

424 | 425 | 426 | 427 |
428 | 429 | 430 | 431 | -------------------------------------------------------------------------------- /api/client/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine client 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine模块

12 | KBEngine模块提供了逻辑脚本层访问实体的部分, 以及当前space的数据等等。 13 |

14 | 15 | 16 | 19 | 20 |
17 | Entity 18 |
21 | 22 |

成员函数

23 | 24 | 25 | 28 | 29 | 32 | 33 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 52 | 53 | 56 | 57 | 60 | 61 |
26 | def login( username, password ): 27 |
30 | def createAccount( username, password ): 31 |
34 | def reloginBaseapp(): 35 |
38 | def player( ): 39 |
42 | def resetPassword(username): 43 |
46 | def bindAccountEmail( emailaddress ): 47 |
50 | def newPassword( oldpassword, newpassword ): 51 |
54 | def findEntity( entityID ): 55 |
58 | def getSpaceData( key ): 59 |
62 | 63 |

回调函数

64 | 65 | 66 |
67 | 68 |

属性

69 | 70 | 71 | 72 | 73 | 82 | 83 |
component  只读 string
entities  Entities 74 | 75 |
entity_uuid  uint64 76 | 77 |
entity_id  int32 78 | 79 |
spaceID  int32 80 | 81 |
84 | 85 |
86 |

成员函数文档

87 | 88 |

89 | def login( username, password ): 90 |

91 | 92 |
93 | 功能说明:

94 | 登录账号到KBEngine服务端。
95 | 注意:如果插件与UI层使用事件交互模式,在UI层不要直接调用,请触发一个"login"事件给插件,事件附带数据username和password。 96 |
97 |
98 | 99 |

100 | 参数: 101 | 102 | 103 | 106 | 107 | 110 |
username 104 | string,用户名。 105 |
password 108 | string,密码。 109 |
111 |

112 | 113 | 114 | 115 |

116 | def createAccount( username, password ): 117 |

118 | 119 |
120 | 功能说明:

121 | 请求向KBEngine服务端创建一个登录账号。
122 | 注意:如果插件与UI层使用事件交互模式,在UI层不要直接调用,请触发一个"createAccount"事件给插件,事件附带数据username和password。 123 |
124 |
125 | 126 |

127 | 参数: 128 | 129 | 130 | 133 | 134 | 137 |
username 131 | string,用户名。 132 |
password 135 | string,密码。 136 |
138 |

139 | 140 | 141 | 142 |

143 | def reloginBaseapp( ): 144 |

145 | 146 |
147 | 功能说明:

148 | 请求重登录到KBEngine服务端(通常在掉线之后希望更及时的连接到服务端并继续控制服务端角色时使用)。
149 | 注意:如果插件与UI层使用事件交互模式,在UI层不要直接调用,请触发一个"reloginBaseapp"事件给插件,事件附带数据为空。 150 |
151 |
152 | 153 | 154 | 155 |

156 | def player( ): 157 |

158 | 159 |
160 | 功能说明:

161 | 获得当前客户端所控制的实体。
162 |
163 |
164 | 165 |

166 | 返回: 167 | 168 | 171 |
169 | Entity,返回控制的实体, 如果不存在(如:未能连接到服务端)则返回空。 170 |
172 |

173 | 174 | 175 | 176 | 177 |

178 | def resetPassword( username ): 179 |

180 | 181 |
182 | 功能说明:

183 | 请求loginapp重置账号的密码, 服务端将会向该账号绑定的邮箱发送一封重置密码邮件(通常是忘记密码功能使用)。
184 |
185 |
186 | 187 |

188 | 参数: 189 | 190 | 191 | 194 |
username 192 | string,用户名。 193 |
195 |

196 | 197 | 198 | 199 |

200 | def bindAccountEmail( emailaddress ): 201 |

202 | 203 |
204 | 功能说明:

205 | 请求baseapp绑定账号的email地址。
206 |
207 |
208 | 209 |

210 | 参数: 211 | 212 | 213 | 216 |
emailaddress 214 | string,邮箱地址。 215 |
217 |

218 | 219 | 220 | 221 |

222 | def newPassword( oldpassword, newpassword ): 223 |

224 | 225 |
226 | 功能说明:

227 | 请求设置账号的新密码。
228 |
229 |
230 | 231 |

232 | 参数: 233 | 234 | 235 | 238 | 241 |
oldpassword 236 | string,旧密码。 237 |
newpassword 239 | string,新密码。 240 |
242 |

243 | 244 | 245 | 246 |

247 | def findEntity( entityID ): 248 |

249 | 250 |
251 | 功能说明:

252 | 通过实体的ID查找实体的实例对象。 253 |
254 | 255 |

256 | 参数: 257 | 258 | 259 | 262 |
entityID 260 | int32,实体ID。 261 |
263 |

264 | 265 |

266 | 返回: 267 | 268 | 271 |
269 | Entity,存在返回实体实例,不存在返回空。 270 |
272 |

273 | 274 | 275 | 276 |

277 | def getSpaceData( key ): 278 |

279 | 280 |
281 | 功能说明:

282 | 获取指定key的space数据。 283 |
284 | space数据由用户在服务端通过setSpaceData设置。 285 |
286 | 287 |

288 | 参数: 289 | 290 | 291 | 294 |
key 292 | string,一个字符串关键字。 293 |
295 |

296 | 297 |

298 | 返回: 299 | 300 | 303 |
301 | string,指定key的字符串数据。 302 |
304 |

305 | 306 |
307 |

回调函数文档

308 | 309 |

310 | 311 | 312 |

313 | 314 | 315 |
316 |

属性文档

317 | 318 |

319 | component 320 |

321 | 322 |
323 | 说明:

324 | 这是正运行在当前脚本环境的组件。(至今为止)可能值有'cellapp', 'baseapp', 'client', 'dbmgr', 'bots' 和 'editor'。 325 |
326 | 327 |

328 | entities 329 |

330 | 331 |
332 | 说明:

333 | entities是一个字典对象,包含当前进程上所有的实体。
334 |
335 | 336 |

337 | 类型: 338 | 339 | 341 |
Entities 340 |
342 |

343 | 344 |

345 | entity_uuid 346 |

347 | 348 |
349 | 说明:

350 | 实体的uuid,改ID与实体本次登录绑定。当使用重登陆功能时服务端会与此ID进行比对,判断合法性。 351 |
352 | 353 | 354 |

355 | entity_id 356 |

357 | 358 |
359 | 说明:

360 | 当前客户端所控制的实体的ID。 361 |
362 | 363 | 364 |

365 | spaceID 366 |

367 | 368 |
369 | 说明:

370 | 当前客户端控制的实体所在的空间ID(也可以理解为所在对应的场景、房间、副本)。 371 |
372 | 373 | 374 |
375 | 376 | 377 | -------------------------------------------------------------------------------- /api/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine client 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

client插件

12 | KBEngine是一个开源的游戏服务端引擎,不包含完整的客户端部分,但我们提供了能与服务端快速对接的客户端插件部分。客户端插件包含了与服务端的通讯、注册账号、登录接口、Entity基础类等等。 13 | 插件与客户端表现层之间通过一种机制进行交互,表现层获得插件的数据进行表现(例如:血量变化,实体进入View),插件获得表现层的输入进行改变(例如:角色位置与朝向)。 14 | 15 |
16 |
17 | KBEngine在不同的前端技术下实现了不同的客户端插件,但每种插件都遵循本API文档中列出的方法与属性,根据该文档不同的客户端插件都拥有了一个实现标准。 18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /api/dbmgr/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine dbmgr 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine模块

12 | KBEngine模块提供了Python脚本控制dbmgr进程处理实体登陆查询与数据存取等部分。 13 | 14 | 15 |

成员函数

16 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 | 33 | 34 |
19 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 20 |
23 | def delTimer( id ): 24 |
27 | def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): 28 |
31 | def urlopen( url, callback, postData, headers ): 32 |
35 | 36 |

回调函数

37 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 | 54 | 55 |
40 | def onDBMgrReady( ): 41 |
44 | def onDBMgrShutDown( ): 45 |
48 | def onReadyForShutDown( ): 49 |
52 | def onSelectAccountDBInterface( accountName ): 53 |
56 | 57 | 58 |
59 |

成员函数文档

60 | 61 |

62 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 63 |

64 | 65 |
66 | 功能说明:

67 | 注册一个定时器,定时器由回调函数callbackObj触发,回调函数将在"initialOffset"秒后被执行第1次,而后将每间隔"repeatOffset"秒执行1次。 68 |

69 | 例子: 70 | 71 |
# 这里是使用addTimer的一个例子
 72 |         import KBEngine
 73 |  
 74 |         # 增加一个定时器,5秒后执行第1次,而后每1秒执行1次,用户参数是9
 75 |         KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
 76 |  
 77 |         # 增加一个定时器,1秒后执行,用户参数缺省是0
 78 |         KBEngine.addTimer( 1, onTimer_Callbackfun )
 79 |  
 80 |     def onTimer_Callbackfun( id ):
 81 |         print "onTimer_Callbackfun called: id %i" % ( id )
 82 |         # if 这是不断重复的定时器,当不再需要该定时器的时候,调用下面函数移除:
 83 |         #     KBEngine.delTimer( id )
84 |
85 |
86 | 87 |

88 | 参数: 89 | 90 | 91 | 94 | 95 | 98 | 99 | 102 | 103 |
initialOffset 92 | float,指定定时器从注册到第一次回调的时间间隔(秒)。 93 |
repeatOffset 96 | float,指定第一次回调执行后每次执行的时间间隔(秒)。必须用函数delTimer移除定时器,否则它会一直重复下去。值小于等于0将被忽略。 97 |
callbackObj 100 | function,指定的回调函数对象。 101 |
104 |

105 | 106 |

107 | 返回: 108 | 109 | 111 |
integer,该函数返回timer的内部id,这个id可用于delTimer移除定时器。 110 |
112 |

113 | 114 | 115 | 116 |

117 | def delTimer( id ): 118 |

119 | 120 |
121 | 功能说明:

122 | 函数delTimer用于移除一个注册的定时器,移除后的定时器不再执行。只执行1次的定时器在执行回调后自动移除,不必要使用delTimer移除。 123 | 如果delTimer函数使用一个无效的id(例如已经移除),将会产生错误。 124 |

125 | 到KBEngine.addTimer参考定时器的一个使用例子。 126 |
127 | 128 |

129 | 参数: 130 | 131 | 132 | 135 | 136 |
id 133 | integer,它指定要移除的定时器id。 134 |
137 |

138 | 139 | 140 | 141 |

142 | def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): 143 |

144 | 145 |
146 | 功能说明:

147 | 这个脚本函数在数据库上执行原始数据库命令,该命令将直接由相关数据库进行解析。 148 |

149 | 请注意使用该函数修改实体数据可能不生效,因为如果实体已经检出,被修改过的实体数据将仍会被实体存档而导致覆盖。
150 | 强烈不推荐这个函数用于读取或修改实体数据。 151 |
152 | 153 |

154 | 参数: 155 | 156 | 157 | 160 | 161 | 162 | 184 | 185 | 189 | 190 | 193 | 194 |
command 158 | 这个数据库命令将会因为不同数据库配置方案而不同。对于方案为MySQL数据库它是一个SQL查询语句。 159 |
callback

163 | 可选参数,带有命令执行结果的回调对象(比如说是一个函数)。这个回调带有4个参数:结果集合,影响的行数,自増长值,错误信息。 164 |
165 | 声明样例:
166 | def 167 | sqlcallback(result, rows, insertid, error):
168 |     print(result, rows, insertid, error)
169 |
170 | 如同上面的例子所示,result参数对应的就是“结果集合”,这个结果集合参数是一个行列表。 171 | 每一行是一个包含字段值的字符串列表。
172 | 命令执行没有返回结果集合(比如说是DELETE命令), 173 | 或者 174 | 命令执行有错误时这个结果集合为None。 175 |

176 | rows参数则是“影响的行数”,它是一个整数,表示命令执行受影响的行数。这个参数只和不返回结果结合的命令(如DELETE)相关。
177 | 如果有结果集合返回或者命令执行有错误时这个参数为None。 178 |

179 |

insertid对应的是“自増长值”,类似于实体的databaseID,当成功的向一张带有自増长类型字段的表中插入数据时,它返回该数据在插入时自増长字段所被赋于的值。
180 | 更多的信息可以参阅mysql的mysql_insert_id()方法。另外,此参数仅在数据库类型为mysql时有意义。
181 |
182 | error则对应了“错误信息”,当命令执行有错误时,这个参数是一个描述错误的字符串。命令执行没有发生错误时这个参数为None。 183 |

threadID 186 | int32,可选参数,指定一个线程来处理本条命令。用户可以通过这个参数控制某一类命令的执行先后顺序(dbmgr是多线程处理的),默认是不指定,如果threadID是实体的ID,
187 | 那么将加入到该实体的存档队列中由线程逐条写入。 188 |
dbInterfaceName 191 | string,可选参数,指定由某个数据库接口来完成, 默认使用"default"接口。数据库接口由kbengine_defaults.xml->dbmgr->databaseInterfaces中定义。 192 |
195 |

196 | 197 | 198 | 199 |

200 | def urlopen( url, callback, postData, headers ): 201 |

202 | 203 |
204 | 功能说明:

205 | 这个脚本函数在提供对外HTTP/HTTPS异步请求。 206 |
207 | 208 |

209 | 参数: 210 | 211 | 212 | 215 | 216 | 217 | 235 | 236 | 239 | 240 | 243 | 244 |
url 213 | 有效的HTTP/HTTPS网址,字符串类型。 214 |
callback

218 | 可选参数,带有请求执行结果的回调对象(比如说是一个函数)。这个回调带有5个参数:HTTP请求返回码(如:200),返回的内容,返回的HTTP协议头,是否成功,请求的网址。 219 |
220 | 声明样例:
221 | def 222 | onHttpCallback(httpcode, data, headers, success, url):
223 |     print(httpcode, data, headers, success, url)
224 |
225 | 如同上面的例子所示: 226 |

httpcode:参数对应的就是“HTTP请求返回码”,这个结果集合参数是一个整形值。 227 |

data:参数则是“返回的内容”,它是一个字符串。 228 |

229 |

headers:参数是“服务器返回的HTTP协议头”,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 230 |

success:则对应了“执行是否成功”,当请求执行有错误时,为False,可以通过httpcode进一步判断错误信息。 231 |

232 |

url:是“请求所用的网址。 233 |

234 |
postData 237 | 可选参数,默认是GET方式请求服务器,如果需要POST方式请提供需要POST的内容,引擎将自动使用POST方式请求服务器,它是一个bytes。 238 |
headers 241 | 可选参数,请求时使用的HTTP头,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 242 |
245 |

246 | 247 | 248 | 249 |
250 |

回调函数文档

251 | 252 |

253 | def onDBMgrReady( ): 254 |

255 | 256 |
257 | 功能说明:

258 | 当前进程已经准备好的时候回调此函数。 259 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 260 |
261 | 262 | 263 | 264 |

265 | def onDBMgrShutDown( ): 266 |

267 | 268 |
269 | 功能说明:

270 | 进程关闭会回调此函数。 271 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 272 |
273 | 274 | 275 | 276 |

277 | def onReadyForShutDown( ): 278 |

279 | 280 |
281 | 功能说明:

282 | 如果这个函数在脚本中有实现,当进程准备退出时,该回调函数被调用。

283 | 284 | 可以通过该回调控制进程退出的时机。
285 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 286 |
287 | 288 |

289 | 返回: 290 | 291 | 294 |
292 | bool,如果返回True,则允许进入进程退出流程,返回其它值则进程会过一段时间后再次询问。 293 |
295 |

296 | 297 | 298 | 299 |

300 | def onSelectAccountDBInterface( accountName ): 301 |

302 | 303 |
304 | 功能说明:

305 | 这个回调实现返回某个账号对应的数据库接口,选定接口后dbmgr针对这个账号的相关操作都由对应的数据库接口完成。

306 | 数据库接口在kbengine_defaults.xml->dbmgr->databaseInterfaces定义。
307 | 利用该接口可以根据accountName来决定账号应该存储在哪个数据库。
308 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
309 |
310 | 311 |

312 | 参数: 313 | 314 | 315 | 318 | 319 |
accountName 316 | string,账号的名称。 317 |
320 |

321 | 322 |

323 | 返回: 324 | 325 | 328 |
326 | string,数据库接口名(数据库接口在kbengine_defaults.xml->dbmgr->databaseInterfaces定义)。 327 |
329 |

330 | 331 | 332 | 333 | 334 |
335 | 336 | 337 | -------------------------------------------------------------------------------- /api/dbmgr/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine dbmgr 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Dbmgr进程

12 | Dbmgr进程主要负责处理实体数据的存储与实体数据的加载查询等等。
13 | 注意:该进程脚本实现在scripts/db目录中。 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /api/htmlhelp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbengine/kbengine_docs/f24879e473d2fe91b9016e958b6b036e20d0522b/api/htmlhelp.exe -------------------------------------------------------------------------------- /api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Getting Started 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

什么是KBEngine?

15 |

16 | 一款开源的游戏服务端引擎,客户端通过简单的约定协议就能与服务端通讯, 使用KBEngine插件能够快速与(Unity3D, OGRE, Cocos2d-x, HTML5, 等等)技术结合形成一个完整的客户端。
17 | 18 | 服务端底层框架使用C++编写,游戏逻辑层使用Python(支持热更新),开发者无需重复的实现一些游戏服务端通用的底层技术, 将精力真正集中到游戏开发层面上来,快速的打造各种网络游戏。
19 | 20 | (经常被问到承载上限,kbengine底层架构被设计为多进程分布式动态负载均衡方案, 理论上只需要不断扩展硬件就能够不断增加承载上限,单台机器的承载上限取决于游戏逻辑本身的复杂度。)


21 | 22 | Homepage
23 | 24 | http://www.kbengine.org 25 |

26 | 27 | Releases 28 |
29 | sources : https://github.com/kbengine/kbengine/releases/latest
30 | binarys : https://sourceforge.net/projects/kbengine/files/
31 |

32 | Demo sources 33 |
34 | unity3d : https://github.com/kbengine/kbengine_unity3d_demo/releases/latest
35 | unity3d : https://github.com/kbengine/kbengine_unity3d_warring/releases/latest
36 | ogre : https://github.com/kbengine/kbengine_ogre_demo/releases/latest
37 | html5 : https://github.com/kbengine/kbengine_html5_demo/releases/latest
38 |

39 | Docs 40 |
41 | docs : http://www.kbengine.org/docs/
42 | API : https://github.com/kbengine/kbengine/tree/master/docs
43 |

44 | Support 45 |
46 | Email : kbesrv@gmail.com
47 | Maillist : https://groups.google.com/d/forum/kbengine_maillist
48 |

49 | 50 | 51 |

开始

52 |

53 | 您可以先看安装指南, 了解常用工具之后,您还可以去 54 | GitHub加入开源力量。 55 |

56 | 57 | 相信在对KBEngine有足够的了解之后,您会喜欢她的。 58 |

59 |

60 |

想修改和完善文档?

61 |

62 | 如果您认为文档中有什么需要改变的,那么您现在就可以改变它。只需要forking kbengine_docs与发起一个pull请求。 63 |

64 | 同样,如果你发现文档中有任何不明白的地方请提交一个issue,我将会调整该文档,让更多的人能够得到更好的理解。 65 | 66 |

67 |

68 |

69 |

70 |
71 | 72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /api/interfaces/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine interfaces 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Interfaces进程

12 | Interfaces进程主要处理KBEngine服务端与第三方平台的接入接出工作。
13 | 注意:该进程脚本实现在scripts/interface目录中。 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /api/kbengine_api.hhp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbengine/kbengine_docs/f24879e473d2fe91b9016e958b6b036e20d0522b/api/kbengine_api.hhp -------------------------------------------------------------------------------- /api/keywords.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Keywords 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

关键词释义

15 |

16 | 17 |

18 | EntityCall: 19 |

20 | 21 |
22 |

23 | 脚本层与实体远程交互的常规手段(其他参考:allClientsotherClientsclientEntity)。
24 | EntityCall对象在C++底层实现非常简单,它只包含了实体的ID、目的地的地址、实体类型、EntityCall类型。当用户请求一次远程交互时,底层首先能够通过实体类型找到实体定义的描述,
25 | 通过实体定义的描述对用户输入的数据进行检查,如果检查合法那么底层将数据打包并发往目的地,目的地进程根据协议进行解包最终调用到脚本层。

26 | 27 | 注意: EntityCall只能调用其对应def文件中声明过的方法,不能访问实体的属性以及其他任何信息。 28 | 29 |

30 | 一个实体最多可以包含三个部分:
31 | client: 当实体包括客户端部分时(通常为玩家),在服务端可以访问实体的client(EntityCall)属性。
32 | base:当实体的一部分创建在Baseapp时,在非当前Baseapp中可以访问实体的base(EntityCall)属性。
33 | cell:当实体的一部分创建在Cellapp时,在非当前Cellapp中可以访问实体的cell(EntityCall)属性。
34 |
35 | 举例:

36 | Avatar.def中定义client远程方法: 37 |
 38 | 	<ClientMethods>
 39 | 		<hello>
 40 | 		</hello>
 41 | 	</ClientMethods>
 42 | 
43 | 44 |

45 | client\Avatar.py 46 |
 47 | 	class Avatar:
 48 | 		def hello(self):
 49 | 			print("hello")
 50 | 
51 |

52 | 在GUIConsole工具的Debug页输入框中输入(请先在左边列表中勾选要调试的进程):
53 | 首先在服务端Baseapp的日志找到玩家实体(Avatar)的ID, 然后通过实体ID获得玩家实体(Avatar)或者EntityCall:
54 | >>> KBEngine.entities[玩家ID].client.hello()
55 |
56 | 此时客户端log文件中将输出"hello", 一次远程调用过程完成。 57 |
58 | 59 | 60 | 61 |

62 | KBE_ROOT: 63 |

64 | 65 |
66 |

67 | 这是一个KBEngine的环境变量,描述的是KBEngine所在的根目录。 68 |
69 | 70 | 71 | 72 |

73 | KBE_RES_PATH: 74 |

75 | 76 |
77 |

78 | 这是一个KBEngine的环境变量,描述的是KBEngine引擎能够读取到的资源目录。 79 |
80 | 81 | 82 | 83 |

84 | KBE_HYBRID_PATH: 85 |

86 | 87 |
88 |

89 | 这是一个KBEngine的环境变量,描述的是KBEngine引擎可执行文件所在的目录。 90 |
91 | 92 | 93 | 94 |

95 | entities.xml: 96 |

97 | 98 |
99 |

100 | 服务端所有有效的实体类型必须在此进行注册,引擎初始化时会根据此处依次加载实体的描述信息。 101 |
102 | 103 | 104 | 105 |

106 | kbengine_defaults.xml: 107 |

108 | 109 |
110 |

111 | 服务端默认配置,在此用户可以修改cellappbaseapp、loginapp等所有的组件配置。 112 |
113 | 注意:你可能经常需要对引擎进行升级,直接修改此处可能在升级时产生冲突,另外也不适合多个项目放在同一KBEngine环境的情况。 114 |
115 | 建议在kbengine.xml中进行重载修改,你只需要对想修改的部分按照格式在xml中重写就可以了。 116 |
117 | 118 | 119 | 120 |

121 | kbengine.xml: 122 |

123 | 124 |
125 |

126 | 服务端配置,在此用户可以修改cellappbaseapp、loginapp等所有的组件配置。

127 | 详细请参考kbengine_defaults.xml 128 |
129 | 130 | 131 | 132 |

133 | 实体 134 |

135 | 136 |
137 |

138 | 实体被定义为服务端最基本的对象,类似Python的基础对象object。
139 | 什么时候需要定义实体? 请参见http://www.kbengine.org/docs/programming/entitydef.html 140 |
141 | 142 |

143 | entity 144 |

145 | 146 |
147 |

148 | 参见: 实体 149 |
150 | 151 | 152 | 153 |

154 | View 155 |

156 | 157 |
158 |

159 | 每一个连接到服务器的客户端实体都将拥有一个View,View类似一种视图,让客户端能够对自身View内的事件传达给客户端。
160 | View与空间相关,每个View都能够设定独立的大小范围。
161 | 注意:这里描述的空间是一种抽象的概念,不一定需要和物理空间概念绑定(MMORPG除外),对于一个卡牌游戏的核心玩法,也可以认为一个房间内的玩家在一个逻辑空间中。
162 | 事件包括: 实体移动、客户端广播类型的属性改变、死亡销毁等等。 163 |
164 | 165 | 166 | 167 |

168 | Witness 169 |

170 | 171 |
172 |

173 | 目击者。
174 | 只有绑定了Witness的cell实体View才能产生作用,换句话来说witness就是客户端的一个cell代理,cellapp将View内的信息不断的通过Witness同步给客户端。
175 | 服务端一个NPC被目击者目击时会调用实体的onWitness回调,服务端可以依赖于此特性降低CPU的消耗,当一个实体
176 | 没有被目击时,用户可以停止它的任何行为。
177 |
178 | 179 | 180 |

181 | Space 182 |

183 | 184 |
185 |

186 | 空间,KBEngine在cellapp上分配一个空间,这个空间与其他空间隔离,View、陷阱、实体碰撞等等只在当前空间相互影响。
187 | 空间具体是什么由用户来定义,它可以是一个场景、副本、房间... 188 |
189 | 190 | 191 |

192 | 空间 193 |

194 | 195 |
196 |

197 | 参见: Space 198 |
199 | 200 | 201 |

202 | cell 203 |

204 | 205 |
206 |

207 | cell在文档中存在二个不同的意思。
208 | 通常如果描述的是Entity.cell属性, 此时实际是在描述实体的CellEntityCall
209 | 210 | 如果是在cellapp上有关cell的描述通常是在描述一个空间的一部分,一个空间在cellapp进行负载平衡时有可能被分割成N份,每一份称之为一个cell,每个cell由不同进程维护。
211 |
212 | 213 | 214 |

215 | base 216 |

217 | 218 |
219 |

220 | 通常是指baseapp上的Base实体或者是一个指向Base实体的BaseEntityCall, 例如:Entity.base
221 |
222 | 223 | 224 | 225 |

226 | client 227 |

228 | 229 |
230 |

231 | 通常是指客户端或者是一个指向客户端实体的EntityCall, 例如:Entity.client
232 |
233 | 234 | 235 | 236 |

237 | cellapp 238 |

239 | 240 |
241 |

242 | Cellapp进程主要负责与位置有关类游戏逻辑、View、AI、场景房间等等。
243 | 参见: cellapp 244 |
245 | 246 | 247 |

248 | baseapp 249 |

250 | 251 |
252 |

253 | Baseapp进程主要负责与客户端通讯、与位置无关类游戏逻辑(公会管理器、聊天系统、游戏大厅、排行榜等等)、存档与备份等等。
254 | 参见: baseapp 255 |
256 | 257 | 258 | 259 |

260 | real 261 |

262 | 263 |
264 |

265 | 指的是一个cell上的实体,这个实体是真实存在于当期cell上的(有一种实体只是另一个cell广播过来的影像,参见:ghost)。
266 |
267 | 268 | 269 | 270 |

271 | ghost 272 |

273 | 274 |
275 |

276 | 这种实体其实是由于cellapp动态负载均衡机制将一个完整的space分割成N份并交给不同的进程中的cell共同维护从而产生的一种边界区影像实体。
277 | 由于space被分割成多个区域,所以space存在边界。要让客户端无法感知到边界的存在我们将每个cell边界区域一定范围内的实体同步一份到另一个边邻的cell上,
278 | 这样就不会在边界区域时无法和另一个边界区的实体进行交互了。而这种实体只有部分数据被同步过来(CELL_PUBLIC等cell广播类型的属性)。
279 |
280 | 非ghost实体我们称为real实体。 281 |
282 | 283 | 284 | 285 |

286 | vector3 287 |

288 | 289 |
290 |

291 | 描述和管理3D空間的向量。
292 | 其中有x,y,z三个属性代表不同的轴向。

293 | 脚本中使用的例子: 294 | import Math 295 | v = Math.Vector3() 296 |
297 | 298 | 299 | 300 |

301 |

302 |

303 |

304 |
305 | 306 |
307 | 308 | 309 | -------------------------------------------------------------------------------- /api/logger/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine logger 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine模块

12 | KBEngine模块提供了Python脚本控制对特定类型的日志进行分析和转储等能力。 13 | 14 | 15 |

成员函数

16 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 |
19 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 20 |
23 | def delTimer( id ): 24 |
27 | def urlopen( url, callback, postData, headers ): 28 |
31 | 32 |

回调函数

33 | 34 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 |
36 | def onLoggerAppReady( ): 37 |
40 | def onLoggerAppShutDown( ): 41 |
44 | def onLogWrote( datas ): 45 |
48 | def onReadyForShutDown( ): 49 |
52 | 53 | 54 |
55 |

成员函数文档

56 | 57 |

58 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 59 |

60 | 61 |
62 | 功能说明:

63 | 注册一个定时器,定时器由回调函数callbackObj触发,回调函数将在"initialOffset"秒后被执行第1次,而后将每间隔"repeatOffset"秒执行1次。 64 |

65 | 例子: 66 | 67 |
# 这里是使用addTimer的一个例子
 68 |         import KBEngine
 69 |  
 70 |         # 增加一个定时器,5秒后执行第1次,而后每1秒执行1次,用户参数是9
 71 |         KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
 72 |  
 73 |         # 增加一个定时器,1秒后执行,用户参数缺省是0
 74 |         KBEngine.addTimer( 1, onTimer_Callbackfun )
 75 |  
 76 |     def onTimer_Callbackfun( id ):
 77 |         print "onTimer_Callbackfun called: id %i" % ( id )
 78 |         # if 这是不断重复的定时器,当不再需要该定时器的时候,调用下面函数移除:
 79 |         #     KBEngine.delTimer( id )
80 |
81 |
82 | 83 |

84 | 参数: 85 | 86 | 87 | 90 | 91 | 94 | 95 | 98 | 99 |
initialOffset 88 | float,指定定时器从注册到第一次回调的时间间隔(秒)。 89 |
repeatOffset 92 | float,指定第一次回调执行后每次执行的时间间隔(秒)。必须用函数delTimer移除定时器,否则它会一直重复下去。值小于等于0将被忽略。 93 |
callbackObj 96 | function,指定的回调函数对象。 97 |
100 |

101 | 102 |

103 | 返回: 104 | 105 | 107 |
integer,该函数返回timer的内部id,这个id可用于delTimer移除定时器。 106 |
108 |

109 | 110 | 111 | 112 |

113 | def delTimer( id ): 114 |

115 | 116 |
117 | 功能说明:

118 | 函数delTimer用于移除一个注册的定时器,移除后的定时器不再执行。只执行1次的定时器在执行回调后自动移除,不必要使用delTimer移除。 119 | 如果delTimer函数使用一个无效的id(例如已经移除),将会产生错误。 120 |

121 | 到KBEngine.addTimer参考定时器的一个使用例子。 122 |
123 | 124 |

125 | 参数: 126 | 127 | 128 | 131 | 132 |
id 129 | integer,它指定要移除的定时器id。 130 |
133 |

134 | 135 | 136 | 137 |

138 | def urlopen( url, callback, postData, headers ): 139 |

140 | 141 |
142 | 功能说明:

143 | 这个脚本函数在提供对外HTTP/HTTPS异步请求。 144 |
145 | 146 |

147 | 参数: 148 | 149 | 150 | 153 | 154 | 155 | 173 | 174 | 177 | 178 | 181 | 182 |
url 151 | 有效的HTTP/HTTPS网址,字符串类型。 152 |
callback

156 | 可选参数,带有请求执行结果的回调对象(比如说是一个函数)。这个回调带有5个参数:HTTP请求返回码(如:200),返回的内容,返回的HTTP协议头,是否成功,请求的网址。 157 |
158 | 声明样例:
159 | def 160 | onHttpCallback(httpcode, data, headers, success, url):
161 |     print(httpcode, data, headers, success, url)
162 |
163 | 如同上面的例子所示: 164 |

httpcode:参数对应的就是“HTTP请求返回码”,这个结果集合参数是一个整形值。 165 |

data:参数则是“返回的内容”,它是一个字符串。 166 |

167 |

headers:参数是“服务器返回的HTTP协议头”,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 168 |

success:则对应了“执行是否成功”,当请求执行有错误时,为False,可以通过httpcode进一步判断错误信息。 169 |

170 |

url:是“请求所用的网址。 171 |

172 |
postData 175 | 可选参数,默认是GET方式请求服务器,如果需要POST方式请提供需要POST的内容,引擎将自动使用POST方式请求服务器,它是一个bytes。 176 |
headers 179 | 可选参数,请求时使用的HTTP头,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 180 |
183 |

184 | 185 | 186 | 187 |
188 |

回调函数文档

189 | 190 |

191 | def onLoggerAppReady( ): 192 |

193 | 194 |
195 | 功能说明:

196 | 当前进程已经准备好的时候回调此函数。 197 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 198 |
199 | 200 | 201 | 202 |

203 | def onLoggerAppShutDown( ): 204 |

205 | 206 |
207 | 功能说明:

208 | 进程关闭会回调此函数。 209 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 210 |
211 | 212 | 213 | 214 |

215 | def onLogWrote( datas ): 216 |

217 | 218 |
219 | 功能说明:

220 | 如果这个函数在脚本中有实现,logger进程获得了一条新日志,该回调函数被调用。

221 | 数据库接口在kbengine_defaults.xml->dbmgr->databaseInterfaces定义。
222 | 223 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
224 |
225 | 226 |

227 | 参数: 228 | 229 | 230 | 233 | 234 |
datas 231 | bytes,日志数据。 232 |
235 |

236 | 237 | 238 | 239 |

240 | def onReadyForShutDown( ): 241 |

242 | 243 |
244 | 功能说明:

245 | 如果这个函数在脚本中有实现,当进程准备退出时,该回调函数被调用。

246 | 247 | 可以通过该回调控制进程退出的时机。
248 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 249 |
250 | 251 |

252 | 返回: 253 | 254 | 257 |
255 | bool,如果返回True,则允许进入进程退出流程,返回其它值则进程会过一段时间后再次询问。 256 |
258 |

259 | 260 | 261 | 262 | 263 |
264 | 265 | 266 | -------------------------------------------------------------------------------- /api/logger/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine logger 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Logger进程

12 | Logger进程主要负责收集KBEngine服务器所输出的日志。
13 | 注意:该进程脚本实现在scripts/logger目录中。 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /api/loginapp/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine loginapp 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine模块

12 | KBEngine模块提供了Python脚本控制loginapp进程处理实体登陆注册等部分。 13 | 14 | 15 |

成员函数

16 | 17 | 18 | 21 | 22 | 25 | 26 | 29 | 30 |
19 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 20 |
23 | def delTimer( id ): 24 |
27 | def urlopen( url, callback, postData, headers ): 28 |
31 | 32 |

回调函数

33 | 34 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 | 54 | 55 | 58 |
36 | def onLoginAppReady( ): 37 |
40 | def onLoginAppShutDown( ): 41 |
44 | def onRequestLogin( loginName, password, clientType, datas ): 45 |
48 | def onLoginCallbackFromDB( loginName, accountName, errorno, datas ): 49 |
52 | def onRequestCreateAccount( accountName, password, datas ): 53 |
56 | def onCreateAccountCallbackFromDB( accountName, errorno, datas ): 57 |
59 | 60 | 61 |
62 |

成员函数文档

63 | 64 |

65 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 66 |

67 | 68 |
69 | 功能说明:

70 | 注册一个定时器,定时器由回调函数callbackObj触发,回调函数将在"initialOffset"秒后被执行第1次,而后将每间隔"repeatOffset"秒执行1次。 71 |

72 | 例子: 73 | 74 |
# 这里是使用addTimer的一个例子
 75 |         import KBEngine
 76 |  
 77 |         # 增加一个定时器,5秒后执行第1次,而后每1秒执行1次,用户参数是9
 78 |         KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
 79 |  
 80 |         # 增加一个定时器,1秒后执行,用户参数缺省是0
 81 |         KBEngine.addTimer( 1, onTimer_Callbackfun )
 82 |  
 83 |     def onTimer_Callbackfun( id ):
 84 |         print "onTimer_Callbackfun called: id %i" % ( id )
 85 |         # if 这是不断重复的定时器,当不再需要该定时器的时候,调用下面函数移除:
 86 |         #     KBEngine.delTimer( id )
87 |
88 |
89 | 90 |

91 | 参数: 92 | 93 | 94 | 97 | 98 | 101 | 102 | 105 | 106 |
initialOffset 95 | float,指定定时器从注册到第一次回调的时间间隔(秒)。 96 |
repeatOffset 99 | float,指定第一次回调执行后每次执行的时间间隔(秒)。必须用函数delTimer移除定时器,否则它会一直重复下去。值小于等于0将被忽略。 100 |
callbackObj 103 | function,指定的回调函数对象。 104 |
107 |

108 | 109 |

110 | 返回: 111 | 112 | 114 |
integer,该函数返回timer的内部id,这个id可用于delTimer移除定时器。 113 |
115 |

116 | 117 | 118 | 119 |

120 | def delTimer( id ): 121 |

122 | 123 |
124 | 功能说明:

125 | 函数delTimer用于移除一个注册的定时器,移除后的定时器不再执行。只执行1次的定时器在执行回调后自动移除,不必要使用delTimer移除。 126 | 如果delTimer函数使用一个无效的id(例如已经移除),将会产生错误。 127 |

128 | 到KBEngine.addTimer参考定时器的一个使用例子。 129 |
130 | 131 |

132 | 参数: 133 | 134 | 135 | 138 | 139 |
id 136 | integer,它指定要移除的定时器id。 137 |
140 |

141 | 142 | 143 | 144 |

145 | def urlopen( url, callback, postData, headers ): 146 |

147 | 148 |
149 | 功能说明:

150 | 这个脚本函数在提供对外HTTP/HTTPS异步请求。 151 |
152 | 153 |

154 | 参数: 155 | 156 | 157 | 160 | 161 | 162 | 180 | 181 | 184 | 185 | 188 | 189 |
url 158 | 有效的HTTP/HTTPS网址,字符串类型。 159 |
callback

163 | 可选参数,带有请求执行结果的回调对象(比如说是一个函数)。这个回调带有5个参数:HTTP请求返回码(如:200),返回的内容,返回的HTTP协议头,是否成功,请求的网址。 164 |
165 | 声明样例:
166 | def 167 | onHttpCallback(httpcode, data, headers, success, url):
168 |     print(httpcode, data, headers, success, url)
169 |
170 | 如同上面的例子所示: 171 |

httpcode:参数对应的就是“HTTP请求返回码”,这个结果集合参数是一个整形值。 172 |

data:参数则是“返回的内容”,它是一个字符串。 173 |

174 |

headers:参数是“服务器返回的HTTP协议头”,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 175 |

success:则对应了“执行是否成功”,当请求执行有错误时,为False,可以通过httpcode进一步判断错误信息。 176 |

177 |

url:是“请求所用的网址。 178 |

179 |
postData 182 | 可选参数,默认是GET方式请求服务器,如果需要POST方式请提供需要POST的内容,引擎将自动使用POST方式请求服务器,它是一个bytes。 183 |
headers 186 | 可选参数,请求时使用的HTTP头,如:{"Content-Type": "application/x-www-form-urlencoded"},它是一个字典。 187 |
190 |

191 | 192 | 193 | 194 |
195 |

回调函数文档

196 | 197 |

198 | def onLoginAppReady( ): 199 |

200 | 201 |
202 | 功能说明:

203 | 当前进程已经准备好的时候回调此函数。 204 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 205 |
206 | 207 | 208 | 209 |

210 | def onLoginAppShutDown( ): 211 |

212 | 213 |
214 | 功能说明:

215 | 进程关闭会回调此函数。 216 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 217 |
218 | 219 | 220 | 221 |

222 | def onRequestLogin( loginName, password, clientType, datas ): 223 |

224 | 225 |
226 | 功能说明:

227 | 客户端请求服务器登陆账号时回调。

228 | 229 | 此处可以对用户登陆做一些管理控制,例如:
230 | 利用该接口可以在此截断用户的登陆,将请求记录下来进行排队并返回一个错误码告诉客户端排队状态,客户端通过不断登陆从此处获得状态。
231 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
232 |
233 | 234 |

235 | 参数: 236 | 237 | 238 | 241 | 242 | 245 | 246 | 249 | 250 | 253 | 254 |
loginName 239 | string,登陆时提交的账号名称。 240 |
password 243 | string,MD5密码。 244 |
clientType 247 | integer,客户端类型,客户端登陆时给出。 248 |
datas 251 | bytes,客户端请求时所附带的数据,可将数据转发第三方平台。 252 |
255 |

256 | 257 |

258 | 返回: 259 | 260 | 263 |
261 | Tuple,返回值分别为(错误码,真实账号名,密码,客户端类别,客户端提交的数据datas),如果没有任何需要扩展修改的则通常返回值为毁掉传入的值(KBEngine.SERVER_SUCCESS, loginName, password, clientType, datas)。 262 |
264 |

265 | 266 | 267 | 268 |

269 | def onLoginAppReady( ): 270 |

271 | 272 |
273 | 功能说明:

274 | 当前进程已经准备好的时候回调此函数。 275 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 276 |
277 | 278 | 279 | 280 |

281 | def onLoginAppShutDown( ): 282 |

283 | 284 |
285 | 功能说明:

286 | 进程关闭会回调此函数。 287 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。 288 |
289 | 290 | 291 | 292 |

293 | def onLoginCallbackFromDB( loginName, accountName, errorno, datas ): 294 |

295 | 296 |
297 | 功能说明:

298 | 客户端请求服务器登陆账号后由dbmgr返回的回调。

299 | 300 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
301 |
302 | 303 |

304 | 参数: 305 | 306 | 307 | 310 | 311 | 314 | 315 | 318 | 319 | 322 | 323 |
loginName 308 | string,登陆时提交的账号名称。 309 |
accountName 312 | string,真实的账号名称(由dbmgr处查询获得)。 313 |
errorno 316 | integer,错误码,如果非KBEngine.SERVER_SUCCESS则表示登陆失败。 317 |
datas 320 | bytes,可能是任何数据,例如:第三方平台返回的数据或者由dbmgr以及interfaces中处理登陆时返回的数据。 321 |
324 |

325 | 326 | 327 | 328 |

329 | def onRequestCreateAccount( accountName, password, data ): 330 |

331 | 332 |
333 | 功能说明:

334 | 客户端请求服务器创建账号时回调。

335 | 336 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
337 |
338 | 339 |

340 | 参数: 341 | 342 | 343 | 346 | 347 | 350 | 351 | 354 | 355 |
accountName 344 | string,客户端提交的账号名称。 345 |
password 348 | string,MD5密码。 349 |
datas 352 | bytes,客户端请求时所附带的数据,可将数据转发第三方平台。 353 |
356 |

357 | 358 |

359 | 返回: 360 | 361 | 364 |
362 | Tuple,返回值分别为(错误码,真实账号名,密码,客户端提交的数据datas),如果没有任何需要扩展修改的则通常返回值为毁掉传入的值(KBEngine.SERVER_SUCCESS, loginName, password, datas)。 363 |
365 |

366 | 367 | 368 | 369 | 370 |

371 | def onCreateAccountCallbackFromDB( accountName, errorno, datas ): 372 |

373 | 374 |
375 | 功能说明:

376 | 客户端请求服务器创建账号后由dbmgr返回的回调。

377 | 378 |
注意:该回调接口必须实现在入口模块(kbengine_defaults.xml->entryScriptFile)中。
379 |
380 | 381 |

382 | 参数: 383 | 384 | 385 | 386 | 389 | 390 | 393 | 394 | 397 | 398 |
accountName 387 | string,客户端提交的账号名称。 388 |
errorno 391 | integer,错误码,如果非KBEngine.SERVER_SUCCESS则表示登陆失败。 392 |
datas 395 | bytes,可能是任何数据,例如:第三方平台返回的数据或者由dbmgr以及interfaces中处理登陆时返回的数据。 396 |
399 |

400 | 401 | 402 | 403 | 404 |
405 | 406 | 407 | -------------------------------------------------------------------------------- /api/loginapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine loginapp 文档 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Loginapp进程

12 | Loginapp进程主要负责处理实体的注册与登陆请求。
13 | 注意:该进程脚本实现在scripts/login目录中。 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /api/style.css: -------------------------------------------------------------------------------- 1 | A.toc_heading {color:#883333;font-family:Arial;font-size:10pt;font-weight:bold;text-decoration:none;} 2 | A.toc_heading:hover {text-decoration:underline;} 3 | A.toc_entry {color:#3333FF;font-family:Arial;font-size:10pt;font-weight:normal;margin-left:10px;} 4 | 5 | BODY,DIV, TABLE, TR, TD { background:white; font-family:Arial; font-size:9.0pt; } 6 | 7 | .function_list {color:#000000;} 8 | a.function_list {color:#3333FF;font-weight:bold;text-decoration:none;} 9 | a.function_list:hover {background-color:#DDDDFF;} 10 | 11 | .function_definition, .attribute_definition {color:#000000;font-weight:bold; background-color:#bbbbbb; width:100%} 12 | 13 | .function_parameter, .function_return, .function_parameter_name, .attribute_type {color:#000000;font-weight:bold;} 14 | 15 | .function_description, .attribute_description {color:#000000;} 16 | 17 | .enumeration_list {color:#000000;} 18 | A.enumeration_list {color:#3333FF;font-weight:bold;text-decoration:none;} 19 | A.enumeration_list:hover { background-color:#DDDDFF;} 20 | 21 | .attribute_list, .class_list { color:#000000; } 22 | A.attribute_list, A.class_list { color:#3333FF; font-weight:bold; text-decoration:none;} 23 | A.attribute_list:hover, A.class_list:hover { background-color:#DDDDFF;} 24 | 25 | .module_h1 { color:#000000; font-size:13.0pt; font-weight:bold;} 26 | A.module_h1 { color:#3333FF; font-size:13pt; font-weight:bold; text-decoration:none;} 27 | A.module_h1:hover { background-color:#DDDDFF;} 28 | 29 | .argument { color:#883333; } 30 | 31 | H1 {margin-left:00.0pt;margin-top:05.0pt;margin-bottom:12.0pt;font-size:13.0pt;font-family:Arial;padding-left:2pt;padding-top:4pt;padding-bottom:4pt;color:white;background:#708090;} 32 | 33 | A.H2 { color:white; font-family:Arial; font-size:11pt;} 34 | A.H2:hover { text-background:#DDDDFF;} 35 | 36 | H2 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:12.0pt;font-size:11.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:#aaaaaa;} 37 | H3 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:03.0pt;font-size:09.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:darkgray;} 38 | H4 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:03.0pt;font-size:09.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:silver;font-style:oblique} 39 | 40 | P { background:white; font-family:Arial; font-size:9.0pt; } 41 | 42 | A { color:#3333FF; font-weight:bold; text-decoration:none;} 43 | A:hover { background-color:#DDDDFF;} 44 | 45 | /* Copyright Info */ 46 | p.copyrightFooter { text-align:right; background:#708090; color:white; } 47 | DIV.releaseDate { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:30pt; margin-bottom:0pt; } 48 | DIV.softwareInfo { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:10pt; margin-bottom:0pt; } 49 | DIV.bigworldInfo { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:10pt; margin-bottom:0pt; } 50 | DIV.periodInfo { font-size:9.0pt; font-weight:normal; color:#006699; margin-top:10pt; margin-bottom:0pt; } 51 | DIV.legal { font-size:8.0pt; font-weight:normal; color:#006699; margin-top:05pt; } 52 | -------------------------------------------------------------------------------- /api_en/Table of Contents.hhc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 220 | 221 | -------------------------------------------------------------------------------- /api_en/baseapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine baseapp 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Baseapp process

12 | The Baseapp process is mainly responsible for communication with the client, 13 | location independent game logic (guild manager, chat system, leaderboard, etc.), 14 | archiving, backup, and so on. 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /api_en/basetypes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Base Types 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

Basic data types

15 |

16 |
17 | [Name]			[Bytes]
18 | 
19 | UINT8			1
20 | UINT16			2
21 | UINT32			4
22 | UINT64			8
23 | 
24 | INT8			1
25 | INT16			2
26 | INT32			4
27 | INT64			8
28 | 
29 | FLOAT			4
30 | DOUBLE			8
31 | 
32 | VECTOR2			12
33 | VECTOR3			16
34 | VECTOR4			20
35 | 
36 | STRING			N
37 | UNICODE			N
38 | PYTHON			N
39 | PY_DICT			N
40 | PY_TUPLE			N
41 | PY_LIST			N
42 | ENTITYCALL		N
43 | BLOB			N
44 | 
45 | 46 |

47 |

48 |

49 |

50 |
51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /api_en/bots/Classes/PyClientApp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PyClientApp - KBEngine bots 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

PyClientApp class

12 | 13 |

[KBEngine module]

14 |

PyClientApp is a part of the KBEngine 15 | Module. It is is client object created when a client is simulated from 16 | the bottom of C++. It cannot be created in the script layer directly.

17 | 18 |

Member functions

19 | 20 | 21 | 24 | 25 | 28 | 29 |
22 | def getSpaceData( key ): 23 |
26 | def player( ): 27 |
30 | 31 |

Callbacks

32 | 33 | 34 |
35 | 36 |

Attributes

37 | 38 | 39 | 40 | 42 | 43 |
id  Read-only Integer 41 |
entities  Entities 44 | 45 |
46 | 47 |
48 |

A detailed description

49 | Instances of class Entity represent 50 | game objects on the client. 51 |

52 | 53 |

54 | An Entity can access its equivalent 55 | entities in the base and cell applications via ENTITYCALL. 56 | This requires a set of remotely-invoked functions (specified in the entity's .def file). 57 | 58 |
59 |

Member functions documentation

60 | 61 |

62 | def getSpaceData( key ): 63 |

64 | 65 |
66 | Function description:

67 | Get the space data of the specified key. 68 |
69 | The space data is set by the user on the server through setSpaceData. 70 |
71 | 72 |

73 | parameters: 74 | 75 | 76 | 79 |
key 77 | string, a string keyword. 78 |
80 |

81 | 82 |

83 | returns: 84 | 85 | 88 |
86 | string, string data for the key 87 |
89 |

90 | 91 | 92 | 93 |

94 | def player( ): 95 |

96 | 97 |
98 | Function description

99 | Gets the entity that the current client controls.
100 |
101 |
102 | 103 | 104 | 105 | 106 |
107 |

Callback functions documentation

108 | 109 | 110 | 111 | 112 | 113 |
114 |

Attributes documentation

115 | 116 |

117 | entities 118 |

119 | 120 |
121 | Description:

122 | entities is a dictionary object that contains all the entities in the 123 | current process.
124 |
125 | 126 |

127 | Types: 128 | 129 | 131 |
Entities 130 |
132 |

133 | 134 | 135 | 136 |
137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /api_en/bots/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine bots Îĵµ 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Bots process

12 | Bots is a kind of lightweight client program that simulates and tests the 13 | server side. Bots has no rendering parts. It can test for hidden bugs and 14 | apply load to the server through a large number of simulated client and 15 | server interactions, so that the developer can optimize the service side 16 | effectively. 17 |
18 |
19 | Note: The Bots process needs to implement the relevant client code under scripts/bots, which is extended by a Python script. 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /api_en/cellapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine cellapp 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Cellapp process

12 | The Cellapp process is primarily responsible for space-related game 13 | logic, providing players on different baseapps a real-time interaction 14 | in one space. The Cellapp can usually implement scene-related logic such 15 | as NPCs/monsters, battles, and checkpoint rooms. 16 | 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /api_en/client/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine client Îĵµ 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine module

12 | This KBEngine module provides a part of the 13 | logic script layer access to entity, 14 | as well as current space data and so on. 15 |

Class

16 | 17 | 18 | 21 | 22 |
19 | Entity 20 |
23 | 24 |

Member function

25 | 26 | 27 | 30 | 31 | 34 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 | 54 | 55 | 58 | 59 | 62 | 63 |
28 | def login( username, password ): 29 |
32 | def createAccount( username, password ): 33 |
36 | def reloginBaseapp(): 37 |
40 | def player( ): 41 |
44 | def resetPassword(username): 45 |
48 | def bindAccountEmail( emailaddress ): 49 |
52 | def newPassword( oldpassword, newpassword ): 53 |
56 | def findEntity( entityID ): 57 |
60 | def getSpaceData( key ): 61 |
64 | 65 |

Callback

66 | 67 | 68 |
69 | 70 |

Attributes

71 | 72 | 73 | 74 | 75 | 84 | 85 |
component  Read only string
entities  Entities 76 | 77 |
entity_uuid  uint64 78 | 79 |
entity_id  int32 80 | 81 |
spaceID  int32 82 | 83 |
86 | 87 |
88 |

Member functions documentation

89 | 90 |

91 | def login( username, password ): 92 |

93 | 94 |
95 | Function description:

96 | Login account to KBEngine server.
97 | Note: If the plug-in and the UI layer use event interaction mode, do 98 | not call directly from the UI layer. Please trigger a "login" event to the 99 | plug-in. The event is accompanied by the data username and password. 100 |
101 |
102 | 103 |

104 | parameter 105 | 106 | 107 | 110 | 111 | 114 |
username 108 | string, username. 109 |
password 112 | string, password. 113 |
115 |

116 | 117 | 118 | 119 |

120 | def createAccount( username, password ): 121 |

122 | 123 |
124 | Function description

125 | Request to create a login account on the KBEngine server. 126 |
127 | Note: If the plug-in and the UI layer use the event interaction mode, 128 | do not call directly from the UI layer. Please trigger a "createAccount" 129 | event to the plug-in. The event is accompanied by the data username and 130 | password. 131 |
132 |
133 | 134 |

135 | parameters: 136 | 137 | 138 | 141 | 142 | 145 |
username 139 | string, username. 140 |
password 143 | string, password. 144 |
146 |

147 | 148 | 149 | 150 |

151 | def reloginBaseapp( ): 152 |

153 | 154 |
155 | Function description

156 | Requests to re-login to the KBEngine server (usually used after a dropped 157 | connection in order to connect to the server more quickly and continue to 158 | control the server role).
159 | Note: If the plug-in and the UI layer use event interaction mode, do 160 | not call directly from the UI layer, please trigger a "reloginBaseapp" 161 | event to the plug-in, and the incidental data is empty. 162 |
163 |
164 | 165 | 166 | 167 |

168 | def player( ): 169 |

170 | 171 |
172 | Function description

173 | Gets the entity that the current client controls.
174 |
175 |
176 | 177 |

178 | return: 179 | 180 | 184 |
181 | Entity, return controlled entity, 182 | if it does not exist (e.g.: failed to connect to the server) returns null. 183 |
185 |

186 | 187 | 188 | 189 | 190 |

191 | def resetPassword( username ): 192 |

193 | 194 |
195 | Function description

196 | Asks loginapp to reset the password of the account. The server will send 197 | a password reset email (usually the forgotten password function) to the 198 | email address to which the account is bound.
199 |
200 |
201 | 202 |

203 | parameters: 204 | 205 | 206 | 209 |
username 207 | string, username. 208 |
210 |

211 | 212 | 213 | 214 |

215 | def bindAccountEmail( emailaddress ): 216 |

217 | 218 |
219 | Function description

220 | Requests Baseapp to bind the email address of the account.
221 |
222 |
223 | 224 |

225 | parameters: 226 | 227 | 228 | 231 |
emailaddress 229 | string, email address. 230 |
232 |

233 | 234 | 235 | 236 |

237 | def newPassword( oldpassword, newpassword ): 238 |

239 | 240 |
241 | Function description

242 | Requests to set a new password for the account.
243 |
244 |
245 | 246 |

247 | parameters: 248 | 249 | 250 | 253 | 256 |
oldpassword 251 | string, old password 252 |
newpassword 254 | string, new password 255 |
257 |

258 | 259 | 260 | 261 |

262 | def findEntity( entityID ): 263 |

264 | 265 |
266 | Function description

267 | Finds an instance object of an entity by its ID. 268 |
269 | 270 |

271 | parameters: 272 | 273 | 274 | 277 |
entityID 275 | int32, entity ID. 276 |
278 |

279 | 280 |

281 | returns: 282 | 283 | 287 |
284 | Entity An entity instance is returned. 285 | There can be no return null. 286 |
288 |

289 | 290 | 291 | 292 |

293 | def getSpaceData( key ): 294 |

295 | 296 |
297 | Function description

298 | Gets the space data for the specified key. 299 |
300 | The space data is set by the user on the server through 301 | setSpaceData. 302 |
303 | 304 |

305 | parameters: 306 | 307 | 308 | 311 |
key 309 | string, a keyword 310 |
312 |

313 | 314 |

315 | returns: 316 | 317 | 320 |
318 | string, specifies the value at the key 319 |
321 |

322 | 323 |
324 |

Callback function documentation

325 | 326 |

327 | 328 | 329 |

330 | 331 | 332 |
333 |

Attributes documentation

334 | 335 |

336 | component 337 |

338 | 339 |
340 | Description:

341 | This is the component that is running in the current scripting environment. 342 | (So far) Possible values are 'cellapp', 'baseapp', 'client', 'dbmgr', 'bots' 343 | and 'editor'. 344 |
345 | 346 |

347 | entities 348 |

349 | 350 |
351 | Description:

352 | entities is a dictionary object that contains all the entities in the current process. 353 |
354 | 355 |

356 | Types: 357 | 358 | 360 |
Entities 359 |
361 |

362 | 363 |

364 | entity_uuid 365 |

366 | 367 |
368 | Description:

369 | The uuid of the entity. Change the ID and entity to bind to this login. 370 | When using the heavy login function, the server compares this ID and 371 | determines the validity. 372 |
373 | 374 | 375 |

376 | entity_id 377 |

378 | 379 |
380 | Description:

381 | The ID of the entity controlled by the current client. 382 |
383 | 384 | 385 |

386 | spaceID 387 |

388 | 389 |
390 | Description:

391 | The ID of the Space where the 392 | entity controlled by the current client is located (also can be understood 393 | as the corresponding scene, room, and copy). 394 |
395 | 396 | 397 |
398 | 399 | 400 | 401 | -------------------------------------------------------------------------------- /api_en/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine client Îĵµ 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Client Plugins

12 | KBEngine is an open source game server engine that does not include the 13 | complete client part, but we provide multiple client plug-ins that can quickly 14 | interface with the server. Client plug-ins handle communication with 15 | the server, registering accounts, login interface, provide an Entity base class, and 16 | so on. The plug-in layer and the client UI layer interface with each other to 17 | form a complete game client. 18 | The plug-in provides the UI layer updated data for display received from 19 | the server (eg, HP changes, the entities entering the clients View), 20 | and the UI layer provides the plug-in layer with updated data to send back to the 21 | server based on the clients input (e.g., the position and orientation of the character). 22 |
23 |
24 | 25 | KBEngine implements different client plug-ins under different front-end 26 | technologies, but each plug-in follows the methods and attributes listed 27 | in this section of the API documentation. All plug-ins follow the same implementation standard 28 | outlined here in the "Client Plugins" section of the documentation. 29 | 30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /api_en/dbmgr/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine dbmgr 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine module

12 | This KBEngine module provides Python scripts to 13 | control the dbmgr process to handle entity login queries and data access. 14 | 15 | 16 |

Member functions

17 | 18 | 19 | 22 | 23 | 26 | 27 | 30 | 31 | 34 | 35 |
20 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 21 |
24 | def delTimer( id ): 25 |
28 | def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): 29 |
32 | def urlopen( url, callback, postData, headers ): 33 |
36 | 37 |

Callbacks

38 | 39 | 40 | 43 | 44 | 47 | 48 | 51 | 52 | 55 | 56 |
41 | def onDBMgrReady( ): 42 |
45 | def onDBMgrShutDown( ): 46 |
49 | def onReadyForShutDown( ): 50 |
53 | def onSelectAccountDBInterface( accountName ): 54 |
57 | 58 | 59 |
60 |

Member functions documentation

61 | 62 |

63 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 64 |

65 | 66 |
67 | Function description:

68 | Registers a timer. The timer triggers the callback function specified 69 | by callbackObj. The callback will be executed the first time after 70 | "initialOffset" seconds, and then executed once every "repeatOffset" 71 | seconds. 72 |

73 | Example: 74 | 75 |
# Here is an example of using addTimer
 76 |         import KBEngine
 77 |  
 78 |         # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9
 79 |         KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
 80 |  
 81 |         # Add a timer and execute it after 1 second. The default user parameter is 0.
 82 |         KBEngine.addTimer( 1, onTimer_Callbackfun )
 83 |  
 84 |     def onTimer_Callbackfun( id ):
 85 |         print "onTimer_Callbackfun called: id %i" % ( id )
 86 |         # If this is a repeated timer, it is no longer needed, call the following function to remove: 
 87 |         #     KBEngine.delTimer( id )
88 |
89 |
90 | 91 |

92 | parameters: 93 | 94 | 95 | 99 | 100 | 106 | 107 | 110 | 111 |
initialOffset 96 | float, specifies the time interval in seconds for the timer to register 97 | the first callback. 98 |
repeatOffset 101 | float, specifies the time interval (in seconds) after each execution of 102 | the first callback execution. You must remove the timer with the function 103 | delTimer, otherwise it will continue to repeat. 104 | Values less than or equal to 0 will be ignored. 105 |
callbackObj 108 | function, the specified callback function object. 109 |
112 |

113 | 114 |

115 | returns: 116 | 117 | 120 |
integer, this function returns the internal id of the timer. 118 | This id can be used to remove the timer using delTimer. 119 |
121 |

122 | 123 | 124 | 125 |

126 | def delTimer( id ): 127 |

128 | 129 |
130 | Function description:

131 | The delTimer function is used to remove a registered timer. The removed 132 | timer is no longer executed. Single-shot timers are automatically removed 133 | after the callback is executed, and it is not necessary to use delTimer 134 | to remove it. If the delTimer function receives an invalid id (for 135 | example, it was removed), it will generate an error. 136 | 137 |

138 | A use case is in the KBEngine.addTimer example. 139 |
140 | 141 |

142 | parameters: 143 | 144 | 145 | 148 | 149 |
id 146 | integer, specifies the timer id to remove. 147 |
150 |

151 | 152 | 153 | 154 |

155 | def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): 156 |

157 | 158 |
159 | Function description:

160 | This script function executes a database command on the database, which 161 | is directly parsed by the relevant database. 162 |

163 | Please note that using this function to modify entity data may not be 164 | effective because if the entity has been checked out, the modified data 165 | will still be archived by the entity and cause overwriting.
166 | This function is strongly not recommended for reading or modifying entity data. 167 |
168 | 169 |

170 | parameters: 171 | 172 | 173 | 177 | 178 | 179 | 216 | 217 | 224 | 225 | 229 | 230 |
command 174 | This database command will be different for different database configuration 175 | scenarios. For a MySQL database it is an SQL query. 176 |
callback

180 | Optional parameter, callback object (for example, a function) called 181 | back with the command execution result.
182 | This callback has 4 parameters: result set, number of rows affected, 183 | auto value, error message.
184 | Example:
185 | def sqlcallback(result, rows, insertid, error): 186 |     print(result, rows, insertid, error) 187 |

188 | 189 | As the above example shows, the result parameter corresponds to the 190 | "result set", and the result set parameter is a row List. Each line is a 191 | list of strings containing field values. If the command execution does not 192 | return a result set (for example, a DELETE command), or the command 193 | execution encounters an error, the result set is None. 194 |

195 | 196 | The rows parameter is the "number of rows affected", which is an integer 197 | indicating the number of rows affected by the command execution. This 198 | parameter is only relevant for commands that do not return results 199 | (such as DELETE).
200 | This parameter is None if there is a result set return or if there is an 201 | error in the command execution. 202 |

203 | 204 | The insertid is a long value, similar to an entity's databaseID. When 205 | successfully inserting data int a table with an auto long type field, it 206 | returns the data at the time of insertion.
207 | More information can be found in mysql's mysql_insert_id() method. In 208 | addition, this parameter is only meaningful when the database type is 209 | mysql. 210 |

211 | 212 | Error corresponds to the "error message", when the command execution 213 | encounters an error, this parameter is a string describing the error. 214 | This parameter is None when the command execution has not occurred. 215 |

threadID 218 | int32, optional parameter, specifies a thread to process this command. 219 | Users can use this parameter to control the execution order of certain 220 | commands (dbmgr is multi-threaded). The default is not specified. If threadId 221 | is the ID of an entity, it will be added to the entity's archive queue 222 | and written by the thread one by one. 223 |
dbInterfaceName 226 | string, optional parameter, specifies a database interface. By default it 227 | uses the "default" interface. Database interfaces are defined by kbengine_defaults.xml->dbmgr->databaseInterfaces. 228 |
231 |

232 | 233 | 234 | 235 |

236 | def urlopen( url, callback, postData, headers ): 237 |

238 | 239 |
240 | Function description:

241 | This script function is providing an external HTTP/HTTPS asynchronous request. 242 |
243 | 244 |

245 | parameters: 246 | 247 | 248 | 251 | 252 | 253 | 272 | 273 | 276 | 277 | 280 | 281 |
url 249 | A valid HTTP/HTTPS URL. 250 |
callback

254 | Optional parameter with a callback object (for example, a function) that requests execution results. This callback takes five parameters: the HTTP request return code (eg: 200), 255 | the returned content, the returned HTTP protocol header, whether it succeeded, and the requested URL. 256 |
257 | Example:
258 | def 259 | onHttpCallback(httpcode, data, headers, success, url):
260 |     print(httpcode, data, headers, success, url)
261 |
262 | As the above example shows: 263 |

httpcode:The parameter corresponds to the "HTTP request return code", is an integer. 264 |

data:The parameter is “ returned content & rdquo;, it is a string. 265 |

266 |

headers:The parameter is the HTTP protocol header returned by the server, such as:{"Content-Type": "application/x-www-form-urlencoded"}, is an dict. 267 |

success:Whether the execution is successful or not, when the request execution has an error, it is False, and the error information can be further judged by httpcode. 268 |

269 |

url:Is the URL used by the request. 270 |

271 |
postData 274 | Optional parameter, the default is GET mode request server. If you need POST mode, please provide the content that needs POST. The engine will automatically request the server using POST, is an bytes. 275 |
headers 278 | Optional parameter, HTTP header used when requesting, such as:{"Content-Type": "application/x-www-form-urlencoded"}, is an dict. 279 |
282 |

283 | 284 | 285 | 286 | 287 |
288 |

Callback functions documentation

289 | 290 |

291 | def onDBMgrReady( ): 292 |

293 | 294 |
295 | Function description:

296 | This function is called back when the current process is ready. 297 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 298 |
299 | 300 | 301 | 302 |

303 | def onDBMgrShutDown( ): 304 |

305 | 306 |
307 | Function description:

308 | This function is called when the process shuts down. 309 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 310 |
311 | 312 | 313 | 314 |

315 | def onReadyForShutDown( ): 316 |

317 | 318 |
319 | Function description:

320 | If this function is implemented in a script, the callback function is called when the process is ready to exit.

321 | 322 | You can use this callback to control when the process exits.
323 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 324 |
325 | 326 |

327 | returns: 328 | 329 | 333 |
330 | bool, if it returns True, it allows the process to exit. Returning other 331 | values will cause the process to ask again after a period of time. 332 |
334 |

335 | 336 | 337 | 338 |

339 | def onSelectAccountDBInterface( accountName ): 340 |

341 | 342 |
343 | Function description:

344 | When implemented in a script, this callback returns the database interface 345 | corresponding to an account. After the interface is selected, the dbmgr 346 | operations related to this account are completed by the corresponding 347 | database interface. 348 |

349 | Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces.
350 | Use this function to determine which database the account should be stored 351 | in based on accountName.
352 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
353 |
354 | 355 |

356 | parameters: 357 | 358 | 359 | 362 | 363 |
accountName 360 | string, the name of the account. 361 |
364 |

365 | 366 |

367 | returns: 368 | 369 | 372 |
370 | string, the database interface name (database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces). 371 |
373 |

374 | 375 | 376 | 377 | 378 |
379 | 380 | 381 | 382 | -------------------------------------------------------------------------------- /api_en/dbmgr/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine dbmgr 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Dbmgr process

12 | The Dbmgr process is mainly responsible for handling the storage of 13 | entity data and loading/querying of entity data.
14 | Note: This process script is implemented in the scripts/db directory. 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /api_en/htmlhelp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbengine/kbengine_docs/f24879e473d2fe91b9016e958b6b036e20d0522b/api_en/htmlhelp.exe -------------------------------------------------------------------------------- /api_en/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Getting Started 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

What is KBEngine?

15 |

16 | 17 | KBEngine is an open source game server engine. The client can communicate with the server through a simple protocol. 18 | KBEngine plugins can be quickly combined with (Unity3D, OGRE, Cocos2d-x, HTML5, 19 | etc.) technology to form a complete game client. The server-side low-level 20 | framework is written in C++, and the game logic layer uses Python (supports hot-fixing). 21 | Developers do not need to repeatedly implement the underlying 22 | technologies common to some game servers, and instead can focus their efforts 23 | on the game development level, to quickly build various multiplayer games. 24 |

25 | (Because it is often asked what the upper limit of the load is that KBEngine can handle, the underlying 26 | architecture has been designed as a multi-process distributed dynamic load balancing solution. Theoretically, 27 | by continuously expanding the hardware, the upper limit of the load can also be continuously increased. 28 | The upper limit of the capacity of a single machine depends on the complexity of the game logic itself.) 29 |

30 | 31 | Homepage
32 | 33 | http://www.kbengine.org 34 |

35 | 36 | Releases 37 |
38 | sources : https://github.com/kbengine/kbengine/releases/latest
39 | binarys : https://sourceforge.net/projects/kbengine/files/
40 |

41 | Demo sources 42 |
43 | unity3d : https://github.com/kbengine/kbengine_unity3d_demo/releases/latest
44 | unity3d : https://github.com/kbengine/kbengine_unity3d_warring/releases/latest
45 | ogre : https://github.com/kbengine/kbengine_ogre_demo/releases/latest
46 | html5 : https://github.com/kbengine/kbengine_html5_demo/releases/latest
47 |

48 | Docs 49 |
50 | docs : http://www.kbengine.org/docs/
51 | API : https://github.com/kbengine/kbengine/tree/master/docs
52 |

53 | Support 54 |
55 | Email : kbesrv@gmail.com
56 | Maillist : https://groups.google.com/d/forum/kbengine_maillist
57 |

58 | 59 | 60 |

Start

61 |

62 | You can look at the installation guide first. 63 | After learning about the common tools, you can go to 64 | GitHub to join our open source team. 65 |

66 | 67 | I believe that after you have enough knowledge of KBEngine, you will like it. 68 |

69 |

70 |

Want to modify and improve the documentation?

71 |

72 | If you think there is something in the documentation that needs to be changed, you can 73 | fork kbengine_docs 74 | and submit a pull request. 75 |

76 | Again, if you find anything in the documentation that you don't understand, 77 | please submit an issue, 78 | and I will adjust the document to help everyone have a better understanding. 79 | 80 |

81 |

82 |

83 |

84 |
85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /api_en/interfaces/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine interfaces 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Interfaces process

12 | The Interfaces process handles access to third-party platforms for the KBEngine server.
13 | 14 | Note: This processes scripts are is implemented in the scripts/interface directory. 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /api_en/kbengine_api.hhp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kbengine/kbengine_docs/f24879e473d2fe91b9016e958b6b036e20d0522b/api_en/kbengine_api.hhp -------------------------------------------------------------------------------- /api_en/keywords.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | KBEngine - Keywords 6 | 7 | 8 | 9 | 10 | 11 | 12 |
KBEngine

13 | 14 |

Keywords Used

15 |

16 | 17 |

18 | EntityCall: 19 |

20 | 21 |
22 |

23 | This is the conventional means of remote interaction between entities in 24 | the script layer. (other references: allClients, 25 | otherClients, 26 | clientEntity). 27 | 28 |

29 | 30 | The EntityCall object is very simple to implement in the underlying C++, it contains only the ID of the entity, 31 | the address of the destination, the entity type, and type of EntityCall. 32 | 33 | When a remote call is requested by the user, 34 | the engine first finds a description of the entity definition through the entity type, 35 | and checks the data input by the user against the description of the entity definition. 36 | If the check is legal, then the data is packaged and sent to the destination 37 | according to the protocol. 38 |

39 | Note: An EntityCall can only be used to call methods declared in its corresponding 40 | def file. It cannot call any of KBEngine's basic Entity class functions or 41 | access entity attributes. 42 | 43 |

44 | An Entity can contain up to three parts:
45 | Client: When an entity includes a client part (usually a 46 | player), the entity's client (EntityCall) property can be accessed on the 47 | server side.
48 | Base: When an entity includes a baseapp part, the base (EntityCall) 49 | attribute of the entity can be accessed in a non-current baseapp.
50 | Cell: When an entity includes a cellapp part, the cell (EntityCall) 51 | attribute of the entity can be accessed in a non-current cellapp.
52 | 53 |
54 | 55 | Example:

56 | Client remote method defined in Avatar.def: 57 |
 58 | 	<ClientMethods>
 59 | 		<hello>
 60 | 		</hello>
 61 | 	</ClientMethods>
 62 | 
63 | 64 |

65 | client\Avatar.py 66 |
 67 | 	class Avatar:
 68 | 		def hello(self):
 69 | 			print("hello")
 70 | 
71 |

72 | 73 | Enter in the Debug page input box of the GUIConsole tool (check the 74 | process to be debugged first in the list on the left):
75 | First find the ID of the player entity (Avatar) in the log of the server's 76 | Baseapp, and then get the player entity (Avatar) or EntityCall through 77 | the entity ID:

78 | 79 | >>> KBEngine.entities[Player ID].client.hello()
80 |
81 | At this point, the client log file will output "hello" and a remote call 82 | process will be completed. 83 |
84 | 85 | 86 | 87 |

88 | KBE_ROOT: 89 |

90 | 91 |
92 |

93 | This is a KBEngine environment variable that describes the root directory 94 | where KBEngine is located. 95 |
96 | 97 | 98 | 99 |

100 | KBE_RES_PATH: 101 |

102 | 103 |
104 |

105 | This is a KBEngine environment variable that describes the resource 106 | directory that KBEngine engine can read. 107 |
108 | 109 | 110 | 111 |

112 | KBE_HYBRID_PATH: 113 |

114 | 115 |
116 |

117 | This is a KBEngine environment variable that describes the directory 118 | where the KBEngine engine executable file is located. 119 |
120 | 121 | 122 | 123 |

124 | entities.xml: 125 |

126 | 127 |
128 |

129 | All valid entity types on the server must be registered here. When the 130 | engine is initialized, the description of the entity is loaded according 131 | to the order. 132 |
133 | 134 | 135 | 136 |

137 | kbengine_defaults.xml: 138 |

139 | 140 |
141 |

142 | Server-side default configuration, where users can modify all component 143 | configurations such as cellapp, 144 | baseapp, and loginapp. 145 | 146 |

147 | Note: You may often need to upgrade the engine. Modifying directly may 148 | cause conflicts during the upgrade, and it is not suitable for multiple 149 | projects in the same KBEngine environment. 150 |

151 | 152 | It is recommended that you modify the overload in 153 | kbengine.xml. You only need to rewrite the 154 | parts you want to modify according to the format in xml. 155 | 156 |
157 | 158 | 159 | 160 |

161 | kbengine.xml: 162 |

163 | 164 |
165 |

166 | Server configuration file, where users can modify all component configurations 167 | such as cellapp, 168 | baseapp, and loginapp.
169 | For details, please refer to kbengine_defaults.xml 170 |
171 | 172 | 173 | 174 |

175 | entity 176 |

177 | 178 |
179 |

180 | Entity is defined as the most basic object of the server, similar to 181 | Python's base object.
182 | When and how should you define an entity? See http://www.kbengine.org/docs/programming/entitydef.html 183 |
184 | 185 |

186 | View 187 |

188 | 189 |
190 |

191 | Each client entity connected to the server will have a View. It allows 192 | the client entity to communicate events in its View to its own client.
193 | View is related to space, and each View can be set to an independent size 194 | range. 195 |

196 | Note: The space described here is an abstract concept and does not 197 | necessarily need to be bound to the concept of physical space (except 198 | for MMORPGs). For the core gameplay of a card game, players in a room can 199 | also be considered to be in a logical space. 200 |

201 | Events include: entity movement, property change of client broadcast type, 202 | destruction on death, and so on. 203 | 204 |
205 | 206 | 207 | 208 |

209 | Witness 210 |

211 | 212 |
213 |

214 | Eyewitness.
215 | Only Witnesses bound to cell entity Views take effect. 216 | In other words, Witness is a cell proxy of the client. 217 | The cellapp continuously synchronizes the information in the View to the 218 | client through the Witness.
219 | When an NPC on the server is seen by a witness, it call the onWitness 220 | callback of the entity. The server can rely on this feature to reduce CPU 221 | consumption. When an entity is not witnessed, the server can stop any of 222 | its behavior.
223 |
224 | 225 | 226 |

227 | Space 228 |

229 | 230 |
231 |

232 | A space KBEngine allocates on the cellapp, which is isolated 233 | from other spaces. Views, traps, entity collisions, etc. only interact with each 234 | other in the current space. The space is defined by the user. It can be 235 | a scene, copy, room... 236 |
237 | 238 | 239 |

240 | cell 241 |

242 | 243 |
244 |

245 | There are two different meanings of cell in this documentation. 246 | Usually, when referring to the Entity.cell 247 | attribute, you are actually describing the entity's CellEntityCall.
248 |
249 | If a cell is described as part of a space, it refers to cellapp's load 250 | balancing technique. A space in the cellapp may be divided into n parts, 251 | each called a cell, and each cell is maintained by a different process. 252 |
253 |
254 | 255 | 256 |

257 | base 258 |

259 | 260 |
261 |

262 | Usually refers to the Base entity on the baseapp 263 | or a BaseEntityCall that points to the Base entity.
264 | For example: Entity.base 265 |
266 | 267 | 268 | 269 |

270 | client 271 |

272 | 273 |
274 |

275 | Usually refers to the client or an EntityCall 276 | that points to the client entity.
277 | For example: Entity.client 278 |
279 | 280 | 281 | 282 |

283 | cellapp 284 |

285 | 286 |
287 |

288 | The Cellapp process in mainly responsible for position-related game logic, 289 | View, AI, scene rooms, and so on.
290 | See also: cellapp 291 |
292 | 293 | 294 |

295 | baseapp 296 |

297 | 298 |
299 |

300 | The Baseapp process is mainly responsible for communication with the client, 301 | position-independent game logic (guild manager, chat system, game lobby, 302 | leaderboard, etc.), archiving, backup, and so on.
303 | See also: baseapp 304 |
305 | 306 | 307 | 308 |

309 | real 310 |

311 | 312 |
313 |

314 | Refers to an entity in a cell that is actually present in the cell at that 315 | time. (As opposed to a ghost entity broadcast there by another cell) 316 |
317 | 318 | 319 | 320 |

321 | ghost 322 |

323 | 324 |
325 |

326 | This kind of entity is a projected copy generated by cellapp's dynamic load 327 | balancing mechanism which divides a space into N shares and splits the cells 328 | between different processes.
329 | Space is divided into multiple regions. To make the client unable to 330 | perceive the existence of the boundaries between them, we synchronize a 331 | certain range of entities in each cell's boundary to an adjacent cell's 332 | boundary. The entity has a part of its data synchronized over 333 | (CELL_PUBLIC, cell broadcast types of attributes) to a ghost entity. In 334 | this way the entity can interact seamlessly with the other side of the boundary 335 | and both cells simultaneously. 336 |

337 | Non-ghost entities are called real entities. 338 |
339 | 340 | 341 | 342 |

343 | vector3 344 |

345 | 346 |
347 |

348 | 349 | Describe and manage 3D space vectors.
350 | There are three properties of x, y, and z that represent different axial directions.

351 | 352 | Example in script: import Math v = Math.Vector3() 353 |
354 | 355 | 356 | 357 |

358 |

359 |

360 |

361 |
362 | 363 | 364 | 365 | 366 | -------------------------------------------------------------------------------- /api_en/logger/Modules/KBEngine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine logger 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

KBEngine module

12 | This KBEngine module provides 13 | Python scripts the ability to control, analyze, and dump certain types 14 | of logs. 15 | 16 | 17 |

Member functions

18 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 |
21 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 22 |
25 | def delTimer( id ): 26 |
29 | def urlopen( url, callback, postData, headers ): 30 |
33 | 34 |

Callbacks

35 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 52 | 53 |
38 | def onLoggerAppReady( ): 39 |
42 | def onLoggerAppShutDown( ): 43 |
46 | def onLogWrote( datas ): 47 |
50 | def onReadyForShutDown( ): 51 |
54 | 55 | 56 |
57 |

Member functions documentation

58 | 59 |

60 | def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): 61 |

62 | 63 |
64 | Function description:

65 | Registers a timer. The timer triggers the callback function callbackObj. 66 | The callback function will be executed the first time after "initialOffset" 67 | seconds, and then will be executed once every "repeatOffset" seconds. 68 |

69 | Example: 70 | 71 |
# Here is an example of using addTimer
 72 |         import KBEngine
 73 |  
 74 |         # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9
 75 |         KBEngine.addTimer( 5, 1, onTimer_Callbackfun )
 76 |  
 77 |         # Add a timer and execute it after 1 second. The default user parameter is 0.
 78 |         KBEngine.addTimer( 1, onTimer_Callbackfun )
 79 |  
 80 |     def onTimer_Callbackfun( id ):
 81 |         print "onTimer_Callbackfun called: id %i" % ( id )
 82 |         # If this is a repeated timer, it is no longer needed, call the following function to remove: 
 83 |         #     KBEngine.delTimer( id )
84 |
85 |
86 | 87 |

88 | parameters: 89 | 90 | 91 | 94 | 95 | 101 | 102 | 105 | 106 |
initialOffset 92 | float, specifies the time interval in seconds for the timer to register from the first callback. 93 |
repeatOffset 96 | float, specifies the time interval (in seconds) between each execution after 97 | the first callback execution. You must remove the timer with the function 98 | delTimer, otherwise it will continue to repeat. 99 | Values less than or equal to 0 will be ignored. 100 |
callbackObj 103 | function, the specified callback function object 104 |
107 |

108 | 109 |

110 | returns: 111 | 112 | 115 |
integer, the internal id of the timer. This id can be used to 113 | remove the timer from delTimer. 114 |
116 |

117 | 118 | 119 | 120 |

121 | def delTimer( id ): 122 |

123 | 124 |
125 | Function description:

126 | The delTimer function is used to remove a registered timer. The removed timer is 127 | no longer executed. Single-shot timers are automatically removed after 128 | the callback is executed, and it is not necessary to use the delTimer 129 | function to remove it. If the delTimer function is passed an invalid id 130 | (for example, timer was removed), it will generate an error. 131 |

132 | A use case is shown in the KBEngine.addTimer example. 133 |
134 | 135 |

136 | parameters: 137 | 138 | 139 | 142 | 143 |
id 140 | integer, which specifies the timer id to remove. 141 |
144 |

145 | 146 | 147 | 148 |

149 | def urlopen( url, callback, postData, headers ): 150 |

151 | 152 |
153 | Function description:

154 | This script function is providing an external HTTP/HTTPS asynchronous request. 155 |
156 | 157 |

158 | parameters: 159 | 160 | 161 | 164 | 165 | 166 | 185 | 186 | 189 | 190 | 193 | 194 |
url 162 | A valid HTTP/HTTPS URL. 163 |
callback

167 | Optional parameter with a callback object (for example, a function) that requests execution results. This callback takes five parameters: the HTTP request return code (eg: 200), 168 | the returned content, the returned HTTP protocol header, whether it succeeded, and the requested URL. 169 |
170 | Example:
171 | def 172 | onHttpCallback(httpcode, data, headers, success, url):
173 |     print(httpcode, data, headers, success, url)
174 |
175 | As the above example shows: 176 |

httpcode:The parameter corresponds to the "HTTP request return code", is an integer. 177 |

data:The parameter is “ returned content & rdquo;, it is a string. 178 |

179 |

headers:The parameter is the HTTP protocol header returned by the server, such as:{"Content-Type": "application/x-www-form-urlencoded"}, is an dict. 180 |

success:Whether the execution is successful or not, when the request execution has an error, it is False, and the error information can be further judged by httpcode. 181 |

182 |

url:Is the URL used by the request. 183 |

184 |
postData 187 | Optional parameter, the default is GET mode request server. If you need POST mode, please provide the content that needs POST. The engine will automatically request the server using POST, is an bytes. 188 |
headers 191 | Optional parameter, HTTP header used when requesting, such as:{"Content-Type": "application/x-www-form-urlencoded"}, is an dict. 192 |
195 |

196 | 197 | 198 | 199 |
200 |

Callback functions documentation

201 | 202 |

203 | def onLoggerAppReady( ): 204 |

205 | 206 |
207 | Function description:

208 | This function is called back when the current process is ready. 209 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 210 |
211 | 212 | 213 | 214 |

215 | def onLoggerAppShutDown( ): 216 |

217 | 218 |
219 | Function description:

220 | This function is called back when the process shuts down. 221 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 222 |
223 | 224 | 225 | 226 |

227 | def onLogWrote( datas ): 228 |

229 | 230 |
231 | Function description:

232 | If this function is implemented in the script, it is invoked when the 233 | logger process obtains a new log.

234 | The database interface is defined in kbengine_defaults.xml->dbmgr->databaseInterfaces.
235 | 236 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile).
237 |
238 | 239 |

240 | parameters: 241 | 242 | 243 | 246 | 247 |
datas 244 | bytes, log data. 245 |
248 |

249 | 250 | 251 | 252 |

253 | def onReadyForShutDown( ): 254 |

255 | 256 |
257 | Function description:

258 | If this function is implemented in the script, it is called when the 259 | process is ready to exit.

260 | 261 | You can use this callback to control when the process exits.
262 |
Note: This callback interface must be implemented in the portal module ( kbengine_defaults.xml ->entryScriptFile). 263 |
264 | 265 |

266 | returns: 267 | 268 | 272 |
269 | bool, if it returns True, it allows the process to exit. Returning other 270 | values will cause the process to ask again after a period of time. 271 |
273 |

274 | 275 | 276 | 277 | 278 |
279 | 280 | 281 | 282 | -------------------------------------------------------------------------------- /api_en/logger/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine logger Îĵµ 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Logger process

12 | The Logger process is responsible for collecting logs output by the 13 | KBEngine server.
14 | 15 | Note: This process script is implemented in the scripts/logger directory. 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /api_en/loginapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | KBEngine - KBEngine loginapp Îĵµ 5 | 6 | 7 | 8 | 9 | 10 |
KBEngine

11 |

Loginapp process

12 | The Loginapp process is primarily responsible for handling entity 13 | registration and login requests.
14 | Note: This process script is implemented in the scripts/login directory. 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /api_en/style.css: -------------------------------------------------------------------------------- 1 | A.toc_heading {color:#883333;font-family:Arial;font-size:10pt;font-weight:bold;text-decoration:none;} 2 | A.toc_heading:hover {text-decoration:underline;} 3 | A.toc_entry {color:#3333FF;font-family:Arial;font-size:10pt;font-weight:normal;margin-left:10px;} 4 | 5 | BODY,DIV, TABLE, TR, TD { background:white; font-family:Arial; font-size:9.0pt; } 6 | 7 | .function_list {color:#000000;} 8 | a.function_list {color:#3333FF;font-weight:bold;text-decoration:none;} 9 | a.function_list:hover {background-color:#DDDDFF;} 10 | 11 | .function_definition, .attribute_definition {color:#000000;font-weight:bold; background-color:#bbbbbb; width:100%} 12 | 13 | .function_parameter, .function_return, .function_parameter_name, .attribute_type {color:#000000;font-weight:bold;} 14 | 15 | .function_description, .attribute_description {color:#000000;} 16 | 17 | .enumeration_list {color:#000000;} 18 | A.enumeration_list {color:#3333FF;font-weight:bold;text-decoration:none;} 19 | A.enumeration_list:hover { background-color:#DDDDFF;} 20 | 21 | .attribute_list, .class_list { color:#000000; } 22 | A.attribute_list, A.class_list { color:#3333FF; font-weight:bold; text-decoration:none;} 23 | A.attribute_list:hover, A.class_list:hover { background-color:#DDDDFF;} 24 | 25 | .module_h1 { color:#000000; font-size:13.0pt; font-weight:bold;} 26 | A.module_h1 { color:#3333FF; font-size:13pt; font-weight:bold; text-decoration:none;} 27 | A.module_h1:hover { background-color:#DDDDFF;} 28 | 29 | .argument { color:#883333; } 30 | 31 | H1 {margin-left:00.0pt;margin-top:05.0pt;margin-bottom:12.0pt;font-size:13.0pt;font-family:Arial;padding-left:2pt;padding-top:4pt;padding-bottom:4pt;color:white;background:#708090;} 32 | 33 | A.H2 { color:white; font-family:Arial; font-size:11pt;} 34 | A.H2:hover { text-background:#DDDDFF;} 35 | 36 | H2 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:12.0pt;font-size:11.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:#aaaaaa;} 37 | H3 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:03.0pt;font-size:09.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:darkgray;} 38 | H4 {margin-left:00.0pt;margin-top:12.0pt;margin-bottom:03.0pt;font-size:09.0pt;font-family:Arial;padding-left:2pt;padding-top:2pt;padding-bottom:2pt;color:white;background:silver;font-style:oblique} 39 | 40 | P { background:white; font-family:Arial; font-size:9.0pt; } 41 | 42 | A { color:#3333FF; font-weight:bold; text-decoration:none;} 43 | A:hover { background-color:#DDDDFF;} 44 | 45 | /* Copyright Info */ 46 | p.copyrightFooter { text-align:right; background:#708090; color:white; } 47 | DIV.releaseDate { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:30pt; margin-bottom:0pt; } 48 | DIV.softwareInfo { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:10pt; margin-bottom:0pt; } 49 | DIV.bigworldInfo { font-size:9.0pt; font-weight:bold; color:#006699; margin-top:10pt; margin-bottom:0pt; } 50 | DIV.periodInfo { font-size:9.0pt; font-weight:normal; color:#006699; margin-top:10pt; margin-bottom:0pt; } 51 | DIV.legal { font-size:8.0pt; font-weight:normal; color:#006699; margin-top:05pt; } 52 | -------------------------------------------------------------------------------- /generate_python_tips.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import os 4 | import os.path 5 | import sys 6 | import time 7 | import shutil 8 | 9 | rootdir = "api" 10 | pythonstr = "" 11 | isModuleAPI = False 12 | ignoreKeys = ["属性文档", "回调函数文档", "成员函数文档"] 13 | 14 | 15 | def findDocsFiles(): 16 | files = [] 17 | 18 | for parent, dirnames, filenames in os.walk(rootdir): 19 | for filename in filenames: 20 | f = parent + "\\" + filename 21 | if ".htm" in filename and ("Classes" in parent or "Modules" in parent): 22 | files.append(f) 23 | 24 | return files 25 | 26 | def modifyDatas(prefix, data): 27 | data = data.replace(" ", " ").replace("\r", "") 28 | data = data.replace("<", "〈").replace(">", "〉") 29 | #data = data.rstrip() 30 | 31 | data.replace(r"""
""", "\n") 32 | 33 | while True: 34 | i = data.find("<") 35 | if i < 0: 36 | break 37 | 38 | ii = data.find(">", i) 39 | 40 | if ii > 0: 41 | data = data.replace(data[i : ii + 1], "") 42 | 43 | if len(data) == 0: 44 | return "" 45 | 46 | return prefix + data 47 | 48 | def parseFunctions(data, substate): 49 | global pythonstr 50 | global isModuleAPI 51 | 52 | if substate == 0: 53 | if r"""
""" in data: 54 | substate = 1 55 | data = modifyDatas(isModuleAPI + "\t", data) 56 | pythonstr += data 57 | if len(data) > 0 and not isModuleAPI: 58 | data += "\t" 59 | elif substate == 1: 60 | if r"""definition">""" in data: 61 | substate = 4 62 | else: 63 | if r"""
""" in data: 64 | substate = 2 65 | else: 66 | pythonstr += modifyDatas(isModuleAPI + "\t", data) 67 | 68 | elif substate == 2: 69 | if r"""definition">""" in data: 70 | substate = 4 71 | else: 72 | if r"""""" in data: 73 | substate = 3 74 | else: 75 | hasArgTitle = "function_parameter_name" in data 76 | if hasArgTitle: 77 | hasArgTitle = "@" 78 | else: 79 | hasArgTitle = "" 80 | 81 | pythonstr += modifyDatas(isModuleAPI + "\t" + hasArgTitle, data) 82 | else: 83 | if r"""definition">""" in data: 84 | substate = 4 85 | else: 86 | pythonstr += modifyDatas(isModuleAPI + "\t", data) 87 | 88 | return substate 89 | 90 | def parseAttributes(data, substate): 91 | global pythonstr 92 | global isModuleAPI 93 | 94 | if substate == 0: 95 | if r"""
""" in data: 96 | substate = 1 97 | pythonstr += modifyDatas(isModuleAPI + "\t", data) 98 | elif substate == 1: 99 | if r"""definition">""" in data: 100 | substate = 2 101 | else: 102 | if r"""
""" in data: 103 | substate = 2 104 | else: 105 | pythonstr += modifyDatas(isModuleAPI + "\t", data) 106 | 107 | return substate 108 | 109 | def writeTipsPy(processName, moduleName, datas): 110 | dirstr = "tips/" + processName + "/" 111 | 112 | try: 113 | os.makedirs(dirstr) 114 | except: 115 | pass 116 | 117 | f = open(dirstr + moduleName + ".py", "a+", encoding="UTF-8") 118 | f.write(datas) 119 | f.close() 120 | print("save to: %s/%s.py" % (os.getcwd(), dirstr + moduleName)) 121 | 122 | def parseDocs(f): 123 | print("====>parseDocs(): " + f + "...") 124 | 125 | temp = f.replace("\\","/") 126 | fd = open(temp, "r", encoding="UTF-8") 127 | lines = fd.readlines() 128 | fd.close() 129 | 130 | # 主状态1:分析方法 131 | # 子状态1:分析主描述 132 | # 子状态2:分析参数描述 133 | # 子状态3:分析返回值描述 134 | # 子状态4:分析结束 135 | # 主状态2:分析属性 136 | # 子状态1:分析主描述 137 | # 子状态2:分析结束 138 | # 主状态3:分析子类 139 | # 子状态1:分析主描述 140 | # 子状态2:分析结束 141 | 142 | state = 0 143 | substate = 0 144 | 145 | global pythonstr 146 | global isModuleAPI 147 | 148 | moduleDocs = "" 149 | pythonstr = "" 150 | isModuleAPI = "Modules" in f 151 | processName = temp.split("/")[1] 152 | moduleName = os.path.basename(f).split(".")[0] 153 | 154 | if not isModuleAPI: 155 | isModuleAPI = "\t" 156 | moduleDocs += "class " + moduleName + ":\n" 157 | else: 158 | isModuleAPI = "" 159 | 160 | for data in lines: 161 | for key in ignoreKeys: 162 | if key in data: 163 | state = 0 164 | substate = 0 165 | continue 166 | 167 | #print("%i---%i--%s" % (state, substate, pythonstr)) 168 | 169 | if state == 0: 170 | if len(pythonstr) > 0: 171 | pythonstr += "\n\t" + isModuleAPI + "\"\"\"\n\t" + isModuleAPI + "pass" +"\n\n" 172 | moduleDocs += pythonstr 173 | 174 | pythonstr = "" 175 | if r"""""" in data: 176 | pythonstr = modifyDatas(isModuleAPI, data) 177 | 178 | if len(pythonstr) > 0 and pythonstr[-1] == "\n": 179 | pythonstr = pythonstr[0 : len(pythonstr) - 1] 180 | 181 | state = 1 182 | pythonstr += "\n\t" + isModuleAPI + "\"\"\"" 183 | 184 | elif r"""""" in data: 185 | pythonstr = isModuleAPI + "@property\n" 186 | pythonstr += modifyDatas(isModuleAPI + "def ", data) 187 | 188 | if len(pythonstr) > 0 and pythonstr[-1] == "\n": 189 | pythonstr = pythonstr[0 : len(pythonstr) - 1] 190 | 191 | if len(isModuleAPI) > 0: 192 | pythonstr += "( self ):\n" 193 | else: 194 | pythonstr += "():\n" 195 | pythonstr += "\n\t" + isModuleAPI + "\"\"\"" 196 | state = 2 197 | elif state == 1: 198 | substate = parseFunctions(data, substate) 199 | if substate == 4: 200 | substate = 0 201 | state = 0 202 | else: 203 | substate = parseAttributes(data, substate) 204 | if substate == 2: 205 | substate = 0 206 | state = 0 207 | 208 | if len(pythonstr) > 0: 209 | pythonstr += "\n\t" + isModuleAPI + "\"\"\"\n\t" + isModuleAPI + "pass" +"\n\n" 210 | pythonstr = pythonstr.replace("版权归KBEngine所有。", "") 211 | moduleDocs += pythonstr 212 | 213 | writeTipsPy(processName, "KBEngine", moduleDocs) 214 | 215 | def generatePythonTips(): 216 | print("generatePythonTips: start...") 217 | 218 | try: 219 | shutil.rmtree(r'tips') 220 | except: 221 | pass 222 | 223 | files = findDocsFiles() 224 | 225 | for f in files: 226 | parseDocs(f) 227 | 228 | print("generatePythonTips: over!") 229 | 230 | if __name__ == "__main__": 231 | generatePythonTips() 232 | -------------------------------------------------------------------------------- /python3.x_generate_python_tips.bat: -------------------------------------------------------------------------------- 1 | python generate_python_tips.py 2 | ping 127.1 /n 3 >nul --------------------------------------------------------------------------------