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 TurtleBrains::Express::Behaviors::TweeningBehavior< tbMath::Vector2 > TurtleBrains::Express::Behaviors::TweeningBehavior< float > TurtleBrains::Express::Behaviors::DelayBehavior TurtleBrains::Express::Behaviors::FadeColorBehavior TurtleBrains::Express::Behaviors::FlickerForBehavior TurtleBrains::Express::Behaviors::KillBehavior TurtleBrains::Express::Behaviors::PlayAnimationBehavior TurtleBrains::Express::Behaviors::PlaySoundBehavior TurtleBrains::Express::Behaviors::RotateBehavior TurtleBrains::Express::Behaviors::RotateForBehavior TurtleBrains::Express::Behaviors::RotateToBehavior TurtleBrains::Express::Behaviors::ScaleToBehavior TurtleBrains::Express::Behaviors::ShakeEntityBehavior TurtleBrains::Express::Behaviors::ShakeScreenBehavior TurtleBrains::Express::Behaviors::TranslateBehavior TurtleBrains::Express::Behaviors::TranslateForBehavior TurtleBrains::Express::Behaviors::TranslateToBehavior TurtleBrains::Express::Behaviors::TweeningBehavior< Type >

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

◆ EntityBehaviorInterface()

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

Constructs an entity behavior.

◆ ~EntityBehaviorInterface()

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

◆ OnAdd()

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.

◆ OnCollide()

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.

◆ OnPause()

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.

Reimplemented in TurtleBrains::Express::Behaviors::ShakeEntityBehavior.

◆ OnRemove()

◆ OnRender()

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.

◆ OnResume()

◆ OnSimulate()

◆ OnUpdate()

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

◆ mEntity

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.