FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::TriggerController Class Reference

This class serves as a central place to manage triggers for a Map. More...

#include <triggercontroller.h>

+ Inheritance diagram for FIFE::TriggerController:
+ Collaboration diagram for FIFE::TriggerController:

Public Member Functions

 TriggerController (Map *map)
 Constructor. More...
 
virtual ~TriggerController ()
 Destructor. More...
 
TriggercreateTrigger (const std::string &triggerName)
 Creates a trigger. More...
 
TriggercreateTriggerOnCoordinate (const std::string &triggerName, Layer *layer, const ModelCoordinate &pt)
 Creates and adds a trigger to the cell on the specified layer and coordinate. More...
 
TriggercreateTriggerOnCoordinates (const std::string &triggerName, Layer *layer, const std::vector< ModelCoordinate > &coords)
 Creates and adds a trigger to the cells on the specified layer and coordinates. More...
 
TriggercreateTriggerOnRect (const std::string &triggerName, Layer *layer, const Rect &rec)
 Creates and adds a trigger to the cells on the specified layer and rect. More...
 
TriggercreateTriggerOnLocation (const std::string &triggerName, const Location &loc)
 Creates and adds a trigger to the cell on the specified location. More...
 
TriggercreateTriggerOnLocations (const std::string &triggerName, const std::vector< Location > &locs)
 Creates and adds a trigger to the cell on the specified locations. More...
 
TriggercreateTriggerOnCell (const std::string &triggerName, Cell *cell)
 Creates and adds a trigger to the specified cell. More...
 
TriggercreateTriggerOnCells (const std::string &triggerName, const std::vector< Cell *> &cells)
 Creates and adds a trigger to the specified cells. More...
 
TriggercreateTriggerOnInstance (const std::string &triggerName, Instance *instance)
 Creates and attach a trigger to the specified instance. More...
 
TriggergetTrigger (const std::string &triggerName)
 Returns a pointer to the trigger with the given name. More...
 
void deleteTrigger (const std::string &triggerName)
 Deletes a trigger with the given name. More...
 
void removeTriggerFromCoordinate (const std::string &triggerName, Layer *layer, const ModelCoordinate &pt)
 Removes a trigger from the cell on the specified layer and coordinate. More...
 
void removeTriggerFromCoordinates (const std::string &triggerName, Layer *layer, const std::vector< ModelCoordinate > &coords)
 Removes a trigger from the cell on the specified layer and coordinates. More...
 
void removeTriggerFromRect (const std::string &triggerName, Layer *layer, const Rect &rec)
 Removes a trigger from the cell on the specified layer and coordinates. More...
 
void removeTriggerFromLocation (const std::string &triggerName, const Location &loc)
 Removes a trigger from the cell on the specified location. More...
 
void removeTriggerFromLocations (const std::string &triggerName, const std::vector< Location > &locs)
 Removes a trigger from the cell on the specified locations. More...
 
void removeTriggerFromCell (const std::string &triggerName, Cell *cell)
 Removes a trigger from the specified cell. More...
 
void removeTriggerFromCells (const std::string &triggerName, const std::vector< Cell *> &cells)
 Removes a trigger from the specified cells. More...
 
void removeTriggerFromInstance (const std::string &triggerName, Instance *instance)
 Detach a trigger from the specified instance. More...
 
std::vector< Trigger * > getAllTriggers ()
 Returns a vector with all trigger pointers. More...
 
std::vector< std::string > getAllTriggerNames ()
 Returns a vector with all trigger names. More...
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 

Private Types

typedef std::map< std::string, Trigger *> TriggerNameMap
 
typedef std::map< std::string, Trigger *>::iterator TriggerNameMapIterator
 
typedef std::map< std::string, Trigger *>::const_iterator TriggerNameMapConstIterator
 
typedef std::pair< std::string, Trigger *> TriggerNameMapPair
 

Private Member Functions

bool exists (const std::string &name)
 Checks to see if the trigger name already exists. More...
 

Private Attributes

Mapm_map
 Pointer to the map this controller is associated with. More...
 
TriggerNameMap m_triggerNameMap
 Trigger name map. More...
 

Detailed Description

This class serves as a central place to manage triggers for a Map.

You should never instantiate this class directly as Map does it when you create a new map.

Definition at line 53 of file triggercontroller.h.

Member Typedef Documentation

◆ TriggerNameMap

typedef std::map< std::string, Trigger* > FIFE::TriggerController::TriggerNameMap
private

Definition at line 223 of file triggercontroller.h.

◆ TriggerNameMapConstIterator

typedef std::map< std::string, Trigger* >::const_iterator FIFE::TriggerController::TriggerNameMapConstIterator
private

Definition at line 225 of file triggercontroller.h.

◆ TriggerNameMapIterator

typedef std::map< std::string, Trigger* >::iterator FIFE::TriggerController::TriggerNameMapIterator
private

Definition at line 224 of file triggercontroller.h.

◆ TriggerNameMapPair

typedef std::pair< std::string, Trigger* > FIFE::TriggerController::TriggerNameMapPair
private

Definition at line 226 of file triggercontroller.h.

Constructor & Destructor Documentation

◆ TriggerController()

FIFE::TriggerController::TriggerController ( Map map)

Constructor.

Parameters
mapA pointer to the map that the controller will interact with.

Definition at line 43 of file triggercontroller.cpp.

◆ ~TriggerController()

FIFE::TriggerController::~TriggerController ( )
virtual

Destructor.

Definition at line 47 of file triggercontroller.cpp.

References m_triggerNameMap.

Member Function Documentation

◆ createTrigger()

Trigger * FIFE::TriggerController::createTrigger ( const std::string &  triggerName)

Creates a trigger.

Parameters
triggerNameThe name of the trigger. This must be unique per map.

Definition at line 54 of file triggercontroller.cpp.

References FIFE::_log, FL_WARN, and m_triggerNameMap.

Referenced by createTriggerOnCell(), createTriggerOnCells(), createTriggerOnCoordinate(), createTriggerOnCoordinates(), createTriggerOnInstance(), createTriggerOnLocation(), createTriggerOnLocations(), createTriggerOnRect(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ createTriggerOnCell()

Trigger * FIFE::TriggerController::createTriggerOnCell ( const std::string &  triggerName,
Cell cell 
)

Creates and adds a trigger to the specified cell.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
cellThe Cell where the Trigger should be added.

Definition at line 117 of file triggercontroller.cpp.

References FIFE::Trigger::assign(), and createTrigger().

◆ createTriggerOnCells()

Trigger * FIFE::TriggerController::createTriggerOnCells ( const std::string &  triggerName,
const std::vector< Cell *> &  cells 
)

Creates and adds a trigger to the specified cells.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
cellsVector with Cell pointers where the Trigger should be added.

Definition at line 125 of file triggercontroller.cpp.

References FIFE::Trigger::assign(), and createTrigger().

◆ createTriggerOnCoordinate()

Trigger * FIFE::TriggerController::createTriggerOnCoordinate ( const std::string &  triggerName,
Layer layer,
const ModelCoordinate pt 
)

Creates and adds a trigger to the cell on the specified layer and coordinate.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to add the Trigger to
ptThe ModelCoordinate where the Trigger should be added.

Definition at line 70 of file triggercontroller.cpp.

References FIFE::Trigger::assign(), and createTrigger().

◆ createTriggerOnCoordinates()

Trigger * FIFE::TriggerController::createTriggerOnCoordinates ( const std::string &  triggerName,
Layer layer,
const std::vector< ModelCoordinate > &  coords 
)

Creates and adds a trigger to the cells on the specified layer and coordinates.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to add the Trigger to
coordsVector with ModelCoordinates where the Trigger should be added.

Definition at line 78 of file triggercontroller.cpp.

References FIFE::Trigger::assign(), and createTrigger().

◆ createTriggerOnInstance()

Trigger * FIFE::TriggerController::createTriggerOnInstance ( const std::string &  triggerName,
Instance instance 
)

Creates and attach a trigger to the specified instance.

But not to the underlaying cell.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
instanceThe Instance where the Trigger is attached to.

Definition at line 133 of file triggercontroller.cpp.

References FIFE::Trigger::attach(), and createTrigger().

◆ createTriggerOnLocation()

Trigger * FIFE::TriggerController::createTriggerOnLocation ( const std::string &  triggerName,
const Location loc 
)

Creates and adds a trigger to the cell on the specified location.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
locThe Location where the Trigger should be added.

Definition at line 100 of file triggercontroller.cpp.

References createTrigger(), FIFE::Layer::getCellCache(), FIFE::Location::getLayer(), and FIFE::Location::getLayerCoordinates().

◆ createTriggerOnLocations()

Trigger * FIFE::TriggerController::createTriggerOnLocations ( const std::string &  triggerName,
const std::vector< Location > &  locs 
)

Creates and adds a trigger to the cell on the specified locations.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
locsVector with Locations where the Trigger should be added.

Definition at line 109 of file triggercontroller.cpp.

References FIFE::Trigger::assign(), and createTrigger().

◆ createTriggerOnRect()

Trigger * FIFE::TriggerController::createTriggerOnRect ( const std::string &  triggerName,
Layer layer,
const Rect rec 
)

Creates and adds a trigger to the cells on the specified layer and rect.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to add the Trigger to
reca Rect with ModelCoordinates where the Trigger should be added.

Definition at line 88 of file triggercontroller.cpp.

References createTrigger(), FIFE::Layer::getCellCache(), and FIFE::CellCache::getCellsInRect().

◆ deleteTrigger()

void FIFE::TriggerController::deleteTrigger ( const std::string &  triggerName)

Deletes a trigger with the given name.

Parameters
triggerNameThe name of the trigger. This must be unique per map.

Definition at line 149 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ exists()

bool FIFE::TriggerController::exists ( const std::string &  name)
private

Checks to see if the trigger name already exists.

Parameters
nameThe name of the trigger to check
Returns
true if the name already exists, false otherwise.

Definition at line 242 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ getAllTriggerNames()

std::vector< std::string > FIFE::TriggerController::getAllTriggerNames ( )

Returns a vector with all trigger names.

Definition at line 233 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ getAllTriggers()

std::vector< Trigger * > FIFE::TriggerController::getAllTriggers ( )

Returns a vector with all trigger pointers.

Definition at line 224 of file triggercontroller.cpp.

References m_triggerNameMap.

Referenced by FIFE::MapSaver::save().

+ Here is the caller graph for this function:

◆ getTrigger()

Trigger * FIFE::TriggerController::getTrigger ( const std::string &  triggerName)

Returns a pointer to the trigger with the given name.

Note: Returns Null if the trigger does not exists.

Parameters
triggerNameThe name of the trigger. This must be unique per map.

Definition at line 141 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromCell()

void FIFE::TriggerController::removeTriggerFromCell ( const std::string &  triggerName,
Cell cell 
)

Removes a trigger from the specified cell.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
cellThe Cell pointer where the Trigger should be removed.

Definition at line 199 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromCells()

void FIFE::TriggerController::removeTriggerFromCells ( const std::string &  triggerName,
const std::vector< Cell *> &  cells 
)

Removes a trigger from the specified cells.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
cellsVector with Cell pointers where the Trigger should be removed.

Definition at line 206 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromCoordinate()

void FIFE::TriggerController::removeTriggerFromCoordinate ( const std::string &  triggerName,
Layer layer,
const ModelCoordinate pt 
)

Removes a trigger from the cell on the specified layer and coordinate.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to remove the Trigger from.
ptThe ModelCoordinate where the Trigger should be removed.

Definition at line 157 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromCoordinates()

void FIFE::TriggerController::removeTriggerFromCoordinates ( const std::string &  triggerName,
Layer layer,
const std::vector< ModelCoordinate > &  coords 
)

Removes a trigger from the cell on the specified layer and coordinates.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to remove the Trigger from.
coordsVector with ModelCoordinates where the Trigger should be removed.

Definition at line 164 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromInstance()

void FIFE::TriggerController::removeTriggerFromInstance ( const std::string &  triggerName,
Instance instance 
)

Detach a trigger from the specified instance.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
instanceThe instance pointer where the Trigger is detached from.

Definition at line 215 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromLocation()

void FIFE::TriggerController::removeTriggerFromLocation ( const std::string &  triggerName,
const Location loc 
)

Removes a trigger from the cell on the specified location.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
locLocation where the Trigger should be removed.

Definition at line 183 of file triggercontroller.cpp.

References FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), and m_triggerNameMap.

◆ removeTriggerFromLocations()

void FIFE::TriggerController::removeTriggerFromLocations ( const std::string &  triggerName,
const std::vector< Location > &  locs 
)

Removes a trigger from the cell on the specified locations.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
locsVector with Locations where the Trigger should be removed.

Definition at line 190 of file triggercontroller.cpp.

References m_triggerNameMap.

◆ removeTriggerFromRect()

void FIFE::TriggerController::removeTriggerFromRect ( const std::string &  triggerName,
Layer layer,
const Rect rec 
)

Removes a trigger from the cell on the specified layer and coordinates.

Parameters
triggerNameThe name of the trigger. This must be unique per map.
layerA pointer to the layer in which to remove the Trigger from.
recRect with ModelCoordinates where the Trigger should be removed.

Definition at line 173 of file triggercontroller.cpp.

References FIFE::Layer::getCellCache(), FIFE::CellCache::getCellsInRect(), and m_triggerNameMap.

Member Data Documentation

◆ m_map

Map* FIFE::TriggerController::m_map
private

Pointer to the map this controller is associated with.

Definition at line 221 of file triggercontroller.h.

◆ m_triggerNameMap


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