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:
[legend]
Collaboration diagram for HealthComponent:
[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

  totalHealth | the maximum the GameObject's health can be

## ◆ ~HealthComponent()

HealthComponent::~HealthComponent | ( |  | ) |

Destroy the Health Component object

## Member Function Documentation

## ◆ ComponentTypeName()

const char * HealthComponent::ComponentTypeName | ( |  | ) |
| inline override virtual

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 | ) |
| override virtual

Renders the component (if it has anything to render)

Parameters

  ren | the SDL renderer to be displayed upon

See also
  IGraphicsEngineRenderer

Reimplemented from Component.

## ◆ SetHealth()

void HealthComponent::SetHealth | ( | int | newHealth | ) |

Set the current health.

Parameters

  newHealth | the new health value

## ◆ ShowComponentEditor()

void HealthComponent::ShowComponentEditor | ( | bool * | showEditor | ) |
| override virtual

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
| ) |  |
| override virtual

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

Parameters

  e | any inputs given by the user
  frame | what frame is the game currently displaying
  broadcastList | a 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

  changeInHealth | a 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:

- include/HealthComponent.h
- src/HealthComponent.cpp