TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Game::EntityBehaviorInterface Class Referenceabstract

#include <tb_entity_behavior_interface.hpp>

Inheritance diagram for TurtleBrains::Game::EntityBehaviorInterface:
TurtleBrains::Core::Noncopyable TurtleBrainsExpress::Behaviors::DelayBehavior TurtleBrainsExpress::Behaviors::FadeColorBehavior TurtleBrainsExpress::Behaviors::FlickerForBehavior TurtleBrainsExpress::Behaviors::KillBehavior TurtleBrainsExpress::Behaviors::PlayAnimationBehavior TurtleBrainsExpress::Behaviors::PlaySoundBehavior TurtleBrainsExpress::Behaviors::RotateBehavior TurtleBrainsExpress::Behaviors::RotateForBehavior TurtleBrainsExpress::Behaviors::RotateToBehavior TurtleBrainsExpress::Behaviors::ScaleToBehavior TurtleBrainsExpress::Behaviors::ShakeScreenBehavior TurtleBrainsExpress::Behaviors::TranslateBehavior TurtleBrainsExpress::Behaviors::TranslateForBehavior TurtleBrainsExpress::Behaviors::TranslateToBehavior TurtleBrainsExpress::Behaviors::TweeningBehavior< Type > TurtleBrainsExpress::Behaviors::TweeningBehavior< float > TurtleBrainsExpress::Behaviors::TweeningBehavior< tbMath::Vector2 >

Public Member Functions

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

Protected Member Functions

virtual void OnAdd (void)
 
virtual void OnRemove (void)
 
virtual void OnPause (void)
 
virtual void OnResume (void)
 
virtual void OnSimulate (void)
 
virtual void OnUpdate (const float deltaTime)
 
virtual void OnRender (void) const
 
virtual void OnCollide (const Entity &withOther)
 

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::OnAdd ( 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::OnCollide ( const Entity withOther)
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::OnPause ( 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::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
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.