__ACCOUNT_NAME__ |
__ACCOUNT_PASSWORD__ |
accelerate |
accountLoginResponse |
addBots |
addProximity |
address |
address |
addSpaceGeometryMapping |
addTimer |
addTimer |
addTimer |
addTimer |
addTimer |
addTimer |
addWatcher |
addWatcher |
addYawRotator |
allClients |
base |
base |
base |
base |
base |
baseapp |
baseapp |
baseAppData |
callback |
cancelCallback |
cancelController |
cancelController |
canNavigate |
cell |
cell |
cell |
cellapp |
cellapp |
cellAppData |
cellData |
charge |
chargeResponse |
className |
className |
className |
className |
client |
client |
client |
client |
clientAddr |
clientapp |
clientEnabled |
clientEntity |
component |
component |
controlledBy |
controlledBy |
createAccountResponse |
createBase |
createBaseAnywhere |
createBaseAnywhereFromDBID |
createBaseFromDBID |
createBaseLocally |
createBaseRemotely |
createBaseRemotelyFromDB |
createBaseRemotelyFromDBID |
createCellEntity |
createCellEntityInNewSpace |
createEntity |
createEntity |
databaseID |
databaseInterfaceName |
debugTracing |
debugTracing |
debugView |
deleteBaseByDBID |
delSpaceData |
delTimer |
delTimer |
delTimer |
delTimer |
delTimer |
delTimer |
delWatcher |
delWatcher |
deregisterReadFileDescriptor |
deregisterReadFileDescriptor |
deregisterWriteFileDescriptor |
deregisterWriteFileDescriptor |
destroy |
destroy |
destroyCellEntity |
destroySpace |
direction |
direction |
direction |
disconnect |
entities |
entities |
entities.xml |
entitiesInRange |
entitiesInView |
entity |
entity |
EntityCall |
executeRawDatabaseCommand |
executeRawDatabaseCommand |
genUUID64 |
genUUID64 |
genUUID64 |
getAppFlags |
getAppFlags |
getClientDatas |
getClientType |
getRandomPoints |
getResFullPath |
getResFullPath |
getSpaceData |
getSpaceGeometryMapping |
getViewHystArea |
getViewRadius |
getWatcher |
getWatcher |
getWatcherDir |
getWatcherDir |
ghost |
github |
giveClientTo |
globalData |
globalData |
hasClient |
hasRes |
hasRes |
hasWitness |
id |
id |
id |
id |
inWorld |
isDestroyed |
isDestroyed |
isOnGround |
isOnGround |
isOnGround |
isReal |
isShuttingDown |
isShuttingDown |
isWitnessed |
KBE_HYBRID_PATH |
KBE_RES_PATH |
KBE_ROOT |
KBEngine |
KBEngine |
KBEngine |
KBEngine |
kbengine.xml |
kbengine_defaults.xml |
keywords |
layer |
listPathRes |
listPathRes |
LOG_TYPE_DBG |
LOG_TYPE_DBG |
LOG_TYPE_ERR |
LOG_TYPE_ERR |
LOG_TYPE_INFO |
LOG_TYPE_INFO |
LOG_TYPE_NORMAL |
LOG_TYPE_NORMAL |
LOG_TYPE_WAR |
LOG_TYPE_WAR |
lookUpBaseByDBID |
matchPath |
matchPath |
MemoryStream |
MemoryStream |
moveToEntity |
moveToPoint |
moveToPoint |
navigate |
navigatePathPoints |
NEXT_ONLY |
NEXT_ONLY |
onAllSpaceGeometryLoaded |
onAutoLoadEntityCreate |
onBaseAppData |
onBaseAppDataDel |
onBaseAppReady |
onBaseAppShutDown |
onCellAppDeath |
onClientDeath |
onClientEnabled |
onClientGetCell |
onCreateAccountCallbackFromDB |
onCreateCellFailure |
onDBMgrReady |
onDBMgrShutDown |
onDestroy |
onDestroy |
onEnteredCell |
onEnteredView |
onEnteringCell |
onEnterSpace |
onEnterSpace |
onEnterTrap |
onEnterWorld |
onEnterWorld |
onFini |
onGetCell |
onGetWitness |
onGiveClientToFailure |
onGlobalData |
onGlobalData |
onGlobalDataDel |
onGlobalDataDel |
onInit |
onInit |
onInterfaceAppReady |
onInterfaceAppShutDown |
onLeaveSpace |
onLeaveSpace |
onLeaveTrap |
onLeaveTrapID |
onLeaveWorld |
onLeaveWorld |
onLeavingCell |
onLeftCell |
onLoggerAppReady |
onLoggerAppShutDown |
onLoginAppReady |
onLoginAppShutDown |
onLoginCallbackFromDB |
onLogOnAttempt |
onLogWrote |
onLoseCell |
onLoseChargeCB |
onLoseControlledBy |
onLoseControlledBy |
onLoseWitness |
onMove |
onMoveFailure |
onNavigate |
onNavigateFailed |
onPreArchive |
onReadyForLogin |
onReadyForShutDown |
onReadyForShutDown |
onReadyForShutDown |
onRequestAccountLogin |
onRequestCharge |
onRequestCreateAccount |
onRequestCreateAccount |
onRequestLogin |
onRestore |
onSelectAccountDBInterface |
onSpaceData |
onSpaceGeometryLoaded |
onSpaceGone |
onStreamComplete |
onTeleport |
onTeleportFailure |
onTeleportSuccess |
onTimer |
onTimer |
onTurn |
onUpdateBegin |
onUpdateEnd |
onWitnessed |
onWriteToDB |
onWriteToDB |
open |
open |
otherClients |
ownClient |
pitch |
position |
position |
position |
publish |
publish |
quantumPassedPercent |
quantumPassedPercent |
raycast |
real |
registerReadFileDescriptor |
registerReadFileDescriptor |
registerWriteFileDescriptor |
registerWriteFileDescriptor |
reloadScript |
reloadScript |
roll |
roundTripTime |
scriptLogType |
scriptLogType |
scriptLogType |
seeingHeight |
setAppFlags |
setAppFlags |
setSpaceData |
setViewRadius |
shouldAutoArchive |
shouldAutoBackup |
shouldAutoBackup |
Space |
spaceID |
spaceID |
spaceID |
spaceID |
streamFileToClient |
streamStringToClient |
teleport |
teleport |
teleport |
time |
time |
timeSinceHeardFromClient |
topSpeed |
topSpeedY |
type |
vector3 |
vector3 |
velocity |
View |
visibleHeight |
visionAngle |
visionRange |
volatileInfo |
volatileInfo |
Witness |
writeToDB |
writeToDB |
yaw |
KBEngine |
Copyright KBEngine
KBEngine |
EntityCall:
<ClientMethods> <hello> </hello> </ClientMethods>
class Avatar: def hello(self): print("hello")
KBE_ROOT:
KBE_RES_PATH:
KBE_HYBRID_PATH:
entities.xml:
kbengine_defaults.xml:
kbengine.xml:
entity
View
Witness
Space
cell
base
client
cellapp
baseapp
real
ghost
vector3
Copyright KBEngine
KBEngine |
[Name] [Bytes] UINT8 1 UINT16 2 UINT32 4 UINT64 8 INT8 1 INT16 2 INT32 4 INT64 8 FLOAT 4 DOUBLE 8 VECTOR2 12 VECTOR3 16 VECTOR4 20 STRING N UNICODE N PYTHON N PY_DICT N PY_TUPLE N PY_LIST N ENTITYCALL N BLOB N
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
Entity |
def login( username, password ): |
def createAccount( username, password ): |
def reloginBaseapp(): |
def player( ): |
def resetPassword(username): |
def bindAccountEmail( emailaddress ): |
def newPassword( oldpassword, newpassword ): |
def findEntity( entityID ): |
def getSpaceData( key ): |
component | Read only string |
entities | Entities |
entity_uuid | uint64 |
entity_id | int32 |
spaceID | int32 |
def login( username, password ):
parameter
username | string, username. |
password | string, password. |
def createAccount( username, password ):
parameters:
username | string, username. |
password | string, password. |
def reloginBaseapp( ):
def player( ):
return:
Entity, return controlled entity, if it does not exist (e.g.: failed to connect to the server) returns null. |
def resetPassword( username ):
parameters:
username | string, username. |
def bindAccountEmail( emailaddress ):
parameters:
emailaddress | string, email address. |
def newPassword( oldpassword, newpassword ):
parameters:
oldpassword | string, old password |
newpassword | string, new password |
def findEntity( entityID ):
parameters:
entityID | int32, entity ID. |
returns:
Entity An entity instance is returned. There can be no return null. |
def getSpaceData( key ):
parameters:
key | string, a keyword |
returns:
string, specifies the value at the key |
component
entities
Types:
Entities |
entity_uuid
entity_id
spaceID
Copyright KBEngine
KBEngine |
Entity is part of the KBEngine module. More...
import KBEngine
def baseCall( self, methodName, methodArgs ): |
def cellCall( self, methodName, methodArgs ): |
def onDestroy( self ): |
def onEnterWorld( self ): |
def onLeaveWorld( self ): |
def onEnterSpace( self ): |
def onLeaveSpace( self ): |
direction | Tuple of 3 floats as (roll, pitch, yaw) |
id | Read-only Integer |
position | Vector3 |
spaceID | Read-only uint32 |
isOnGround | Read-only bool |
inWorld | Read-only bool |
className | Read-only string |
def baseCall( self, methodName, methodArgs ):
parameters:
methodName | string, method name. |
methodArgs | objects, method parameter list. |
return:
Because it is a remote call, it is not possible to block waiting for a return, so there is no return value. |
def cellCall( self, methodName, methodArgs ):
parameters:
methodName | string, method name. |
methodArgs | objects, method parameter list. |
return:
Because it is a remote call, it is not possible to block waiting for a return, so there is no return value. |
def onDestroy( self ):
def onEnterWorld( self ):
def onLeaveWorld( self ):
def onEnterSpace( self ):
def onLeaveSpace( self ):
className
Type:
Read-only, string |
position
Type:
Vector3 |
direction
Type:
Vector3, which contains (roll, pitch, yaw) in radians. |
isOnGround
Type:
Read-write, bool |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
Entity |
def addSpaceGeometryMapping( spaceID, mapper, path, shouldLoadOnServer, params ): |
def addWatcher( path, dataType, getFunction ): |
def address( ): |
def MemoryStream( ): |
def createEntity( entityType, spaceID, position, direction, params ): |
def debugTracing( ): |
def delSpaceData( spaceID, key ): |
def delWatcher( path ): |
def deregisterReadFileDescriptor( fileDescriptor ): |
def deregisterWriteFileDescriptor( fileDescriptor ): |
def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): |
def genUUID64( ): |
def getResFullPath( res ): |
def getSpaceData( spaceID, key ): |
def getSpaceGeometryMapping( spaceID ): |
def getWatcher( path ): |
def getWatcherDir( path ): |
def getAppFlags( ): |
def hasRes( res ): |
def isShuttingDown( ): |
def listPathRes( path, extension ): |
def matchPath( res ): |
def open( res, mode ): |
def publish( ): |
def registerReadFileDescriptor( fileDescriptor, callback ): |
def registerWriteFileDescriptor( fileDescriptor, callback ): |
def raycast( spaceID, layer, src, dst ): |
def reloadScript( fullReload ): |
def scriptLogType( logType ): |
def setAppFlags( flags ): |
def setSpaceData( spaceID, key, value ): |
def time( ): |
def onCellAppData( key, value ): |
def onCellAppDataDel( key ): |
def onGlobalData( key, value ): |
def onGlobalDataDel( key ): |
def onInit( isReload ): |
def onSpaceData( spaceID, key, value ): |
def onSpaceGeometryLoaded( spaceID, mapping ): |
def onAllSpaceGeometryLoaded( spaceID, isBootstrap, mapping ): |
LOG_TYPE_DBG | |
LOG_TYPE_ERR | |
LOG_TYPE_INFO | |
LOG_TYPE_NORMAL | |
LOG_TYPE_WAR | |
NEXT_ONLY | |
cellAppData | |
component | Read-only string |
entities | Entities |
globalData | GlobalDataClient |
def addSpaceGeometryMapping( spaceID, mapper, path, shouldLoadOnServer, params ):
def onAllSpaceGeometryLoaded( self, spaceID, mappingName ):
parameters:
spaceID | uint32, ID of the space, specifies in which space to operate |
mapper | Not yet implemented |
path | Directory path containing geometry data |
shouldLoadOnServer | Optional boolean parameter that specifies whether to load geometry on the server. Default is True. |
params |
Optional PyDict parameter, specifies the navmesh used by different layers, for example: KBEngine.addSpaceGeometryMapping(self.spaceID, None, resPath, True, {0 : "srv_xinshoucun_1.navmesh", 1 : "srv_xinshoucun.navmesh"}) |
def addWatcher( path, dataType, getFunction ):
>>> def countPlayers( ): >>> i = 0 >>> for e in KBEngine.entities.values(): >>> if e.__class__.__name__ == "Avatar": >>> i += 1 >>> return i >>> >>> KBEngine.addWatcher( "players", "UINT32", countPlayers )
parameters:
path | The path to create a watcher. |
dataType | The value type of the monitored variable. Reference: Basic data types |
getFunction | This function is called when the observer retrieves the variable. This function returns a value representing a watch variable without arguments. |
def address( ):
def MemoryStream( ):
>>> s = KBEngine.MemoryStream() >>> s >>> b'' >>> s.append("UINT32", 1) >>> s.pop("UINT32") >>> 1
def createEntity( entityType, spaceID, position, direction, params ):
# Create an open Door entity in the same space as the "thing" entity direction = ( 0, 0, thing.yaw ) properties = { "open":1 } KBEngine.createEntity( "Door", thing.space, thing.position, direction, properties )
parameters:
entityType |
string, the name of the entity to create, declared in the |
spaceID | int32, the ID of the space to place the entity |
position | A sequence of 3 floats that specify the creation point of the new entity, in world coordinates. |
direction | A sequence of 3 floats that specify the initial orientation (roll, pitch, yaw) of the new entity in world coordinates. |
params | Optional parameters, a Python dictionary object. If a specified key is an Entity attribute, its value will be used to initialize the properties of the new Entity. |
returns:
The new Entity. |
def debugTracing( ):
def delSpaceData( spaceID, key ):
parameters:
spaceID | int32, the ID of the space |
key | string, a string keyword |
def delWatcher( path ):
parameters:
path | The path of the variable to delete. |
def deregisterReadFileDescriptor( fileDescriptor ):
parameters:
fileDescriptor | Socket descriptor/file descriptor |
def deregisterWriteFileDescriptor( fileDescriptor ):
parameters:
fileDescriptor | Socket descriptor/file descriptor |
def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ):
parameters:
command | This database command will be different for different database configurations. For MySQL databases it will be an SQL query statement. |
callback |
Optional parameter, callbacks object (for example, a function) with the
command's execution result. This callback has 4 parameters: result set,
number of rows affected, auto value, and error message. |
threadID |
int32, optional parameter, specifies a thread to process this command.
Users can use this parameter to control the execution order of certain
commands (dbmgr is multi-threaded). The default is not specified. If
threadID is the ID of the entity, it will be added to the entity's archive
queue and written by the thread one by one. |
dbInterfaceName | string, optional parameter, specified by a database interface, defaults to "default" interface. The database interface is defined by kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def genUUID64( ):
returns:
64-bit integer |
def getResFullPath( res ):
parameters:
res | string, if there is an absolute path to return the resource, otherwise it returns null. |
returns:
string, the absolute path to the resource. |
def getSpaceData( spaceID, key ):
parameters:
spaceID | int32, the ID of the space |
key | string, a string keyword |
returns:
string, string data for the given key |
def getSpaceGeometryMapping( spaceID ):
parameters:
spaceID | The ID of the space to be queried |
returns:
string, the name of the geometry map. |
def getWatcher( path ):
parameters:
path | string, the absolute path of the variable including the variable name (can be viewed on the GUIConsole watcher page). |
returns:
The value of the variable. |
def getWatcherDir( path ):
parameters:
path | string, the absolute path of the variable including the variable name (can be viewed on the GUIConsole watcher page). |
returns:
The list of elements (directory, variable name) under the Watch directory. |
def getAppFlags( ):
returns:
KBEngine.APP_FLAGS_* |
def hasRes( res ):
parameters:
res | string, the relative path of the resource |
returns:
BOOL, if it exists return True, otherwise False. |
def isShuttingDown( ):
returns:
BOOL, if the server is shutting down True, otherwise False. |
def listPathRes( path, extension ):
parameters:
res | string, the relative path of the resource. |
extension | string, optional parameter, file extension. |
returns:
Tuple, resource list. |
def matchPath( res ):
parameters:
res | string, the relative path to the resource (including the resource name) |
returns:
string, the absolute path of the resource. |
def open( res, mode ):
parameters:
res | string, the relative path of the resource. |
mode |
string, file operation mode: w Open in write mode, a Open in append mode (Start from EOF, create new file if necessary) r+ Open w+ in read/write mode Open in read/write mode (see w) a+ Open in read/write mode (See a) rb Opens wb in binary read mode Opens in binary write mode (see w) ab Opens in binary append mode (see a) rb+ Opens in binary read and write mode (see r+) wb+ Opens in binary read and write mode (see w+ ) ab+ Open in binary read/write mode (see a+) |
def publish( ):
returns:
int8, 0: debug, 1: release, others can be customized. |
def raycast( spaceID, layer, src, dst ):
>>> KBEngine.raycast( spaceID, entity.layer, (0, 10, 0), (0,-10,0) ) ((0.0000, 0.0000, 0.0000), ( (0.0000, 0.0000, 0.0000), (4.0000, 0.0000, 0.0000), (4.0000, 0.0000, 4.0000)), 0)
parameters:
spaceID | int32, space ID |
layer | int8, geometric layer. A space can load multiple navmesh data at the same time. Different navmesh can be in different layers. Different layers can be abstracted into the ground, the water surface and so on. |
returns:
list, list of coordinate points collided |
def registerReadFileDescriptor( fileDescriptor, callback ):
parameters:
fileDescriptor | Socket descriptor/file descriptor |
callback | A callback function with the socket descriptor/file descriptor as its only parameter. |
def registerWriteFileDescriptor( fileDescriptor, callback ):
parameters:
fileDescriptor | Socket descriptor/file descriptor |
callback | A callback function with the socket descriptor/file descriptor as its only parameter. |
def reloadScript( fullReload ):
for e in KBEngine.entities.values(): if type( e ) is Avatar.Avatar: e.customData.__class__ = CustomClassWhen this method completes KBEngine.onInit( True ) is called.
parameters:
fullReload | Optional boolean parameter that specifies whether to reload entity definitions at the same time. If this parameter is False, the entity definition will not be reloaded. The default is True. |
returns:
True if the reload succeeds, False otherwise. |
def scriptLogType( logType ):
def setAppFlags( flags ):
def setSpaceData( spaceID, key, value ):
parameters:
spaceID | int32, the ID of the space. |
key | string, a string keyword |
value | string, the string value. |
def time( ):
returns:
uint32, the current time of the game. This refers to the number of cycles. The period is affected by the frequency. The frequency is determined by the configuration file kbengine.xml or kbengine_defaults.xml-> gameUpdateHertz. |
def onCellAppData( key, value ):
parameters:
key | The key of the changed data. |
value | The value of the changed data. |
def onCellAppDataDel( key ):
parameters:
key | Deleted data key. |
def onGlobalData( key, value ):
parameters:
key | The key of the changed data. |
value | The value of the changed data. |
def onGlobalDataDel( key ):
parameters:
key | Deleted data key. |
def onInit( isReload ):
parameters:
isReload | Bool, whether it was triggered after reloading the loading the script. |
def onSpaceData( spaceID, key, value ):
parameters:
spaceID | The ID of the space. |
key | The key of the changed data. |
value | The value of the changed data. |
def onSpaceGeometryLoaded( spaceID, mapping ):
parameters:
spaceID | The ID of the space. |
mapping | The map value of the grid collision data. |
def onAllSpaceGeometryLoaded( spaceID, isBootstrap, mapping ):
parameters:
spaceID | The ID of the space. |
isBootstrap | If a space is partitioned by multiple cells, isBootstrap describes whether it is the originating cell of the loading request. |
mapping | The map value of grid collision data. |
LOG_TYPE_DBG
LOG_TYPE_ERR
LOG_TYPE_INFO
LOG_TYPE_NORMAL
LOG_TYPE_WAR
NEXT_ONLY
cellAppData
KBEngine.cellAppData[ "hello" ] = "there"
print KBEngine.cellAppData[ "hello" ]
KBEngine.cellAppData[ "list" ] = [1, 2, 3] KBEngine.cellAppData[ "list" ][1] = 7This will cause the local access to read [1, 7, 3] and the remote [1, 2, 3]
component
entities
>>> KBEngine.entities.garbages.items() [(1025, Avatar object at 0x7f92431ceae8.)]
>>> e = _[0][1] >>> import gc >>> gc.get_referents(e) [{'spacesIsOk': True, 'bootstrapIdx': 1},]
Types:
Entities |
globalData
KBEngine.globalData[ "hello" ] = "there"
print KBEngine.globalData[ "hello" ]
KBEngine.globalData[ "list" ] = [1, 2, 3] KBEngine.globalData[ "list" ][1] = 7This will cause the local access to read [1, 7, 3] and the remote [1, 2, 3]
Copyright KBEngine
KBEngine |
Entity is part of the KBEngine module. More...
import KBEngine
def accelerate( self, accelerateType, acceleration ): |
def addYawRotator( self, targetYaw, velocity, userArg ): |
def addProximity( self, range, userArg ): |
def addTimer( self, start, interval=0.0, userData=0 ): |
def cancelController( self, controllerID ): |
def clientEntity( self, destID ): |
def canNavigate( self ): |
def debugView( self ): |
def delTimer( self, id ): |
def destroy( self ): |
def destroySpace( self ): |
def entitiesInView( self ): |
def entitiesInRange( self, range, entityType=None, position=None ): |
def isReal( self ): |
def moveToEntity( self, destEntityID, velocity, distance, userData, faceMovement, moveVertically ): |
def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ): |
def getViewRadius( self ): |
def getViewHystArea( self ): |
def getRandomPoints( self, centerPos, maxRadius, maxPoints, layer ): |
def navigate( self, destination, velocity, distance, maxMoveDistance, maxSearchDistance, faceMovement, layer, userData ): |
def navigatePathPoints( self, destination, maxSearchDistance, layer ): |
def setViewRadius( self, radius, hyst=5 ): |
def teleport( self, nearbyMBRef, position, direction ): |
def writeToDB( self, shouldAutoLoad, dbInterfaceName ): |
def onDestroy( self ): |
def onEnterTrap( self, entity, rangeXZ, rangeY, controllerID, userArg ): |
def onEnteredView( self, entity ): |
def onGetWitness( self ): |
def onLeaveTrap( self, entity, rangeXZ, rangeY, controllerID, userArg ): |
def onLoseControlledBy( self, id ): |
def onLoseWitness( self ): |
def onMove( self, controllerID, userData ): |
def onMoveOver( self, controllerID, userData ): |
def onMoveFailure( self, controllerID, userData ): |
def onRestore( self ): |
def onSpaceGone( self ): |
def onTurn( self, controllerID, userData ): |
def onTeleport( self ): |
def onTeleportFailure( self ): |
def onTeleportSuccess( self, nearbyEntity ): |
def onTimer( self, timerHandle, userData ): |
def onUpdateBegin( self ): |
def onUpdateEnd( self ): |
def onWitnessed( self, isWitnessed ): |
def onWriteToDB( self ): |
allClients | Read-only PyClient |
base | Read-only BaseEntityCall |
client | Read-only ClientEntityCall |
controlledBy | BaseEntityCall |
className | Read-only string |
direction | Tuple of 3 floats as (roll, pitch, yaw) |
hasWitness | boolean |
id | Read-only Integer |
isDestroyed | Read-only bool |
isWitnessed | Read-only bool |
layer | int8 |
otherClients | Read-only PyClient |
position | Vector3 |
spaceID | Read-only uint32 |
topSpeed | float |
topSpeedY | float |
volatileInfo | float |
def accelerate( self, accelerateType, acceleration ):
The activities that can be accelerated include:
Entity.moveToEntity |
Entity.moveToPoint |
Entity.navigate |
Entity.addYawRotator |
parameters:
accelerateType | string, the type of movement affected such as: "Movement", "Turn". |
velocity | float, acceleration per second, use negative to decelerate |
returns:
The current speed of the affected entity. |
def addYawRotator( self, targetYaw, velocity, userArg ):
See:
Entity.cancelController |
parameters:
targetYaw | float, the given target yaw radians. |
velocity |
float, the arc per second when rotated. |
userArg | Optional integer that is common to all controllers. If this value is not 0, it is passed to the callback function. It is recommended to set the default value to 0 in the callback prototype. |
def addProximity( self, rangeXZ, rangeY, userArg ):
def onEnterTrap( self, entityEntering, rangeXZ, rangeY, controllerID, userArg = 0 ): def onLeaveTrap( self, entityLeaving, rangeXZ, rangeY, controllerID, userArg = 0 ):
See:
Entity.cancelController |
parameters:
rangeXZ | float, the size of the xz axis area of the trigger, must be greater than or equal to zero. |
rangeY |
float, the height of the y-axis of the trigger, must be greater than or equal to zero. It should be noted that for this parameter to take effect kbengine_defaults.xml->cellapp->coordinate_system->rangemgr_y must be set to true. Open y-axis management will increase CPU consumption, because some games have a large number of entities at the same y-axis height or all on the ground which is almost completely flat. Because of this, the collision becomes very dense. 3D space games or small room-type games are more suitable for this option. |
userArg | Optional integer that is common to all controllers. If this value is not 0, it is passed to the callback function. It is recommended to set the default value to 0 in the callback prototype. |
returns:
The ID of the created controller. |
def addTimer( self, start, interval=0.0, userData=0 ):
# Here is an example of using addTimer import KBEngine class MyCellEntity( KBEngine.Entity ): def __init__( self ): KBEngine.Entity.__init__( self ) # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9. self.addTimer( 5, 1, 9 ) # Add a timer and execute it after 1 second. The default user parameter is 0. self.addTimer( 1 ) # Entity timer callback "onTimer" is called def onTimer( self, id, userArg ): print "MyCellEntity.onTimer called: id %i, userArg: %i" % ( id, userArg ) # if this is a repeated timer, when it is no longer needed, call the following function to remove it: # self.delTimer( id )
parameters:
initialOffset | float, specifies the time interval (in seconds) for the timer to execute the first callback. |
repeatOffset | float, specifies the time interval (in seconds) between each callback after the first callback. The timer must be removed with the function delTimer, otherwise it will be repeated. Values less than or equal to 0 will be ignored. |
userArg | integer, specifies the value of the "userArg" parameter when calling "onTimer". |
returns:
integer, returns the internal ID of the timer. This ID can be used to remove the timer using delTimer. |
def cancelController( self, controllerID ):
parameters:
controllerID | integer, the index of the controller to cancel. A special controller type string can also be used as its type. For example, only one mobile/navigation controller can be activated at a time. This can be cancelled with entity.cancelController( "Movement" ). |
def clientEntity( self, destID ):
parameters:
destID | integer, the ID of the target entity. |
def canNavigate( self ):
returns:
bool, returns True if the entity can use the Navigate function in the current space, otherwise it returns False. |
def debugView( self ):
INFO cellapp [0x00001a1c] [2014-11-04 00:28:41,409] - Avatar::debugView: 100 size=4, Seen=4, Pending=0, ViewRadius=50.000, ViewHyst=5.000 INFO cellapp [0x00001a1c] [2014-11-04 00:28:41,409] - Avatar::debugView: 100 Avatar(102), position(771.586.211.002.776.55), dist=0 INFO cellapp [0x00001a1c] [2014-11-04 00:28:41,409] - Avatar::debugView: 100 Monster(1028), position(820.834.211.635.768.749), dist=49.8659 INFO cellapp [0x00001a1c] [2014-11-04 00:28:41,409] - Avatar::debugView: 100 NPC(1025), position(784.024.210.95.782.273), dist=13.6915 INFO cellapp [0x00001a1c] [2014-11-04 00:28:41,409] - Avatar::debugView: 100 Avatar(106), position(771.586.211.002.776.55), dist=0The first line of information tells us:
def delTimer( self, id ):
parameters:
id | integer, which specifies the timer ID to remove. |
def destroy( self ):
def destroySpace( self ):
def entitiesInView( self ):
def entitiesInRange( self, range, entityType=None, position=None ):
self.entitiesInRange( 100, 'Creature', (100, 0, 100) )Searches for a list of entities of type 'Creature' (an instantiated entity of a subclass of 'Creature'). The center point is (100, 0, 100) and the search radius is 100 meters.
[ e for e in self.entitiesInRange( 100, None, (100,0,100) ) if isinstance( e, BaseType ) ]Gives a list of entities instantiated from subclasses of 'BaseType'.
parameters:
range | Search distance around this entity, float type |
entityType |
An optional string parameter, the entity's type name, used to match entities.
If the entity type is a valid class name (valid entities are ones listed in |
position | Optional Vector3 type parameter, which is the center of the search radius is centered on the entity itself by default. |
returns:
A list of Entity objects in a given range. |
def isReal( self ):
returns:
bool, True if real, otherwise False. |
def moveToEntity( self, destEntityID, velocity, distance, userData, faceMovement, moveVertically ):
def onMove( self, controllerID, userData ): def onMoveOver( self, controllerID, userData ): def onMoveFailure( self, controllerID, userData ):
References:
Entity.cancelController |
parameters:
destEntityID | int, the ID of the target Entity |
velocity | float, speed of the Entity move, in m/s |
distance | float, distance target that when reached the entity will stop moving, if the value is 0, it moves to the target position. |
userData | object, optional parameter, when the callback function is invoked the userData parameter will be this value. |
faceMovement | bool, optional parameter, True if the entity faces the direction of the move. If it is other mechanism, it is False. |
moveVertically | bool, optional parameter, set to True to move in a straight line, set to False means to move in a straight line parallel to the ground. |
returns:
int, newly created controller ID. |
def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ):
def onMove( self, controllerID, userData ): def onMoveOver( self, controllerID, userData ): def onMoveFailure( self, controllerID, userData ):
See:
Entity.cancelController |
parameters:
destination | Vector3, the target point to which the Entity is to be moved |
velocity | float, Entity's moving speed, in m/s |
distance | float, distance target that when reached the entity will stop moving, if the value is 0, it moves to the target position. |
userData | object, data passed to the callback function |
faceMovement | bool, True if the entity faces the direction of the move. If it is other mechanism, it is false. |
moveVertically | bool, set to True to move in a straight line, set to False means to move in a straight line parallel to the ground. |
returns:
int, newly created controller ID. |
def getViewRadius( self ):
returns:
float, View radius |
def getViewHystArea( self ):
returns:
float, The current lag area value of this Entity's View. |
def getRandomPoints( self, centerPos, maxRadius, maxPoints, layer ):
parameters:
centerPos | Vector3, Entity center coordinates |
maxRadius | float, the maximum search radius |
maxPoints | uint32, the maximimum number of random coordinate points returned. |
layer | int8, layer of navmesh to search. |
returns:
tuple, an array of one or more coordinates. |
def navigate( self, destination, velocity, distance, maxMoveDistance, maxSearchDistance, faceMovement, layer, userData ):
def onMove( self, controllerID, userData ): def onMoveOver( self, controllerID, userData ): def onMoveFailure( self, controllerID, userData ):
See:
Entity.cancelController |
parameters:
destination | Vector3, the target point where the Entity moves. |
velocity | float, Entity's move speed, in m/s |
distance | float, distance target that when reached the entity will stop moving, if the value is 0, it moves to the target position. |
maxMoveDistance | float, the maximum move distance |
maxSearchDistance | float, the maximum search distance from the navigatio ndata. |
faceMovement | bool, True if the entity faces the direction of the move (default). Otherwise False. |
layer | int8, navmesh layer to search |
userData | object, the data passed to the callback function |
returns:
int, the newly created controller ID. |
def navigatePathPoints( self, destination, maxSearchDistance, layer ):
parameters:
destination | Vector3, target point where the Entity moves |
maxSearchDistance | float, the maximum search distance |
layer | int8, navmesh layer to search for a path on. |
def setViewRadius( self, radius, hyst=5 ):
parameters:
radius | float, specifies the radius of the View area |
hyst | float, specifies the size of the lag area of the View. A reasonable setting of the lag area will reduce the sensitivity of View collisions and reduce CPU consumption. Views where one entity enters another entity must span the View radius area, but entities that leave the View area need to move out of the View radius area including the lag area. |
returns:
None |
def teleport( self, nearbyMBRef, position, direction ):
parameters:
nearbyMBRef | A CellEntityCall (the entity corresponding to this entityCall must be in the destination Space ) that determines which Space an Entity is to jump to. It is considered to be the transfer destination. This can be set to None, in which case it will teleport on the current cell. |
position | A sequence of 3 floats (x, y, z), the coordinates of where to teleport the Entity . |
direction | A sequence of 3 floats (roll, pitch, yaw), the orientation of the Entity after teleportation. |
def writeToDB( self, shouldAutoLoad, dbInterfaceName ):
parameters:
shouldAutoLoad |
bool, optional parameter, specifies whether this entity needs to be
loaded from the database when the service starts. Note: The entity is automatically loaded when the server starts. The default is to call createEntityAnywhereFromDBID to create an entity to a minimally loaded baseapp. The entire process will be completed before the first started baseapp calls onBaseAppReady. The script layer can reimplement the entity creation method in a customized script (kbengine_defaults.xml->baseapp->entryScriptFile definition), for example: def onAutoLoadEntityCreate(entityType, dbid): KBEngine.createEntityFromDBID(entityType, dbid) |
dbInterfaceName | string, optional parameter, specified by a database interface, uses the interface name "default" by default. The database interface is defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def onDestroy( self ):
def onEnterTrap( self, entity, rangeXZ, rangeY, controllerID, userArg ):
parameters:
entity | Entity that has entered the area |
rangeXZ | float, the size of the xz axis of the trigger, must be greater than or equal to zero. |
rangeY |
float, the size of the y-axis height of the trigger, must be greater than
or equal to zero. It should be noted that for this parameter to take effect you must enable kbengine_defaults.xml->cellapp->coordinate_system->rangemgr_y Opening y-axis management will increase CPU consumption, because some games have a large number of entities at the same y-axis height or on the ground at nearly the same height. Because of this, the collision becomes very dense. 3D space games or small room-type games are more suitable for enabling this option. |
controllerID | The controller id of this trigger. |
userArg | The value of the parameter given by the user when calling addProximity, the user can decide how to use this parameter. |
def onEnteredView( self, entity ):
parameters:
entity | The entity which has entered the View scope. |
def onGetWitness( self ):
def onLeaveTrap( self, entity, rangeXZ, rangeY, controllerID, userArg ):
parameters:
entity | The entity that has left the trigger area. |
rangeXZ | float, the size of the xz axis of the trigger, must be greater than or equal to zero. |
rangeY |
float, the size of the y-axis height of the trigger, must be greater than
or equal to zero. It should be noted that for this parameter to take effect you must enable kbengine_defaults.xml->cellapp->coordinate_system->rangemgr_y Opening y-axis management will increase CPU consumption, because some games have a large number of entities at the same y-axis height or on the ground at nearly the same height. Because of this, the collision becomes very dense. 3D space games or small room-type games are more suitable for enabling this option. |
controllerID | The controller ID of this trigger. |
userArg | The value of the parameter given by the user when calling addProximity, the user can decide how to use this parameter. |
def onLoseControlledBy( self, id ):
parameters:
id | ID of the controlledBy entity. |
def onLoseWitness( self ):
def onMove( self, controllerID, userData ):
parameters:
controllerID | The controller ID associated with the move. |
userData | The parameter given by the user when requesting to move the entity. |
def onMoveOver( self, controllerID, userData ):
parameters:
controllerID | The controller ID associated with the move. |
userData | This parameter value is given by the user when requesting to move an entity. |
def onMoveFailure( self, controllerID, userData ):
parameters:
controllerID | The controller ID associated with the move. |
userData | This parameter value is given by the user when requesting to move an entity. |
def onRestore( self ):
def onSpaceGone( self ):
def onTurn( self, controllerID, userData ):
parameters:
controllerID | The controller ID returned by Entity.addYawRotator. |
userData | This parameter value is given by user when requesting to move an entity. |
def onTeleport( self ):
def onTeleportFailure( self ):
def onTeleportSuccess( self, nearbyEntity ):
parameters:
nearbyEntity |
This parameter is given by the user when calling Entity.teleport.
This is a real entity.
|
def onTimer( self, timerHandle, userData ):
parameters:
timerHandle | The ID of the timer. |
userData | integer, given by the user when calling Entity.addTimer. |
def onUpdateBegin( self ):
def onUpdateEnd( self ):
def onWitnessed( self, isWitnessed ):
parameters:
isWitnessed |
bool, True if the entity is observed and False when the entity is not
observed. You can also access the entity property Entity.isWitnessed to get the current state of the entity. |
def onWriteToDB( self ):
allClients
Other references:
Entity.clientEntity Entity.otherClients |
base
Other references:
Entity.clientEntity Entity.allClients Entity.otherClients |
Type:
Read-only, ENTITYCALL |
className
Type:
Read-only, string |
client
Other references:
Entity.clientEntity Entity.allClients Entity.otherClients |
Type:
Read-only, ENTITYCALL |
controlledBy
Other references:
Entity.onLoseControlledBy |
Type:
BaseEntityCall |
direction
Type:
Vector3, which contains (roll, pitch, yaw) in radians. |
hasWitness
Type:
Read-only, bool |
id
Type:
Read-only, int32 |
isDestroyed
Type:
Read-only, bool |
isOnGround
Type:
Read-only, bool |
isWitnessed
Entity.onWitnessed |
Type:
Read-only, bool |
layer
Type:
int8 |
otherClients
Other references:
Entity.clientEntity Entity.otherClients |
position
self.position.y = 10.0
import Math self.copyPosition = Math.Vector3( self.position )
Type:
Vector3 |
spaceID
Type:
Read-only, Integer |
topSpeed
Other references:
Entity.topSpeedY |
Type:
float |
topSpeedY
Other references:
Entity.topSpeed |
Type:
float |
volatileInfo
<Volatile> <position/> <!-- always synchronize --> <yaw/> <!-- always synchronize --> <pitch>20</pitch> <!-- synchronize within 20m or less --> <optimized> true </optimized> </Volatile> <!-- roll is always synchronized if not specified -->
Type:
sequence, four floats (float, float, float, float) |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
Entity |
Proxy |
def addWatcher( path, dataType, getFunction ): |
def address( ): |
def MemoryStream( ): |
def charge( ordersID, dbID, byteDatas, pycallback ): |
def createEntity( ): |
def createEntityAnywhere( entityType, *params, callback ): |
def createEntityRemotely( entityType, baseMB, *params, callback ): |
def createEntityFromDBID( entityType, dbID, callback, dbInterfaceName ): |
def createEntityAnywhereFromDBID( entityType, dbID, callback, dbInterfaceName ): |
def createEntityRemotelyFromDBID( entityType, dbID, baseMB, callback, dbInterfaceName ): |
def createEntityLocally( entityType, *params ): |
def debugTracing( ): |
def delWatcher( path ): |
def deleteEntityByDBID( entityType, dbID, callback, dbInterfaceName ): |
def deregisterReadFileDescriptor( fileDescriptor ): |
def deregisterWriteFileDescriptor( fileDescriptor ): |
def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ): |
def genUUID64( ): |
def getResFullPath( res ): |
def getWatcher( path ): |
def getWatcherDir( path ): |
def getAppFlags( ): |
def hasRes( res ): |
def isShuttingDown( ): |
def listPathRes( path, extension ): |
def lookUpEntityByDBID( entityType, dbID, callback, dbInterfaceName ): |
def matchPath( res ): |
def open( res, mode ): |
def publish( ): |
def quantumPassedPercent( ): |
def registerReadFileDescriptor( fileDescriptor, callback ): |
def registerWriteFileDescriptor( fileDescriptor, callback ): |
def reloadScript( fullReload ): |
def scriptLogType( logType ): |
def setAppFlags( flags ): |
def time( ): |
def onBaseAppReady( isBootstrap ): |
def onBaseAppShutDown( state ): |
def onCellAppDeath( addr ): |
def onFini( ): |
def onBaseAppData( key, value ): |
def onBaseAppDataDel( key ): |
def onGlobalData( key, value ): |
def onGlobalDataDel( key ): |
def onInit( isReload ): |
def onLoseChargeCB( orderID, dbID, success, datas ): |
def onReadyForLogin( isBootstrap ): |
def onReadyForShutDown( ): |
def onAutoLoadEntityCreate( entityType, dbID ): |
def addWatcher( path, dataType, getFunction ):
>>> def countPlayers( ): >>> i = 0 >>> for e in KBEngine.entities.values(): >>> if e.__class__.__name__ == "Avatar": >>> i += 1 >>> return i >>> >>> KBEngine.addWatcher( "players", "UINT32", countPlayers )
parameters:
path | Create a monitored path. |
dataType | The value type of the monitor variable. Reference: Basic data types |
getFunction | This function is called when the observer retrieves the variable. This function returns a value representing a watch variable without arguments. |
def address( ):
def MemoryStream( ):
>>> s = KBEngine.MemoryStream() >>> s >>> b'' >>> s.append("UINT32", 1) >>> s.pop("UINT32") >>> 1
def charge( ordersID, dbID, byteDatas, pycallback ):
parameters:
ordersID | string, order ID. |
dbID | uint64, the databaseID of the entity. |
byteDatas | bytes, with data, which is parsed and defined by the developer. |
pycallback |
Billing callback. Billing callback prototype: (When calling KBEngine.chargeResponse in interfaces, the callback is called if an order is set to callback) def on*ChargeCB(self, orderID, dbID, success, datas): ordersID: string, OrderID dbID: uint64, usually the databaseID of the entity. success: bool, whether the order succeeded datas: bytes, with data, parsed and defined by the developer. |
def createEntity( ):
def createEntityAnywhere( entityType, params, callback ):
params = { "name" : "kbe", # base, BASE_AND_CLIENT "HP" : 100, # cell, ALL_CLIENT, in cellData "tmp" : "tmp" # baseEntity.tmp } def onCreateEntityCallback(entity) print(entity) createEntityAnywhere("Avatar", params, onCreateEntityCallback)
parameters:
entityType |
string, specifies the type of Entity
to create. Valid entity types are listed in |
params | optional parameter, a Python dictionary object. If a specified key is an Entity attribute, its value will be used to initialize the properties of this Entity. If the key is a Cell attribute, it will be added to the 'cellData' attribute of the Entity. This cellData' attribute is a Python dictionary and will be used later to initialize the attributes of the cell entity. |
callback | An optional callback function that is called when the entity is created. The callback function takes one argument, when the Entity is created successfully it is the entity's entityCall, on failure it is None. |
returns:
Returns the entityCall of the Entity through the callback. |
def createEntityRemotely( entityType, baseMB, params, callback ):
params = { "name" : "kbe", # base, BASE_AND_CLIENT "HP" : 100, # cell, ALL_CLIENT, in cellData "tmp" : "tmp" # baseEntity.tmp } def onCreateEntityCallback(entity) print(entity) createEntityRemotely("Avatar", baseEntityCall, params, onCreateEntityCallback)
parameters:
entityType |
string, specifies the type of Entity
to create. Valid entity types are listed in |
baseMB | BaseEntityCall which is a base Entity EntityCall. The entity will be created on the baseapp process corresponding to this entity. |
params | Optional parameters, a Python dictionary object. If a specified key is an Entity attribute, its value will be used to initialize the properties of this Entity. If this key is a Cell attribute, it will be added to the Entity's 'cellData' attribute. This 'cellData' attribute is a Python dictionary and will be used later to initialize the attributes of the cell entity. |
callback | An optional callback function that is called when the entity is created. The callback takes one argument, on success it is an Entity实体的entityCall, on failure it is None. |
returns:
Returns the Entity's entityCall through the callback. |
def createEntityFromDBID( entityType, dbID, callback, dbInterfaceName ):
parameters:
entityType |
string, specifies the Entity type to
load. Valid entity types are listed in |
dbID | Specifies the database ID of the entity to create. The database ID of this entity is stored in the entity's databaseID attribute. |
callback |
An optional callback function that is called when the operation is complete.
The callback function has three parameters: baseRef, databaseID, and wasActive.
If the operation is successful, baseRef will be an entityCall
or a direct reference to the newly created Entity.
The databaseID will be the database ID of the entity. wasActive will be
True if baseRef is a reference to an already existing entity (checked out
from the database). If the operation fails the three parameters will be
baseRef - None, databaseID - 0, wasActive - False.
The most common reason for failure is that the entity does not exist in the database, but occasionally other errors such as timeouts or ID allocation failure. |
dbInterfaceName | string, optional parameter, specified by a database interface, and the "default" interface is used by default. Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def createEntityAnywhereFromDBID( entityType, dbID, callback, dbInterfaceName ):
parameters:
entityType |
string, specifies the Entity type to
load. Valid entity types are listed in |
dbID | Specifies the database ID of the entity to create. The database ID of this entity is stored in the entity's databaseID attribute. |
callback |
An optional callback function that is called when the operation is complete.
The callback function has three parameters: baseRef, databaseID, and wasActive.
If the operation is successful, baseRef will be an entityCall
or a direct reference to the newly created Entity.
The databaseID will be the database ID of the entity. wasActive will be
True if baseRef is a reference to an already existing entity (checked out
from the database). If the operation fails the three parameters will be
baseRef - None, databaseID - 0, wasActive - False.
The most common reason for failure is that the entity does not exist in the database, but occasionally other errors such as timeouts or ID allocation failure. |
dbInterfaceName | string, optional parameter, specified by a database interface, and the "default" interface is used by default. Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
returns:
The Entity's entityCall through the callback. |
def createEntityRemotelyFromDBID( entityType, dbID, baseMB, callback, dbInterfaceName ):
parameters:
entityType |
string, specifies the Entity type to
load. Valid entity types are listed in |
dbID | Specifies the database ID of the entity to create. The database ID of this entity is stored in the entity's databaseID attribute. |
callback |
An optional callback function that is called when the operation is complete.
The callback function has three parameters: baseRef, databaseID, and wasActive.
If the operation is successful, baseRef will be an entityCall
or a direct reference to the newly created Entity.
The databaseID will be the database ID of the entity. wasActive will be
True if baseRef is a reference to an already existing entity (checked out
from the database). If the operation fails the three parameters will be
baseRef - None, databaseID - 0, wasActive - False.
The most common reason for failure is that the entity does not exist in the database, but occasionally other errors such as timeouts or ID allocation failure. |
dbInterfaceName | string, optional parameter, specified by a database interface, and the "default" interface is used by default. Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
returns:
Returns the Entity's entityCall through the callback. |
def createEntityLocally( entityType, params ):
params = { "name" : "kbe", # base, BASE_AND_CLIENT "HP" : 100, # cell, ALL_CLIENT, in cellData "tmp" : "tmp" # baseEntity.tmp } baseEntity = createEntityLocally("Avatar", params)
parameters:
entityType |
string, specifies the type of entity to create. Valid entity types are
listed in |
params | optional parameter, a Python dictionary object. If a specified key is an Entity attribute, its value will be used to initialize the properties of this Entity. If the key is a Cell attribute, it will be added to the 'cellData' attribute of the Entity. This cellData' attribute is a Python dictionary and will be used later to initialize the attributes of the cell entity. |
returns:
The newly created Entity. |
def debugTracing( ):
def delWatcher( path ):
parameters:
path | The path to the variable to delete. |
def deleteEntityByDBID( entityType, dbID, callback, dbInterfaceName ):
parameters:
entityType |
string, specifies the type of Entity to delete. Valid entity types are
listed in |
dbID | Specifies the database ID of the entity to delete. The database ID of the entity is stored in the entity's databaseID attribute.databaseID属性。 |
callback | An optional callback, with only one parameter. When the entity has not been checked out from the database it will be deleted successfully and the parameter will be True. If the entity has been checked out from the database then the parameter is the Entity's entityCall. |
dbInterfaceName | String, optional parameter, specifies a database interface. By default it uses the "default" interface. Database interfaces are defined by kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def deregisterReadFileDescriptor( fileDescriptor ):
parameters:
fileDescriptor | socket descriptor/file descriptor |
def deregisterWriteFileDescriptor( fileDescriptor ):
parameters:
fileDescriptor | socket descriptor/file descriptor. |
def executeRawDatabaseCommand( command, callback, threadID, dbInterfaceName ):
parameters:
command | This database command will be different for different database configuration scenarios. For a MySQL database it is an SQL query. |
callback |
Optional parameter, callback object (for example, a function) called
back with the command execution result. |
threadID | int32, optional parameter, specifies a thread to process this command. Users can use this parameter to control the execution order of certain commands (dbmgr is multi-threaded). The default is not specified. If threadId is the ID of an entity, it will be added to the entity's archive queue and written by the thread one by one. |
dbInterfaceName | string, optional parameter, specifies a database interface. By default it uses the "default" interface. Database interfaces are defined by kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def genUUID64( ):
returns:
Returns a 64-bit integer. |
def getResFullPath( res ):
parameters:
res | string, the relative path of the resource |
returns:
string, if there is an absolute path to the given resource, otherwise returns null. |
def getWatcher( path ):
parameters:
path | string, the absolute path of the variable including the variable name (can be viewed on the GUIConsole watcher page). |
returns:
The value of the variable. |
def getWatcherDir( path ):
parameters:
path | string, the absolute path to this variable (can be viewd on the GUIConsole watcher page). |
returns:
Monitors the list of elements in the directory (directory, variable name). |
def getAppFlags( ):
returns:
KBEngine.APP_FLAGS_* |
def hasRes( res ):
parameters:
res | string, the relative path of the resource |
returns:
bool, True if relative path exists, otherwise False. |
def isShuttingDown( ):
returns:
True if the server is shutting down, otherwise False. |
def listPathRes( path, extension ):
parameters:
res | string, the relative path of the resource directory |
extension | string, optional parameter, file extension to filter by |
returns:
Tuple, resource list. |
def lookUpEntityByDBID( entityType, dbID, callback, dbInterfaceName ):
parameters:
entityType |
string, specifies the type of Entity to query. Valid entity types are
listed in |
dbID |
Specifies the database ID of the Entity
to be queried. The database ID is stored in the entity's |
callback | A callback with one parameter, True when the entity is not checked out from the database, if it is checked out then it is the Entity's entityCall. False in any other case. |
dbInterfaceName | string, optional parameter, specifies a database interface. Uses the "default" interface by default. Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def matchPath( res ):
parameters:
res | string, the relative path of the resource (including its name). |
returns:
string, the absolute path of the resource. |
def open( res, mode ):
parameters:
res | string, the relative path of the resource. |
mode |
string, file operation mode: w Open in write mode, a Open in append mode (Start from EOF, create new file if necessary) r+ Open w+ in read/write mode Open in read/write mode (see w) a+ Open in read/write mode (See a) rb Opens wb in binary read mode Opens in binary write mode (see w) ab Opens in binary append mode (see a) rb+ Opens in binary read and write mode (see r+) wb+ Opens in binary read and write mode (see w+ ) ab+ opens in binary read/write mode (see a+) |
def publish( ):
returns:
int8, 0: debug, 1: release, others can be customized. |
def quantumPassedPercent( ):
returns:
Returns the percentage of the current tick that takes one clock cycle. |
def registerReadFileDescriptor( fileDescriptor, callback ):
parameters:
fileDescriptor | socket descriptor/file descriptor. |
callback | A callback function with the socket descriptor/file descriptor as its only parameter. |
def registerWriteFileDescriptor( fileDescriptor, callback ):
parameters:
fileDescriptor | socket descriptor/file descriptor |
callback | A callback function with the socket descriptor/file descriptor as its only parameter. |
def reloadScript( fullReload ):
for e in KBEngine.entities.values(): if type( e ) is Avatar.Avatar: e.customData.__class__ = CustomClassWhen this mehod completes, KBEngine.onInit( True ) is called.
parameters:
fullReload | bool, optional parameter that specifies whether to reload entity definitions at the same time. If this parameter is False, the entity definition will not be reloaded. The default is True. |
returns:
True if the reload succeeds, otherwise False. |
def scriptLogType( logType ):
def setAppFlags( flags ):
def time( ):
returns:
uint32, the time of the current game. This refers to the number of cycles. The period is affected by the frequency. The frequency is determined by the configuration file kbengine.xml or kbengine_defaults.xml->gameUpdateHertz. |
def onBaseAppReady( isBootstrap ):
parameters:
isBootstrap | bool, True if this is the first Baseapp started |
def onBaseAppShutDown( state ):
parameters:
state | If state is 0, it means that it is before all clients are disconnected, if state is 1, it means that it is before all entities are written to the database, if state is 2, it mean all entities have been written to the database. |
def onCellAppDeath( addr ):
parameters:
addr |
Dead cellapp address. tuple:(ip, port) Network byte order |
def onFini( ):
def onBaseAppData( key, value ):
parameters:
key | The key of the changed data. |
value | The value of the changed data. |
def onBaseAppDataDel( key ):
parameters:
key | Deleted data key |
def onGlobalData( key, value ):
parameters:
key | The key of the changed data |
value | The value of the changed data |
def onGlobalDataDel( key ):
parameters:
key | Deleted data key. |
def onInit( isReload ):
parameters:
isReload | bool, whether it was triggered after rewriting the loading script. |
def onLoseChargeCB( orderID, dbID, success, datas ):
parameters:
ordersID | string, order ID. |
dbID | uint64, the database ID of the entity, see: Entity.databaseID. |
success | bool, is it successful? |
datas | bytes, with information |
def onReadyForLogin( isBootstrap ):
parameters:
isBootstrap | bool, True if this is the first Baseapp started. |
returns:
If the return value is greater than or equal to 1.0, the script layer is ready; otherwise, return a value from 0 to less than 1.0. |
def onReadyForShutDown( ):
returns:
bool if it returns True, it allows the process to exit. Returning other values will cause the process to ask again after a period of time. |
def onAutoLoadEntityCreate( entityType, dbID ):
parameters:
entityType |
string, specifies the type of entity to query. Valid entity types are listed in |
dbID | specifies the database ID of the Entity to be queried. The database ID of this entity is stored in the entity's databaseID attribute. |
LOG_ON_ACCEPT
LOG_ON_REJECT
LOG_ON_WAIT_FOR_DESTROY
LOG_TYPE_DBG
LOG_TYPE_ERR
LOG_TYPE_INFO
LOG_TYPE_NORMAL
LOG_TYPE_WAR
NEXT_ONLY
component
entities
>>> KBEngine.entities.garbages.items() [(1025, Avatar object at 0x7f92431ceae8.)]
>>> e = _[0][1] >>> import gc >>> gc.get_referents(e) [{'spacesIsOk': True, 'bootstrapIdx': 1},]
Types:
Entities |
baseAppData
KBEngine.baseAppData[ "hello" ] = "there"
print KBEngine.baseAppData[ "hello" ]
KBEngine.baseAppData[ "list" ] = [1, 2, 3] KBEngine.baseAppData[ "list" ][1] = 7The local access is [1, 7, 3] and the remote access is [1, 2, 3].
globalData
KBEngine.globalData[ "hello" ] = "there"
print KBEngine.globalData[ "hello" ]
KBEngine.globalData[ "list" ] = [1, 2, 3] KBEngine.globalData[ "list" ][1] = 7The local access is [1, 7, 3] and the remote access is [1, 2, 3].
Copyright KBEngine
KBEngine |
Entity is part of the KBEngine module. More...
import KBEngine
def addTimer( self, initialOffset, repeatOffset=0, userArg=0 ): |
def createCellEntity( self, cellEntityMB ): |
def createCellEntityInNewSpace( self, cellappIndex ): |
def delTimer( self, id ): |
def destroy( self, deleteFromDB, writeToDB ): |
def destroyCellEntity( self ): |
def teleport( self, baseEntityMB ): |
def writeToDB( self, callback, shouldAutoLoad, dbInterfaceName ): |
def onCreateCellFailure( self ): |
def onDestroy( self ): |
def onGetCell( self ): |
def onLoseCell( self ): |
def onPreArchive( self ): |
def onRestore( self ): |
def onTimer( self, timerHandle, userData ): |
def onWriteToDB( self, cellData ): |
cell | Read-only CellEntityCall |
cellData | CELLDATADICT |
className | Read-only string |
client | Read-only ClientEntityCall |
databaseID | Read-only int64 |
databaseInterfaceName | Read-only string |
id | Read-only int32 |
isDestroyed | bool |
shouldAutoArchive | True, False or KBEngine.NEXT_ONLY |
shouldAutoBackup | True, False or KBEngine.NEXT_ONLY |
def addTimer( self, initialOffset, repeatOffset=0, userArg=0 ):
# Here is an example of using addTimer import KBEngine class MyBaseEntity( KBEngine.Entity ): def __init__( self ): KBEngine.Entity.__init__( self ) # Add a timer, trigger for the first time after 5 seconds, and execute once per second afterwards. The user parameter is 9. self.addTimer( 5, 1, 9 ) # Add a timer and execute it once after 1 second. The default user parameter is 0. self.addTimer( 1 ) # Entity timer callback "onTimer" is called def onTimer( self, id, userArg ): print "MyBaseEntity.onTimer called: id %i, userArg: %i" % ( id, userArg ) # If this is a repeated timer, when the timer is no longer needed, call the following function to remove it: # self.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to trigger the first callback. |
repeatOffset | float, specifies the time interval (in seconds) after each execution of the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
userArg | integer, specifies the value of the userArg parameter when invoking the "onTimer" callback. |
returns:Z
integer, the internal id of the timer. This id can be used to remove the timer using delTimer. |
def createCellEntity( self, cellEntityMB ):
parameters:
cellEntityMB |
CellEntityCall parameter
that specifies which space to create this cell entity in.
Only a direct CellEntityCall may be used. If you have an entity's BaseEntityCall, you cannot pass its baseEntityCall.cell to this function. Instead, you must create a new function on the current entity's base that accepts a direct CellEntityCall as a parameter and then calls this function using it. E.g. baseEntityCallOfNearbyEntity.createCellNearSelf( self )On the nearby entity's base: def createCellNearSelf( self, baseEntityCall ): baseEntityCall.createCellNearHere( self.cell )On the current entity's base: def createCellNearHere( self, cellEntityCall ): self.createCellEntity( cellEntityCall ) |
def createCellEntityInNewSpace( self, cellappIndex ):
parameters:
cellappIndex |
integer, if it is either None or 0, a cellapp is dynamically selected by
the engine load balancer. If it is greater than 0, a space is created in
the specified cellapp Example: If you expect to open four cellapps, then the cellappIndex needs to specify the index can be 1, 2, 3, 4, if the actual running cellapp is less than 4, for example, only 3, then the cellappIndex input 4 due to the number of overflow 4 1, 5 2. Tip: This feature can be used in conjunction with KBEngine.setAppFlags (KBEngine.APP_FLAGS_NOT_PARTCIPATING_LOAD_BALANCING), for example: placing large map spaces in several fixed cellapps and setting these cellapps to not participate in load balancing, and other cellapps to place copy space. When the copyspace is created and the cellappIndex is set to 0 or None, the consumption of the copy map will not affect the large map process, thus ensuring the smoothness of the main scene. |
def delTimer( self, id ):
parameters:
id | integer, which specifies the timer id to remove. |
def destroy( self, deleteFromDB, writeToDB ):
parameters:
deleteFromDB | If True, the entry associated with this entity in the database will be deleted. This parameter defaults to False. |
writeToDB | If True, the archived attributes associated with this entity will be written to the database. Only if this entity is read for the database or uses Entity.writeToDB will it be written to the database. This parameter is True by default, but will be ignore when deleteFromDB is True. |
def destroyCellEntity( self ):
def teleport( self, baseEntityMB ):
parameters:
baseEntityMB | The EntityCall of the entity that is in the space this entity will be teleported. When successful, the cell entity associated with this parameter is passed to the Entity.onTeleportSuccess function. |
def writeToDB( self, callback, shouldAutoLoad, dbInterfaceName ):
parameters:
callback | This optional parameter is a callback function when the database operation is complete. It has two parameters. The first is a success or failure boolean flag, and the second is the base entity. |
shouldAutoLoad |
This optional parameter specifies whether this entity needs to be loaded
from the database when the service is started. Note: The entity is automatically loaded when the server starts. The default is to call createEntityAnywhereFromDBID to create an entity to a minimally loaded baseapp. The entire process will be completed before the first started baseapp calls onBaseAppReady. The script layer can reimplement the entity creation method in the personalization script (kbengine_defaults.xml->baseapp->entryScriptFile definition), for example: def onAutoLoadEntityCreate(entityType, dbid): KBEngine.createEntityFromDBID(entityType, dbid) |
dbInterfaceName | string, optional parameter, specified by a database interface, default is to use the "default" interface. Database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces. |
def onCreateCellFailure( self ):
def onDestroy( self ):
def onGetCell( self ):
def onLoseCell( self ):
def onPreArchive( self ):
def onRestore( self ):
def onTimer( self, timerHandle, userData ):
parameters:
timerHandle | The id of the timer. |
userData | integer, User data passed in on Entity.addTimer. |
def onWriteToDB( self, cellData ):
parameters:
cellData | Contains the cell properties that will be stored in the database. cellData is a dictionary. |
cell
Type:
Read-only ENTITYCALL |
cellData
Type:
CELLDATADICT |
className
Type:
Read-only string |
client
Type:
Read-only ENTITYCALL |
databaseID
Type:
Read-only int64 |
databaseInterfaceName
Type:
Read-only string |
id
Type:
Read-only int32 |
isDestroyed
Type:
bool |
shouldAutoArchive
Type:
True, False or KBEngine.NEXT_ONLY |
shouldAutoBackup
Type:
True, False or KBEngine.NEXT_ONLY |
Copyright KBEngine
KBEngine |
Proxy is part of the KBEngine module. More...
import KBEngine
def disconnect( self ): |
def getClientType( self ): |
def getClientDatas( self ): |
def giveClientTo( self, proxy ): |
def streamFileToClient( self, resourceName, desc="", id=-1 ): |
def streamStringToClient( self, data, desc="", id=-1 ): |
def onClientDeath( self ): |
def onClientGetCell( self ): |
def onClientEnabled( self ): |
def onGiveClientToFailure( self ): |
def onLogOnAttempt( self, ip, port, password ): |
def onStreamComplete( self, id, success ): |
__ACCOUNT_NAME__ | Read-only string |
__ACCOUNT_PASSWORD__ | Read-only string |
clientAddr | Read-only |
clientEnabled | Read-only bool |
hasClient | Read-only bool |
roundTripTime | Read-only |
timeSinceHeardFromClient | Read-only |
def disconnect( self ):
def getClientType( self ):
returns:
UNKNOWN_CLIENT_COMPONENT_TYPE = 0, CLIENT_TYPE_MOBILE = 1, // Mobile phone CLIENT_TYPE_WIN = 2, // PC, typically EXE clients CLIENT_TYPE_LINUX = 3 // Linux Application program CLIENT_TYPE_MAC = 4 // Mac Application program CLIENT_TYPE_BROWSER = 5, // Web applications, HTML5, Flash CLIENT_TYPE_BOTS = 6, // bots CLIENT_TYPE_MINI = 7, // Mini-Client CLIENT_TYPE_END = 8 // end |
def getClientDatas( self ):
returns:
tuple, a tuple of 2 elements (login data bytes, registration data bytes), the first element is the datas parameter passed in when the client invokes the login, and the second element is passed in when the client registers. Since they can store arbitrary binary data, they all exist as bytes. |
def giveClientTo( self, proxy ):
See also:
Proxy.onGiveClientToFailure |
parameters:
proxy | Control will be transferred to this entity. |
def streamFileToClient( self, resourceName, desc="", id=-1 ):
See also:
Proxy.onStreamComplete |
parameters:
resourceName | The name of the resource to send, including the path. |
desc | An optional string that describes the resource sent to the client. |
id | A 16-bit id whose value depends entirely on the caller. If the incoming -1 system will select an unused id in the queue. The client can make resource judgments based on this id. |
returns:
The id associated with this download. |
def streamStringToClient( self, data, desc="", id=-1 ):
parameters:
data | The string to send |
desc | An optional description string sent. |
id | A 16-bit id whose value depends entirely on the caller. If the incoming -1 system will select an unused id in the queue. |
returns:
The id associated with this download. |
def onClientDeath( self ):
def onClientGetCell( self ):
def onClientEnabled( self ):
def onGiveClientToFailure( self ):
def onLogOnAttempt( self, ip, port, password ):
parameters:
ip | The IP address of the client trying to log in. |
port | The port to which the client attempted to log in. |
password | The MD5 password used when the user logs in. |
def onStreamComplete( self, id, success ):
parameters:
id | The id associated with the download. |
success | Success or failure |
__ACCOUNT_NAME__
__ACCOUNT_PASSWORD__
clientAddr
clientEnabled
hasClient
roundTripTime
timeSinceHeardFromClient
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): |
def delTimer( id ): |
def onLoginAppReady( ): |
def onLoginAppShutDown( ): |
def onRequestLogin( loginName, password, clientType, datas ): |
def onLoginCallbackFromDB( loginName, accountName, errorno, datas ): |
def onRequestCreateAccount( accountName, password, datas ): |
def onCreateAccountCallbackFromDB( accountName, errorno, datas ): |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ):
# Here is an example of using addTimer import KBEngine # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9 KBEngine.addTimer( 5, 1, onTimer_Callbackfun ) # Add a timer and execute it after 1 second. The default user parameter is 0. KBEngine.addTimer( 1, onTimer_Callbackfun ) def onTimer_Callbackfun( id ): print "onTimer_Callbackfun called: id %i" % ( id ) # If this is a repeated timer, it is no longer needed, call the following function to remove: # KBEngine.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to register from the first callback. |
repeatOffset | float, specifies the time interval (in seconds) between each execution after the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
callbackObj | function, the specified callback function object |
returns:
integer, the internal id of the timer. This id can be used to remove the timer using delTimer |
def delTimer( id ):
parameters:
id | integer, timer id to remove |
def onLoginAppReady( ):
def onLoginAppShutDown( ):
def onRequestLogin( loginName, password, clientType, datas ):
parameters:
loginName | string, the name of the account submitted when logging in. |
password | string, MD5 password. |
clientType | integer, client type, given when the client logs in. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |
returns:
Tuple, the return value is (error code, real account name, password, client type, data data submitted by the client), if there is no need to extend the modification, the return value is usually to destroy the incoming value (KBEngine.SERVER_SUCCESS , loginName, password, clientType, datas). |
def onLoginAppReady( ):
def onLoginAppShutDown( ):
def onLoginCallbackFromDB( loginName, accountName, errorno, datas ):
parameters:
loginName | string, the name of the account submitted when logging in. |
accountName | string, the real account name (obtained from the the query at dbmgr) |
errorno | integer, error code, if it is not KBEngine.SERVER_SUCCESS, login failed. |
datas | bytes, which may be any data, such as data returned by a third-party platform or data returned by dbmgr and interfaces when processing the login. |
def onRequestCreateAccount( accountName, password, data ):
parameters:
accountName | string, the name of the account submitted by the client. |
password | string, MD5 password. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |
returns:
Tuple, the return value is (error code, real account name, password, data data submitted by the client), if there is no need to extend the modified value is usually returned to destroy the incoming value (KBEngine.SERVER_SUCCESS, loginName, password , datas). |
def onCreateAccountCallbackFromDB( accountName, errorno, datas ):
parameters:
accountName | string, the name of the account submitted by the client. |
errorno | integer, error code, if it is not KBEngine.SERVER_SUCCESS, login failed. |
datas | bytes, which may be any data, such as data returned by a third-party platform or data returned by dbmgr and interfaces when processing the login. |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): |
def delTimer( id ): |
def onDBMgrReady( ): |
def onDBMgrShutDown( ): |
def onReadyForShutDown( ): |
def onSelectAccountDBInterface( accountName ): |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ):
# Here is an example of using addTimer import KBEngine # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9 KBEngine.addTimer( 5, 1, onTimer_Callbackfun ) # Add a timer and execute it after 1 second. The default user parameter is 0. KBEngine.addTimer( 1, onTimer_Callbackfun ) def onTimer_Callbackfun( id ): print "onTimer_Callbackfun called: id %i" % ( id ) # If this is a repeated timer, it is no longer needed, call the following function to remove: # KBEngine.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to register the first callback. |
repeatOffset | float, specifies the time interval (in seconds) after each execution of the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
callbackObj | function, the specified callback function object. |
returns:
integer, this function returns the internal id of the timer. This id can be used to remove the timer using delTimer. |
def delTimer( id ):
parameters:
id | integer, specifies the timer id to remove. |
def onDBMgrReady( ):
def onDBMgrShutDown( ):
def onReadyForShutDown( ):
returns:
bool, if it returns True, it allows the process to exit. Returning other values will cause the process to ask again after a period of time. |
def onSelectAccountDBInterface( accountName ):
parameters:
accountName | string, the name of the account. |
returns:
string, the database interface name (database interfaces are defined in kbengine_defaults.xml->dbmgr->databaseInterfaces). |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
Entity |
PyClientApp |
def addBots( reqCreateAndLoginTotalCount, reqCreateAndLoginTickCount=0, reqCreateAndLoginTickTime=0 ): |
def callback( initialOffset, callbackObj ): |
def cancelCallback( id ): |
def genUUID64( ): |
def getWatcher( path ): |
def getWatcherDir( path ): |
def scriptLogType( logType ): |
def onInit( isReload ): |
def onFinish( ): |
bots | bots |
component | Read-only string |
def addBots( reqCreateAndLoginTotalCount, reqCreateAndLoginTickCount=0, reqCreateAndLoginTickTime=0 ):
# Here is an example of using addBots import KBEngine # Add 5 robots to the server at one time (instantaneously). KBEngine.addBots( 5 ) # Add a total of 1000 robots to the server, 5 at a time, at an interval of 10 seconds. KBEngine.addBots( 1000, 5, 10 )
parameters:
reqCreateAndLoginTotalCount | integer, integer, the total number of bots to add to the server. |
reqCreateAndLoginTickCount | integer, the number of bots added to the server each interval |
reqCreateAndLoginTickTime | integer, the interval of time (in seconds) between adding bots. |
def callback( initialOffset, callbackObj ):
# Here is an example of using callback import KBEngine # Add a timer and execute it after 1 second KBEngine.callback( 1, onCallbackfun ) def onCallbackfun( ): print "onCallbackfun called"
parameters:
initialOffset | float, time, in seconds, to wait before triggering the callback. |
callbackObj | function, the specified callback function object. |
returns:
integer, this function returns the internal id of the callback. This id can be used with cancelCallback to remove the callback. |
def cancelCallback( id ):
parameters:
id | integer, specifies the callback id to remove. |
def genUUID64( ):
returns:
A 64-bit integer. |
def getWatcher( path ):
parameters:
path | string, the absolute path of the variable including the variable name (can be viewed on the GUIConsole watcher page). |
returns:
The value of the variable. |
def getWatcherDir( path ):
parameters:
path | string, the absolute path of the variable including the variable name (can be viewed on the GUIConsole watcher page). |
returns:
A list of elements in the directory (directories, variable names). |
def scriptLogType( logType ):
def onInit( isReload ):
parameters:
isReload | bool, whether it was triggered after rewriting the loading script. |
def onFinish( ):
bots
Types:
PyBots |
component
版权归KBEngine所有。
KBEngine |
PyClientApp is a part of the KBEngine Module. It is is client object created when a client is simulated from the bottom of C++. It cannot be created in the script layer directly.
def getSpaceData( key ): |
def onDestroy( self ): |
def onEnterWorld( self ): |
def onLeaveWorld( self ): |
def onEnterSpace( self ): |
def onLeaveSpace( self ): |
id | Read-only Integer |
entities | Entities |
def getSpaceData( key ):
parameters:
key | string, a string keyword. |
returns:
string, string data for the key |
def onDestroy( self ):
def onEnterWorld( self ):
def onLeaveWorld( self ):
def onEnterSpace( self ):
def onLeaveSpace( self ):
entities
Types:
Entities |
Copyright KBEngine
KBEngine |
Entity is part of the KBEngine module. More...
import KBEngine
def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ): |
def cancelController( self, controllerID ): |
def onEnterWorld( self ): |
def onLeaveWorld( self ): |
def onEnterSpace( self ): |
def onLeaveSpace( self ): |
base | Read-only ENTITYCALL |
cell | Read-only ENTITYCALL |
className | Read-only string |
clientapp | Read-only PyClientApp |
direction | Tuple of 3 floats as (roll, pitch, yaw) |
id | Read-only Integer |
position | Vector3 |
spaceID | Read-only uint32 |
isOnGround | Read-only bool |
def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ):
def onMove( self, controllerID, userData ): def onMoveOver( self, controllerID, userData ): def onMoveFailure( self, controllerID, userData ):
See also:
Entity.cancelController |
parameters:
destination | Vector3, the target point to which the Entity is to be moved. |
velocity | float, the speed to move the Entity (in m/s). |
distance | float, the distance target which if it is within, movement is stopped. If the value is 0, it moves to the target position. |
userData | object, user data passed to the callback function. |
faceMovement | bool, True if the entity faces the direction of the move. If it is other mechanism, it is False. |
moveVertically | bool, set to True means to move in a straight line directly to the point, and False means to move in a straight line paralell to the ground. |
returns:
int, newly created controller ID. |
def cancelController( self, controllerID ):
parameters:
controllerID | integer, the index of the controller to cancel. A special controller type string can also be used. For example, only one movement/navigation controller can be activated at a time. This can be cancelled with entity.cancelController("Movement"). |
def onEnterWorld( self ):
def onLeaveWorld( self ):
def onEnterSpace( self ):
def onLeaveSpace( self ):
base
Other references:
Entity.clientEntity Entity.allClients Entity.otherClients |
Types:
Read-only, ENTITYCALL |
cell
Types:
Read-only ENTITYCALL |
cellData
Types:
CELLDATADICT |
className
Types:
Read-only, string |
clientapp
Types:
Read-only, PyClientApp |
position
Types:
Vector3 |
direction
Types:
Vector3, which contains (roll, pitch, yaw) in radians. |
isOnGround
Types:
Read-write, bool |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): |
def accountLoginResponse( commitName, realAccountName, extraDatas, errorCode ): |
def createAccountResponse( commitName, realAccountName, extraDatas, errorCode ): |
def chargeResponse( orderID, extraDatas, errorCode ): |
def delTimer( id ): |
def onInterfaceAppReady( ): |
def onInterfaceAppShutDown( ): |
def onRequestCreateAccount( registerName, password, datas ): |
def onRequestAccountLogin( loginName, password, datas ): |
def onRequestCharge( ordersID, entityDBID, datas ): |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ):
# Here is an example of using addTimer import KBEngine # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9 KBEngine.addTimer( 5, 1, onTimer_Callbackfun ) # Add a timer and execute it after 1 second. The default user parameter is 0. KBEngine.addTimer( 1, onTimer_Callbackfun ) def onTimer_Callbackfun( id ): print "onTimer_Callbackfun called: id %i" % ( id ) # If this is a repeated timer, it is no longer needed, call the following function to remove: # KBEngine.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to register from the first callback. |
repeatOffset | float, specifies the time interval (in seconds) between each execution after the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
callbackObj | function, the specified callback function object |
returns:
integer, the internal id of the timer. This id can be used to remove the timer from delTimer. |
def accountLoginResponse( commitName, realAccountName, extraDatas, errorCode ):
parameters:
commitName | string, the name submitted by the client when requested. |
realAccountName | string, returns the real account name (if there are no special requirements it is ually commitName, this is available when logging in with various alias accounts). |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def createAccountResponse( commitName, realAccountName, extraDatas, errorCode ):
parameters:
commitName | string, the name submitted by the client when requested. |
realAccountName | string, returns the real account name (if there are no special requirements it is ually commitName, this is available when logging in with various alias accounts). |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def chargeResponse( orderID, extraDatas, errorCode ):
parameters:
ordersID | uint64, the ID of the order |
extraDatas | bytes, the data attached to the client's request. Can forward the data to a third-party platform and provide an opportunity to modify it. This parameter can be read in the script via the getClientDatas interface of the base entity. |
errorCode | integer, error code. If you need to interrupt the user's behavior, you can set the error code here. The error code can be referenced (KBEngine.SERVER_ERROR_*, described in kbengine/kbe/res/server/server_errors.xml), otherwise submitting KBEngine.SERVER_SUCCESS represents permitting the login. |
def delTimer( id ):
parameters:
id | integer, which specifies the timer id to remove. |
def onInterfaceAppReady( ):
def onInterfaceAppShutDown( ):
def onRequestCreateAccount( registerName, password, datas ):
parameters:
registerName | string, the name submitted by the client when requested. |
password | string, password |
datas | bytes, the data attached to the client's request, can forward data to a third-party platform. |
def onRequestAccountLogin( loginName, password, datas ):
parameters:
loginName | string, the name submitted by the client when requested. |
password | string, password. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |
def onRequestCharge( ordersID, entityDBID, datas ):
parameters:
ordersID | uint64, the ID of the order. |
entityDBID | uint64, the entity DBID of the submitted order. |
datas | bytes, the data attached to the client request, can forward data to a third-party platform. |
Copyright KBEngine
KBEngine |
Copyright KBEngine
KBEngine |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ): |
def delTimer( id ): |
def onLoggerAppReady( ): |
def onLoggerAppShutDown( ): |
def onLogWrote( datas ): |
def onReadyForShutDown( ): |
def addTimer( initialOffset, repeatOffset=0, callbackObj=None ):
# Here is an example of using addTimer import KBEngine # Add a timer, perform the first time after 5 seconds, and execute once every 1 second. The user parameter is 9 KBEngine.addTimer( 5, 1, onTimer_Callbackfun ) # Add a timer and execute it after 1 second. The default user parameter is 0. KBEngine.addTimer( 1, onTimer_Callbackfun ) def onTimer_Callbackfun( id ): print "onTimer_Callbackfun called: id %i" % ( id ) # If this is a repeated timer, it is no longer needed, call the following function to remove: # KBEngine.delTimer( id )
parameters:
initialOffset | float, specifies the time interval in seconds for the timer to register from the first callback. |
repeatOffset | float, specifies the time interval (in seconds) between each execution after the first callback execution. You must remove the timer with the function delTimer, otherwise it will continue to repeat. Values less than or equal to 0 will be ignored. |
callbackObj | function, the specified callback function object |
returns:
integer, the internal id of the timer. This id can be used to remove the timer from delTimer. |
def delTimer( id ):
parameters:
id | integer, which specifies the timer id to remove. |
def onLoggerAppReady( ):
def onLoggerAppShutDown( ):
def onLogWrote( datas ):
parameters:
datas | bytes, log data. |
def onReadyForShutDown( ):
returns:
bool, if it returns True, it allows the process to exit. Returning other values will cause the process to ask again after a period of time. |
Copyright KBEngine