Skip to content

Entity Class

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

import KBEngine

Member Functions

def baseCall( self, methodName, methodArgs ):

def cellCall( self, methodName, methodArgs ):

def isPlayer( self ):

def getComponent( self, componentName, all ):

def fireEvent( self, eventName, *args ):

def registerEvent( self, eventName, callback ):

def deregisterEvent( self, eventName, callback ):

Callback Functions

def onDestroy( self ):

def onEnterWorld( self ):

def onLeaveWorld( self ):

def onEnterSpace( self ):

def onLeaveSpace( self ):

Properties

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

Detailed Description

An instance of the Entity class represents a game object on the client.

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

Member Function Documentation


def baseCall( self, methodName, methodArgs ):

Description: Calls the base part method of this entity.

Note

The entity must have a base part on the server. On the client, only client-controlled player entities can access this method.

Example:

js plugin: entity.baseCall("reqCreateAvatar", roleType, name);

c# plugin: entity.baseCall("reqCreateAvatar", new object[]{roleType, name});

Parameters:

methodName: string, method name.

methodArgs: objects, method argument list.

Returns:

Since this is a remote call, it cannot block and wait for a return, so there is no return value.


def cellCall( self, methodName, methodArgs ):

Description: Calls the cell part method of this entity.

Note

The entity must have a cell part on the server. On the client, only client-controlled player entities can access this method.

Example:

js plugin: entity.cellCall("xxx", roleType, name);

c# plugin: entity.cellCall("xxx", new object[]{roleType, name});

Parameters:

methodName: string, method name.

methodArgs: objects, method argument list.

Returns:

Since this is a remote call, it cannot block and wait for a return, so there is no return value.


def isPlayer( self ):

Description: This function returns whether this Entity is the Player controlled by the current client.

Returns:

bool, returns True if it is the Player controlled by the current client, otherwise returns False.


def getComponent( self, componentName, all ):

Description: This function is used to get an instance of a certain type of component bound to the entity.

Parameters:

componentName: string, component type name, the module name of the component.

all: bool, if True, returns all instances of the same type of component, otherwise returns only the first or an empty list.


def fireEvent( self, eventName, *args ):

Description: This function is used to trigger an entity event.

Parameters:

eventName: string, the name of the event to trigger.

args: event data to attach, variable arguments.


def registerEvent( self, eventName, callback ):

Description: This function is used to register an entity event.

Parameters:

eventName: string, the name of the event to listen for.

callback: the callback method to respond to the event when triggered.


def deregisterEvent( self, eventName, callback ):

Description: This function is used to deregister an entity event listener.

Parameters:

eventName: string, the name of the event to deregister.

callback: the callback method to deregister.

Callback Function Documentation


def onDestroy( self ):

Called when the entity is destroyed.


def onEnterWorld( self ):

If the entity is not a client-controlled entity, it means the entity has entered the View range of the client-controlled entity on the server, and the client can now see this entity.

If the entity is a client-controlled entity, it means the entity has created a cell on the server and entered the space.


def onLeaveWorld( self ):

If the entity is not a client-controlled entity, it means the entity has left the View range of the client-controlled entity on the server, and the client can no longer see this entity.

If the entity is a client-controlled entity, it means the entity's cell has been destroyed on the server and has left the space.


def onEnterSpace( self ):

The client-controlled entity has entered a new space.


def onLeaveSpace( self ):

The client-controlled entity has left the current space.

Property Documentation


className

The class name of the entity.

Type:

Read-only string


position

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

Type:

Vector3


direction

This property describes the orientation of the Entity in world space, data is synchronized from the server to the client.

Type:

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


isOnGround

If this property is True, the Entity is on the ground, otherwise False.

If it is a client-controlled entity, this property will be synchronized to the server when changed; for other entities, it is synchronized from the server to the client. The client can use this value to force ground alignment to avoid precision issues.

Type:

Readable and writable, bool

文档内容由 Comblock® 提供