Annwvyn::AnnBehaviorScript Class Reference

Object that reprenset a script defining an object "behavior". More...

#include <AnnScriptManager.hpp>

Inheritance diagram for Annwvyn::AnnBehaviorScript:
Collaboration diagram for Annwvyn::AnnBehaviorScript:

Public Member Functions

 AnnBehaviorScript ()
 Invalid script constructor. More...
 
 AnnBehaviorScript (const std::string &name, std::function< void(chaiscript::Boxed_Value &)> updateHook, AnnBehaviorScriptHooks hooks, chaiscript::Boxed_Value scriptObjectInstance)
 Callable script constructor. More...
 
virtual ~AnnBehaviorScript ()
 Script destructor. More...
 
void update ()
 Call this to call the "update" of the script. More...
 
bool isValid () const
 Return true if the script is valid. If the object is in a state where this returns false, calling "update" on it will crash. More...
 
void registerAsListener ()
 register this object as an event listener More...
 
void unregisterAsListener ()
 unregister this object as an event listener More...
 
void KeyEvent (AnnKeyEvent e) override
 Event from the keyboard. More...
 
void MouseEvent (AnnMouseEvent e) override
 Event from the mouse. More...
 
void ControllerEvent (AnnControllerEvent e) override
 Event for a Joystick. More...
 
void TimeEvent (AnnTimeEvent e) override
 Event from a timer. More...
 
void TriggerEvent (AnnTriggerEvent e) override
 Event from a trigger. More...
 
void HandControllerEvent (AnnHandControllerEvent e) override
 Event from an HandController. More...
 
void CollisionEvent (AnnCollisionEvent e) override
 Event from the collision between 2 game objects. More...
 
void PlayerCollisionEvent (AnnPlayerCollisionEvent e) override
 Event from the collision between the player and a game object. More...
 

Private Member Functions

void callUpdateOnScript ()
 Just call the update on the instance. More...
 

Private Attributes

const bool valid
 Validity state of this object. Cannot change. More...
 
std::string name
 Name of this script. Name of the "class" defined in the script. More...
 
chaiscript::Boxed_Value ScriptObjectInstance
 The ChaiScript object that is an instance of "name" class. BlackBox to find what "update" to call on the script engine. More...
 
std::function< void(chaiscript::Boxed_Value &)> callUpdateOnScriptInstance
 The "update" function. ChaiScript "object.update()" is like calling "update(object)". More...
 
std::function< void(chaiscript::Boxed_Value &, AnnKeyEvent)> callKeyEventOnScriptInstance
 Hook for key event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnMouseEvent)> callMouseEventOnScriptInstance
 Hook for Mouse event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnControllerEvent)> callStickEventOnScriptInstance
 Hook for Stick event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnTimeEvent)> callTimeEventOnScriptInstance
 Hook for Time event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnTriggerEvent)> callTriggerEventOnScriptInstance
 Hook for Trigger event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnHandControllerEvent)> callHandControllertOnScriptInstance
 Hook for Hand Controller event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnCollisionEvent)> callCollisionEventOnScriptInstance
 Hook for Collision event. More...
 
std::function< void(chaiscript::Boxed_Value &, AnnPlayerCollisionEvent)> callPlayerCollisionEventOnScriptInstance
 Hook for PlayerCollision event. More...
 
bool cannotKey
 Call guards for the hooks above. More...
 
bool cannotMouse
 
bool cannotStick
 
bool cannotTime
 
bool cannotTrigger
 
bool cannotHand
 
bool cannotCollision
 
bool cannotPlayerCollision
 

Detailed Description

Object that reprenset a script defining an object "behavior".

Definition at line 39 of file AnnScriptManager.hpp.

Constructor & Destructor Documentation

◆ AnnBehaviorScript() [1/2]

AnnBehaviorScript::AnnBehaviorScript ( )

Invalid script constructor.

Definition at line 566 of file AnnScriptManager.cpp.

◆ AnnBehaviorScript() [2/2]

AnnBehaviorScript::AnnBehaviorScript ( const std::string name,
std::function< void(chaiscript::Boxed_Value &)>  updateHook,
AnnBehaviorScriptHooks  hooks,
chaiscript::Boxed_Value  scriptObjectInstance 
)

Callable script constructor.

Definition at line 580 of file AnnScriptManager.cpp.

◆ ~AnnBehaviorScript()

AnnBehaviorScript::~AnnBehaviorScript ( )
virtual

Script destructor.

Definition at line 608 of file AnnScriptManager.cpp.

Member Function Documentation

◆ callUpdateOnScript()

void Annwvyn::AnnBehaviorScript::callUpdateOnScript ( )
inlineprivate

Just call the update on the instance.

Definition at line 116 of file AnnScriptManager.hpp.

Here is the caller graph for this function:

◆ CollisionEvent()

void AnnBehaviorScript::CollisionEvent ( AnnCollisionEvent  e)
override

Event from the collision between 2 game objects.

Definition at line 747 of file AnnScriptManager.cpp.

◆ ControllerEvent()

void AnnBehaviorScript::ControllerEvent ( AnnControllerEvent  e)
override

Event for a Joystick.

Definition at line 679 of file AnnScriptManager.cpp.

◆ HandControllerEvent()

void AnnBehaviorScript::HandControllerEvent ( AnnHandControllerEvent  e)
override

Event from an HandController.

Definition at line 730 of file AnnScriptManager.cpp.

◆ isValid()

bool AnnBehaviorScript::isValid ( ) const

Return true if the script is valid. If the object is in a state where this returns false, calling "update" on it will crash.

Definition at line 629 of file AnnScriptManager.cpp.

◆ KeyEvent()

void AnnBehaviorScript::KeyEvent ( AnnKeyEvent  e)
override

Event from the keyboard.

Definition at line 645 of file AnnScriptManager.cpp.

◆ MouseEvent()

void AnnBehaviorScript::MouseEvent ( AnnMouseEvent  e)
override

Event from the mouse.

Definition at line 662 of file AnnScriptManager.cpp.

◆ PlayerCollisionEvent()

void AnnBehaviorScript::PlayerCollisionEvent ( AnnPlayerCollisionEvent  e)
override

Event from the collision between the player and a game object.

Definition at line 763 of file AnnScriptManager.cpp.

◆ registerAsListener()

void AnnBehaviorScript::registerAsListener ( )

register this object as an event listener

Definition at line 634 of file AnnScriptManager.cpp.

Here is the call graph for this function:

◆ TimeEvent()

void AnnBehaviorScript::TimeEvent ( AnnTimeEvent  e)
override

Event from a timer.

Definition at line 696 of file AnnScriptManager.cpp.

◆ TriggerEvent()

void AnnBehaviorScript::TriggerEvent ( AnnTriggerEvent  e)
override

Event from a trigger.

Definition at line 713 of file AnnScriptManager.cpp.

◆ unregisterAsListener()

void AnnBehaviorScript::unregisterAsListener ( )

unregister this object as an event listener

Definition at line 639 of file AnnScriptManager.cpp.

Here is the call graph for this function:

◆ update()

void AnnBehaviorScript::update ( )

Call this to call the "update" of the script.

Definition at line 613 of file AnnScriptManager.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ callCollisionEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnCollisionEvent)> Annwvyn::AnnBehaviorScript::callCollisionEventOnScriptInstance
private

Hook for Collision event.

Definition at line 108 of file AnnScriptManager.hpp.

◆ callHandControllertOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnHandControllerEvent)> Annwvyn::AnnBehaviorScript::callHandControllertOnScriptInstance
private

Hook for Hand Controller event.

Definition at line 106 of file AnnScriptManager.hpp.

◆ callKeyEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnKeyEvent)> Annwvyn::AnnBehaviorScript::callKeyEventOnScriptInstance
private

Hook for key event.

Definition at line 96 of file AnnScriptManager.hpp.

◆ callMouseEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnMouseEvent)> Annwvyn::AnnBehaviorScript::callMouseEventOnScriptInstance
private

Hook for Mouse event.

Definition at line 98 of file AnnScriptManager.hpp.

◆ callPlayerCollisionEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnPlayerCollisionEvent)> Annwvyn::AnnBehaviorScript::callPlayerCollisionEventOnScriptInstance
private

Hook for PlayerCollision event.

Definition at line 110 of file AnnScriptManager.hpp.

◆ callStickEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnControllerEvent)> Annwvyn::AnnBehaviorScript::callStickEventOnScriptInstance
private

Hook for Stick event.

Definition at line 100 of file AnnScriptManager.hpp.

◆ callTimeEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnTimeEvent)> Annwvyn::AnnBehaviorScript::callTimeEventOnScriptInstance
private

Hook for Time event.

Definition at line 102 of file AnnScriptManager.hpp.

◆ callTriggerEventOnScriptInstance

std::function<void(chaiscript::Boxed_Value&, AnnTriggerEvent)> Annwvyn::AnnBehaviorScript::callTriggerEventOnScriptInstance
private

Hook for Trigger event.

Definition at line 104 of file AnnScriptManager.hpp.

◆ callUpdateOnScriptInstance

std::function<void(chaiscript::Boxed_Value&)> Annwvyn::AnnBehaviorScript::callUpdateOnScriptInstance
private

The "update" function. ChaiScript "object.update()" is like calling "update(object)".

Definition at line 94 of file AnnScriptManager.hpp.

◆ cannotCollision

bool Annwvyn::AnnBehaviorScript::cannotCollision
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotHand

bool Annwvyn::AnnBehaviorScript::cannotHand
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotKey

bool Annwvyn::AnnBehaviorScript::cannotKey
private

Call guards for the hooks above.

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotMouse

bool Annwvyn::AnnBehaviorScript::cannotMouse
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotPlayerCollision

bool Annwvyn::AnnBehaviorScript::cannotPlayerCollision
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotStick

bool Annwvyn::AnnBehaviorScript::cannotStick
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotTime

bool Annwvyn::AnnBehaviorScript::cannotTime
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ cannotTrigger

bool Annwvyn::AnnBehaviorScript::cannotTrigger
private

Definition at line 113 of file AnnScriptManager.hpp.

◆ name

std::string Annwvyn::AnnBehaviorScript::name
private

Name of this script. Name of the "class" defined in the script.

Definition at line 88 of file AnnScriptManager.hpp.

◆ ScriptObjectInstance

chaiscript::Boxed_Value Annwvyn::AnnBehaviorScript::ScriptObjectInstance
private

The ChaiScript object that is an instance of "name" class. BlackBox to find what "update" to call on the script engine.

Definition at line 91 of file AnnScriptManager.hpp.

◆ valid

const bool Annwvyn::AnnBehaviorScript::valid
private

Validity state of this object. Cannot change.

Definition at line 85 of file AnnScriptManager.hpp.


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