My Project
Public Member Functions | Static Public Member Functions | List of all members
ParaEngine::CAISimulator Class Reference

AI and AI scripts handlers. More...

#include <AISimulator.h>

Public Member Functions

void AddNPLCommand (const string &sCommand)
 add an NPL command code to the pending list to be processed in the next simulation cycle. More...
 
NPL::CNPLRuntimeGetNPLRuntime ()
 get the current NPL runtime environment. More...
 
void CleanUp ()
 perform final clean up, such as shutting down the network layer. More...
 
bool IsCleanedUp ()
 
void FrameMove (float fElapsedTime=0)
 Move all object's mental states to next time. More...
 
int NPLActivate (const char *filepath, const char *code=NULL, int nLength=0)
 activate a specified file More...
 
void NPLLoadFile (const char *filename, bool bReload=false)
 run a script in the "share.lua" neuron file. More...
 
void NPLDoString (const char *strCode, int nLength=0)
 run a chunk of string in the "share.lua" neuron file. More...
 
void SetGameLoop (const string &scriptName)
 reset the game loop script. More...
 
void SetGameLoopInterval (float fInterval)
 set the game loop activation interval. More...
 

Static Public Member Functions

static CAISimulatorGetSingleton ()
 get a global instance of this class
 

Detailed Description

AI and AI scripts handlers.

It hold the only instance of the CPOLRuntimeEnv in the application game interface should query this it from CAISimulator. It serves as a bridge between the game world and the POL language. It contains a group of Host API(or HAPI) for POL to load.

AI Simulator controls all the game and player logic of the game world: It includes the following aspect. (1) NPC and player logic. (2) sequential cut scenes. (3) saving and restoring all game states. (4) Network logic is handled transparently within the POL.

Member Function Documentation

§ AddNPLCommand()

void ParaEngine::CAISimulator::AddNPLCommand ( const string &  sCommand)

add an NPL command code to the pending list to be processed in the next simulation cycle.

This function is thread-safe by using a mutex internally.

§ CleanUp()

void CAISimulator::CleanUp ( )

perform final clean up, such as shutting down the network layer.

§ FrameMove()

void CAISimulator::FrameMove ( float  fElapsedTime = 0)

Move all object's mental states to next time.

desc: Move all object's mental states to next time the following global states are defined specific to this simulator (1) for all NPC type object, "npc_name = object.identifer();" is passed to the neuron file as input.

(1.1) for all OPC type object, "opc_name = object.identifer();" is passed to the neuron file as input. (2) for GUI sensor type object, "sensor_name = object.identifer();" is passed to the neuron file as input. (2.1) for GUI sensor type object that accept key strokes, an additional "keystring = keystrings" is passed as input.

– execute NPL network logic for one pass

§ GetNPLRuntime()

NPL::CNPLRuntime* ParaEngine::CAISimulator::GetNPLRuntime ( )
inline

get the current NPL runtime environment.

§ NPLActivate()

int CAISimulator::NPLActivate ( const char *  filepath,
const char *  code = NULL,
int  nLength = 0 
)

activate a specified file

activate a local neuron file by its file path in the local directory

Parameters
code
nLengththe code length. if this is 0, length is determined from code, however, it must not exceed 4096 bytes. if it is specified. it can be any code length
Returns
: same as NPL.activate return value.

§ NPLDoString()

void CAISimulator::NPLDoString ( const char *  strCode,
int  nLength = 0 
)

run a chunk of string in the "share.lua" neuron file.

It is equivalent to calling "strCode" in the global space of "share.lua".

Parameters
nLengthdefault to 0. if it is 0, the strCode must be exceed to the code length limit.

§ NPLLoadFile()

void CAISimulator::NPLLoadFile ( const char *  filename,
bool  bReload = false 
)

run a script in the "share.lua" neuron file.

It is equivalent to calling dofile("filename") in the global space of "share.lua". Each time, the file will be parsed and executed. The file is better containing no function definition or global variables. In other words, the file is better containing only ParaEngine UI commands.

Parameters
bReloadwhether reload the file if it already exists.

§ SetGameLoop()

void CAISimulator::SetGameLoop ( const string &  scriptName)

reset the game loop script.

the game loop script will be activated every 0.5 seconds see SetGameLoopInterval() to change the default interval Please keep the game loop concise. The default game loop is ./script/gameinterface.lua

§ SetGameLoopInterval()

void CAISimulator::SetGameLoopInterval ( float  fInterval)

set the game loop activation interval.

The default value is 0.5 seconds.


The documentation for this class was generated from the following files: