Jagguar Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
HealthComponent Class Reference

#include <HealthComponent.h>

Inheritance diagram for HealthComponent:
Inheritance graph
[legend]
Collaboration diagram for HealthComponent:
Collaboration graph
[legend]

Public Member Functions

 HealthComponent (int totalHealth)
 
 ~HealthComponent ()
 
void Update (SDL_Event r, int frame, std::vector< std::string > broadcastList) override
 
void Render (SDL_Renderer *ren) override
 
void ShowComponentEditor (bool *showEditor) override
 
void SetHealth (int newHealth)
 
void UpdateHealth (int changeInHealth)
 
const char * ComponentTypeName () override
 
- Public Member Functions inherited from Component
 Component ()
 
 ~Component ()
 
virtual void Update (SDL_Event e, int frame, std::vector< std::string > broadcastList)
 
virtual void Render (SDL_Renderer *ren)
 
virtual void ShowComponentEditor (bool *showEditor)
 
virtual bool HasTag (ComponentTag t)
 
virtual const char * ComponentTypeName ()
 
void ParseAndUpdateBroadcast (std::vector< std::string > broadcastList)
 

Private Attributes

int m_totalHealth
 
int m_currentHealth
 

Additional Inherited Members

- Protected Attributes inherited from Component
std::vector< ComponentTag > tags
 
std::vector< std::string > previousBroadcasts
 
std::vector< std::string > pendingBroadcasts
 

Detailed Description

A Component implementation to record health for a GameObject.

Constructor & Destructor Documentation

◆ HealthComponent()

HealthComponent::HealthComponent ( int  totalHealth)

Construct a new Health Component object

Parameters
totalHealththe maximum the GameObject's health can be

◆ ~HealthComponent()

HealthComponent::~HealthComponent ( )

Destroy the Health Component object

Member Function Documentation

◆ ComponentTypeName()

const char * HealthComponent::ComponentTypeName ( )
inlineoverridevirtual

The name of the component type. Used by the GUI

See also
GameMakerGUI::CreateComponent()
Returns
the name of the component

Reimplemented from Component.

◆ Render()

void HealthComponent::Render ( SDL_Renderer *  ren)
overridevirtual

Renders the component (if it has anything to render)

Parameters
renthe SDL renderer to be displayed upon
See also
IGraphicsEngineRenderer

Reimplemented from Component.

◆ SetHealth()

void HealthComponent::SetHealth ( int  newHealth)

Set the current health.

Parameters
newHealththe new health value

◆ ShowComponentEditor()

void HealthComponent::ShowComponentEditor ( bool *  showEditor)
overridevirtual

Using Imgui, render an editor for this component

See also
GameMakerGUI::RenderEditor()
Parameters
showEditor

Reimplemented from Component.

◆ Update()

void HealthComponent::Update ( SDL_Event  e,
int  frame,
std::vector< std::string >  broadcastList 
)
overridevirtual

Updates the state of the component object. Called by the Engine every tick

Parameters
eany inputs given by the user
framewhat frame is the game currently displaying
broadcastLista list to be used to send messages between components
See also
ParseAndUpdateBroadcast()

Reimplemented from Component.

Here is the call graph for this function:

◆ UpdateHealth()

void HealthComponent::UpdateHealth ( int  changeInHealth)

Modify the health by the given value.

Parameters
changeInHealtha modifier to the health value. Set it to a positive value for healing and a negative value for damaging

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