Entity - KBEngine bots

KBEngine API

KBEngine

Entity class

[KBEngine module]

Entity is part of the KBEngine module. More...

import KBEngine

Member functions

def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ):
def cancelController( self, controllerID ):

Callbacks

def onEnterWorld( self ):
def onLeaveWorld( self ):
def onEnterSpace( self ):
def onLeaveSpace( self ):

Attributes

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

A detailed description

Instances of the class Entity represent game objects on the client.



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

Member functions documentation

def moveToPoint( self, destination, velocity, distance, userData, faceMovement, moveVertically ):

Function description:

Moves the Entity to the given coordinate point in a straight line. The callback will be called on success or failure.
Any Entity can only have one motion controller at any time. Repeatedly calling any move function will terminate the previous move controller.
Returns a controller ID that can be used to cancel this move.

Example:
You can use Entity.cancelController( movementID ) or Entity.cancelController( "Movement" ) to cancel the move. The callback will not be called if the move is cancelled.

The callback functions are defined as follows:
	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 ):

Function description:

The cancelController function stops the effect of a controller on the Entity. It can only be called on a real entity.

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").


Callback functions documentation

def onEnterWorld( self ):

If the entity is not a client-controlled entity, it indicates that the entity has entered the View scope of the entity controlled by the client on the server side. At this time, the client can see this entity.
If the entity is a client-controlled entity, it indicates that the entity has created a cell on the server and entered space.

def onLeaveWorld( self ):

If the entity is not a client-side control entity, it indicates that the entity has left the view scope of the client-controlled entity on the server side, and the client cannot see this entity at this time.
If the entity is a client-controlled entity, it indicates that the entity has destroyed the cell on the server and left space.

def onEnterSpace( self ):

The client-controlled entity enters a new space.

def onLeaveSpace( self ):

The client-controlled entity leaves the current space.

Attributes documentation

base

base is the entityCall used to contact the base Entity. This attribute is read-only, and is None if this entity does not have an associated base Entity.

Other references:

Entity.clientEntity
Entity.allClients
Entity.otherClients

Types:

Read-only, ENTITYCALL

cell

Description:

cell is the ENTITYCALL used to contact the cell entity. This attribute is Read-only, and is None if the base entity has no associated cell.

Types:

Read-only ENTITYCALL

cellData

Description:

cellData is a dictionary property. Whenever the base entity has not created its cell entity, the attributes of the cell entity are stored here.

If the cell entity is created, the values and cellData attributes will be deleted. In addition to the attributes that the cell entity specifies in the entity definition file, it also contains position, direction, and spaceID.

Types:

CELLDATADICT

className

Description:

The class name of the entity.

Types:

Read-only, string

clientapp

Description:

The client (object) to which the current entity belongs.

Types:

Read-only, PyClientApp

position

The coordinates (x, y, z) of this entity in world space. The data is synchronized from the server to the client.

Types:

Vector3

direction

This attribute describes the orientation of the Entity in world space. Data is synchronized from the server to the client.

Types:

Vector3, which contains (roll, pitch, yaw) in radians.

isOnGround

If the value of this attribute is True, the Entity is on the ground, otherwise it is False.
If it is a client-controlled entity, this attribute will be synchronizd to the server at the time of change, and other entities will be synchronized to the client by the server. The client can determine this value to reduce the cost of accuracy.

Types:

Read-write, bool