Vigilante Game Framework  1.0.0.8
A 2D/3D C++ Game Framework using SFML.
Public Types | Public Member Functions | Protected Attributes | List of all members
VGroup Class Reference

An object management class that stores a set of objects to be updated and rendered in a batch. More...

#include <VGroup.h>

Inheritance diagram for VGroup:
VBase V3DBatchModelGroup VEmitter VPhysicsGroup VRenderGroup VRenderLayer VState VSubState V3DScene VTrailArea

Public Types

typedef VBase VSUPERCLASS
 Used to call parent class functions when they are overrided in class.
 

Public Member Functions

 VGroup (unsigned int maxSize=0)
 
int Length ()
 
VBaseAdd (VBase *object)
 
VBaseRemove (VBase *object, bool splice=false)
 
VBaseFirstAvailable ()
 
int FirstNULL ()
 
VBaseFirstExisting ()
 
VBaseFirstAlive ()
 
VBaseFirstDead ()
 
int CountAlive (bool Recursive=false)
 
int CountDead (bool Recursive=false)
 
VBaseGetRandom (int min=0, int max=0)
 
void ForEach (std::function< void(VBase *)> function, bool recursive=false)
 
void ForEachAlive (std::function< void(VBase *)> function, bool recursive=false)
 
void ForEachDead (std::function< void(VBase *)> function, bool recursive=false)
 
void ForEachExists (std::function< void(VBase *)> function, bool recursive=false)
 
VBaseGetGroupItem (int index)
 
template<class T >
T * GetGroupItemAsType (int index)
 
int GetIndexOfItem (VBase *object)
 
void OrganiseNULLS ()
 Sort nullptr members to the bottom of the group.
 
void Swap (int a, int b)
 
void Sort (std::function< bool(VBase *, VBase *)> func)
 
void Reverse ()
 Reverse order of group.
 
void Clear ()
 Clears the whole group (does not destroy any of the members, that must be done using the Destroy method).
 
virtual void Destroy () override
 Removes and/or destroys all objects inside the group before destroying extra data. (If an object is referenced in another VGroup, the object won't be destroyed)
 
virtual void Kill () override
 Kills all living objects before killing the group itself.
 
virtual void Revive () override
 Revives all dead objects before reviving the group itself.
 
virtual void Update (float dt) override
 
virtual void Draw (sf::RenderTarget &RenderTarget) override
 

Protected Attributes

std::vector< VBase * > members
 VBase List.
 
int length = 0
 Current amount of members in the list.
 
unsigned int MaxSize = 0
 Maximum Size of the list, used if VGroup is set to have a fixed size.
 

Additional Inherited Members

- Static Public Member Functions inherited from VBase
static const wchar_t * VString (const char *fmt,...)
 
static void VLog (const char *fmt,...)
 
static void VLogError (const char *fmt,...)
 
static void VClearLog ()
 
- Public Attributes inherited from VBase
bool active = true
 Base can be updated using Update if true.
 
bool visible = true
 Base can be rendered using Draw if true.
 
bool alive = true
 Helper member that is mainly used filter out behaviours to objects which aren't alive in the scene.
 
bool exists = true
 Base can be updated and rendered if true, else it would no longer be treated as being part of the scene.
 
VType type = NONE
 Base object type, typically set in the constructor of an inherited object to specify what type it is.
 
uint32_t RefCount = 0
 Counts the amount of times the object is referenced in groups, ensures an object is only destroyed when no longer part of a single group.
 

Detailed Description

An object management class that stores a set of objects to be updated and rendered in a batch.

Constructor & Destructor Documentation

◆ VGroup()

VGroup::VGroup ( unsigned int  maxSize = 0)
inline
Parameters
maxSizeThe fixed length of the group. If 0, then the VGroup has no limit in size.

Member Function Documentation

◆ Add()

VBase* VGroup::Add ( VBase object)
Parameters
objectThe VBase object to add to the group.

◆ CountAlive()

int VGroup::CountAlive ( bool  Recursive = false)
Returns
Amount of alive objects.

◆ CountDead()

int VGroup::CountDead ( bool  Recursive = false)
Returns
Amount of dead objects.

◆ Draw()

virtual void VGroup::Draw ( sf::RenderTarget &  RenderTarget)
overridevirtual

Renders all alive and visible objects in the group.

Parameters
RenderTargetThe game's sf::RenderTarget object to render data onto.

Reimplemented from VBase.

Reimplemented in VEmitter, VSubState, VRenderGroup, V3DScene, VRenderLayer, VTrailArea, and V3DBatchModelGroup.

◆ FirstAlive()

VBase* VGroup::FirstAlive ( )
Returns
First object that is alive.

◆ FirstAvailable()

VBase* VGroup::FirstAvailable ( )
Returns
First object regardless of state.

◆ FirstDead()

VBase* VGroup::FirstDead ( )
Returns
First object that is dead.

◆ FirstExisting()

VBase* VGroup::FirstExisting ( )
Returns
First object that exists in scene.

◆ FirstNULL()

int VGroup::FirstNULL ( )
Returns
First index that is set to nullptr.

◆ ForEach()

void VGroup::ForEach ( std::function< void(VBase *)>  function,
bool  recursive = false 
)

Applies function for each object in group.

◆ ForEachAlive()

void VGroup::ForEachAlive ( std::function< void(VBase *)>  function,
bool  recursive = false 
)

Applies function for each object in group that's alive.

◆ ForEachDead()

void VGroup::ForEachDead ( std::function< void(VBase *)>  function,
bool  recursive = false 
)

Applies function for each object in group that's dead.

◆ ForEachExists()

void VGroup::ForEachExists ( std::function< void(VBase *)>  function,
bool  recursive = false 
)

Applies function for each object in group that exists.

◆ GetGroupItem()

VBase* VGroup::GetGroupItem ( int  index)

Gets an object from a specified index in group.

◆ GetGroupItemAsType()

template<class T >
T* VGroup::GetGroupItemAsType ( int  index)
inline

Gets an object from a specified index in group.

◆ GetIndexOfItem()

int VGroup::GetIndexOfItem ( VBase object)

Gets the index of a specific object.

◆ GetRandom()

VBase* VGroup::GetRandom ( int  min = 0,
int  max = 0 
)
Returns
Random object from a set range. Min and Max will be clamped to 0 and maxSize.

◆ Length()

int VGroup::Length ( )
Returns
The current size of the group based on amount of active elements.

◆ Remove()

VBase* VGroup::Remove ( VBase object,
bool  splice = false 
)
Parameters
objectThe VBase object to remove from the group (does not destroy any of the members, that must be done using the Destroy method).
spliceIf true, all elements above the object will be moved down, else the element will become null.

◆ Sort()

void VGroup::Sort ( std::function< bool(VBase *, VBase *)>  func)

Sorts objects based on function.

◆ Swap()

void VGroup::Swap ( int  a,
int  b 
)

Swaps order of two groups.

◆ Update()

virtual void VGroup::Update ( float  dt)
overridevirtual

Updates all alive and active objects in the group.

Parameters
dtDelta Time between the previous and current frame.

Reimplemented from VBase.

Reimplemented in VEmitter, VSubState, VRenderGroup, VPhysicsGroup, V3DScene, VState, and VRenderLayer.


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