TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
TurtleBrains::Game::EntityBehaviorInterface Class Referenceabstract

#include <tb_entity_behavior_interface.h>

Inheritance diagram for TurtleBrains::Game::EntityBehaviorInterface:
TurtleBrains::Core::Noncopyable TurtleBrains::Game::DelayBehavior TurtleBrains::Game::KillBehavior TurtleBrains::Game::MoveBehavior TurtleBrains::Game::MoveToBehavior

Public Member Functions

 EntityBehaviorInterface (Entity &entity)
 
virtual ~EntityBehaviorInterface (void)=0
 

Protected Member Functions

virtual void OnAdded (void)
 
virtual void OnRemoved (void)
 
virtual void OnPaused (void)
 
virtual void OnResume (void)
 
virtual void OnSimulate (void)
 
virtual void OnUpdate (const float deltaTime)
 
virtual void OnRender (void) const
 
virtual void OnCollideWith (const Entity &other)
 

Protected Attributes

EntitymEntity
 

Friends

class Entity
 

Detailed Description

The EntityBehaviorInterface provides an interface to create small behavioral states for an Entity that can be reused and applied on the Entity's behavior stack.

Constructor & Destructor Documentation

TurtleBrains::Game::EntityBehaviorInterface::EntityBehaviorInterface ( Entity entity)
explicit

Constructs an entity behavior.

virtual TurtleBrains::Game::EntityBehaviorInterface::~EntityBehaviorInterface ( void  )
pure virtual

Destructs an entity behavior which currently (TurtleBrains v0.2.0) does not have any resources to clean up after.

Member Function Documentation

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnAdded ( void  )
protectedvirtual

This is invoked when the behavior is pushed onto the entities behavior stack, pausing the currently active behavior. This behavior is now the active behavior and will be paused if that changes.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnCollideWith ( const Entity other)
protectedvirtual

This is invoked when the Entity collides/intersects another entity and the behavior is at the top of the entities behavior stack.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnPaused ( void  )
protectedvirtual

This is invoked when the behavior is currently active and a new behavior gets pushed on becoming the new active behavior. OnResume() will be invoked once the behavior becomes active once again.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnRemoved ( void  )
protectedvirtual

This is invoked just as the behavior is being removed from the entity stack.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnRender ( void  ) const
protectedvirtual

This is invoked when the Entity is visible and rendered and when the behavior is at the top of the entities behavior stack. Called exactly once per frame.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnResume ( void  )
protectedvirtual

This is invoked when the behavior is currently paused and the active behavior gets popped off the stack letting this behavior become active again.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnSimulate ( void  )
protectedvirtual

This is invoked when the Entity is activated and simulated and when the behavior is at the top of the entities behavior stack. Called 0 to N times per frame.

Reimplemented in TurtleBrains::Game::MoveToBehavior, TurtleBrains::Game::MoveBehavior, TurtleBrains::Game::KillBehavior, and TurtleBrains::Game::DelayBehavior.

virtual void TurtleBrains::Game::EntityBehaviorInterface::OnUpdate ( const float  deltaTime)
protectedvirtual

This is invoked when the Entity is activated and updated and when the behavior is at the top of the entities behavior stack. Called exactly once per frame.

Member Data Documentation

Entity& TurtleBrains::Game::EntityBehaviorInterface::mEntity
protected

The Entity which the behavior should work magic on. Some behaviors may need a more specific Entity reference and that should be held and contained. For instance a behavior specific to a PlayerEntity would contain PlayerEntity& mPlayerEntity; and work the specific magic on the player.