#include <Team.h>
Collaboration diagram for ASR::Team:
Public Member Functions | |
Team (const String &name, const ColourValue &teamColor) | |
Constructor. | |
~Team () | |
Destructor. | |
const String & | getName () const |
Retrieve the name of this Team. | |
Unit * | createUnit (const UnitType &unitType) |
Create a new Unit for this Team. | |
Building * | createBuilding (const String &meshName, const Vector3 &position) |
Creates a new Building for this Team. | |
ControlGroup * | createControlGroup () |
void | destroyControlGroup (ControlGroup *group) |
void | setActiveControlGroup (ControlGroup *group) |
Changes the currently selected group to the specified group. | |
void | destroyActiveControlGroup () |
ControlGroup * | getActiveControlGroup () const |
TeamUnits::UnitIterator | getUnitIterator () const |
Get an iterator for a list that contains each Unit of this Team. | |
TeamUnits::UnitList | getAdjacentUnits (const Vector3 &worldPos, float radius) |
Get an iterator for a list that contains each Unit that is nearby. | |
FogOfWar * | getFogOfWar () const |
void | findTargets () |
Private Types | |
typedef vector< ControlGroup * > | ControlGroups |
Private Member Functions | |
void | _applyTeamColors (Unit *unit) |
Applies the colors of this Team to the specified Unit. | |
void | _applyTeamColors (Building *building) |
Applies the colors of this Team to the specified Building. | |
void | _destroyAllControlGroups () |
Private Attributes | |
TeamUnits * | mUnits |
TeamBuildings * | mBuildings |
FogOfWar * | mFogOfWar |
TeamUpdater * | mUpdater |
ControlGroups | mControlGroups |
ControlGroup * | mActiveGroup |
String | mName |
String | mBaseMaterialName |
String | mFeathersMaterialName |
String | mShoulderMaterialName |
Friends | |
class | TeamUpdater |
Definition at line 39 of file Team.h.
typedef vector<ControlGroup*> ASR::Team::ControlGroups [private] |
ASR::Team::Team | ( | const String & | name, | |
const ColourValue & | teamColor | |||
) |
Constructor.
name | The name of the team. | |
teamColor | The base color of the team which is applied to buildings and units |
Definition at line 38 of file Team.cpp.
References ASR::Game::addUpdater(), createControlGroup(), ASR::Game::getSingleton(), ASR::Level::getSingleton(), mActiveGroup, mBaseMaterialName, mBuildings, mControlGroups, mFeathersMaterialName, mFogOfWar, mShoulderMaterialName, mUnits, mUpdater, setActiveControlGroup(), ASR::TeamUnits::setSpatialGridSize(), and TeamUpdater.
00039 : mName ( name ) 00040 { 00041 mUnits = new TeamUnits ( this ); 00042 mBuildings = new TeamBuildings (); 00043 00044 mFogOfWar = new FogOfWar ( Level::getSingleton ().getNumNodesWide (), Level::getSingleton ().getNumNodesHigh () ); 00045 00046 mUpdater = new TeamUpdater ( this ); 00047 Game::getSingleton ().addUpdater ( mUpdater ); 00048 00049 mControlGroups.clear (); 00050 mActiveGroup = createControlGroup(); 00051 setActiveControlGroup ( mActiveGroup ); 00052 00053 mUnits->setSpatialGridSize ( 12, 12 ); 00054 00055 // HACK 00056 // Defining custom colors 00057 MaterialPtr baseMat = MaterialManager::getSingleton ().getByName ("LizardMan" ); 00058 MaterialPtr feathersMat = MaterialManager::getSingleton ().getByName ("LizardMan_Feathers" ); 00059 MaterialPtr shoulderMat = MaterialManager::getSingleton ().getByName ("Lizardman_Armor" ); 00060 00061 baseMat->load (); 00062 feathersMat->load (); 00063 shoulderMat->load (); 00064 00065 mFeathersMaterialName = feathersMat->getName() + "_team" + StringConverter::toString ( Level::getSingleton().getNumTeams() ); 00066 mBaseMaterialName = baseMat->getName() + "_team" + StringConverter::toString ( Level::getSingleton().getNumTeams() ); 00067 mShoulderMaterialName = shoulderMat->getName() + "_team" + StringConverter::toString ( Level::getSingleton().getNumTeams() ); 00068 00069 MaterialPtr teamFeathersMaterial = feathersMat->clone ( mFeathersMaterialName ); 00070 MaterialPtr teamBaseMaterial = baseMat->clone ( mBaseMaterialName ); 00071 MaterialPtr teamShoulderMaterial = shoulderMat->clone ( mShoulderMaterialName ); 00072 00073 teamBaseMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setColourOperationEx(LBX_BLEND_TEXTURE_ALPHA, LBS_TEXTURE, LBS_MANUAL, ColourValue::White, teamColor ); 00074 teamFeathersMaterial->getSupportedTechnique(0)->getPass(0)->getTextureUnitState(1)->setColourOperationEx(LBX_MODULATE, LBS_MANUAL, LBS_CURRENT, teamColor ); 00075 teamShoulderMaterial->getSupportedTechnique(0)->getPass(0)->getTextureUnitState(0)->setColourOperationEx(LBX_BLEND_TEXTURE_ALPHA, LBS_TEXTURE, LBS_MANUAL, ColourValue::White, teamColor ); 00076 }
ASR::Team::~Team | ( | ) |
Destructor.
Definition at line 80 of file Team.cpp.
References _destroyAllControlGroups(), mBuildings, mFogOfWar, mUnits, and mUpdater.
00081 { 00082 _destroyAllControlGroups (); 00083 delete mUnits; 00084 delete mBuildings; 00085 delete mUpdater; 00086 delete mFogOfWar; 00087 }
void ASR::Team::_applyTeamColors | ( | Building * | building | ) | [private] |
void ASR::Team::_applyTeamColors | ( | Unit * | unit | ) | [private] |
Applies the colors of this Team to the specified Unit.
Definition at line 197 of file Team.cpp.
References mBaseMaterialName, mFeathersMaterialName, and mShoulderMaterialName.
Referenced by createBuilding(), and createUnit().
00198 { 00199 unit->getEntity()->getSubEntity(1)->setMaterialName ( mFeathersMaterialName ); 00200 unit->getEntity()->getSubEntity (0)->setMaterialName ( mBaseMaterialName ); 00201 00202 00203 unit->mShield->setMaterialName ( mShoulderMaterialName ); 00204 unit->mShoulder->setMaterialName ( mShoulderMaterialName ); 00205 }
void ASR::Team::_destroyAllControlGroups | ( | ) | [private] |
Definition at line 155 of file Team.cpp.
References mControlGroups.
Referenced by ~Team().
00156 { 00157 ControlGroups::iterator iter = mControlGroups.begin (); 00158 while ( iter != mControlGroups.end () ) 00159 { 00160 delete (*iter); 00161 iter++; 00162 } 00163 00164 mControlGroups.clear (); 00165 }
Building * ASR::Team::createBuilding | ( | const String & | meshName, | |
const Vector3 & | position | |||
) |
Creates a new Building for this Team.
meshName | The name of the mesh that represents this building | |
position | The location on the map where the building is located |
Definition at line 107 of file Team.cpp.
References _applyTeamColors(), ASR::TeamBuildings::createBuilding(), and mBuildings.
Referenced by TutorialApplication::_createTeamA().
00108 { 00109 Building* newBuilding = mBuildings->createBuilding( meshName, position ); 00110 _applyTeamColors ( newBuilding ); 00111 return newBuilding; 00112 }
ControlGroup * ASR::Team::createControlGroup | ( | ) |
Definition at line 131 of file Team.cpp.
References mControlGroups.
Referenced by ASR::UnitSelecter::_createActiveGroup(), ASR::UnitSelecter::_unselectDeadUnits(), and Team().
00132 { 00133 // TODO 00134 // Make sure that when removing the last unit from a control group, it 00135 // is deleted 00136 ControlGroup* group = new ControlGroup (); 00137 mControlGroups.push_back ( group ); 00138 return group; 00139 }
Create a new Unit for this Team.
unitType | The type of unit to create |
Definition at line 98 of file Team.cpp.
References _applyTeamColors(), ASR::TeamUnits::createUnit(), ASR::UnitType::getMeshName(), and mUnits.
Referenced by TutorialApplication::_createTeamA(), TutorialApplication::_createTeamB(), and TutorialApplication::_createTeamC().
00099 { 00100 Unit* newUnit = mUnits->createUnit( type.getMeshName() ); 00101 _applyTeamColors ( newUnit ); 00102 return newUnit; 00103 }
void ASR::Team::destroyActiveControlGroup | ( | ) |
Definition at line 190 of file Team.cpp.
References destroyControlGroup(), and mActiveGroup.
Referenced by ASR::UnitSelecter::_createActiveGroup(), and ASR::UnitSelecter::_unselectDeadUnits().
00191 { 00192 destroyControlGroup ( mActiveGroup ); 00193 }
void ASR::Team::destroyControlGroup | ( | ControlGroup * | group | ) |
Definition at line 143 of file Team.cpp.
References mControlGroups.
Referenced by destroyActiveControlGroup().
00144 { 00145 ControlGroups::iterator iter = find ( mControlGroups.begin(), mControlGroups.end(), group ); 00146 if ( iter == mControlGroups.end() ) 00147 throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Control group not found", "Team::destroyControlGroup" ); 00148 00149 delete (*iter); 00150 mControlGroups.erase ( iter ); 00151 }
void ASR::Team::findTargets | ( | ) |
Definition at line 116 of file Team.cpp.
References ASR::Level::getAdjacentUnits(), ASR::Level::getSingleton(), ASR::TeamUnits::getUnitIterator(), and mUnits.
00117 { 00118 Level& lev = Level::getSingleton(); 00119 00120 TeamUnits::UnitIterator iter = mUnits->getUnitIterator(); 00121 while ( iter.hasMoreElements() ) 00122 { 00123 Unit* unit = iter.getNext(); 00124 00125 lev.getAdjacentUnits ( unit->getPosition(), unit->getSightRadius () ); 00126 } 00127 }
ControlGroup * ASR::Team::getActiveControlGroup | ( | ) | const |
Definition at line 183 of file Team.cpp.
References mActiveGroup.
Referenced by ASR::UnitSelecter::_moveUnits(), ASR::UnitSelecter::_unselectCurrect(), and ASR::UnitSelecter::_unselectDeadUnits().
00184 { 00185 return mActiveGroup; 00186 }
TeamUnits::UnitList ASR::Team::getAdjacentUnits | ( | const Vector3 & | worldPos, | |
float | radius | |||
) |
Get an iterator for a list that contains each Unit that is nearby.
worldPos | The position in world coordinates to start the search. | |
radius | How far is the maximum distance to consider. |
Definition at line 217 of file Team.cpp.
References ASR::TeamUnits::getAdjacentUnits(), and mUnits.
00218 { 00219 return mUnits->getAdjacentUnits ( worldPos, radius ); 00220 }
FogOfWar * ASR::Team::getFogOfWar | ( | ) | const |
Definition at line 224 of file Team.cpp.
References mFogOfWar.
Referenced by ASR::ClientUpdater::_findVisibleObjects().
00225 { 00226 return mFogOfWar; 00227 }
const String & ASR::Team::getName | ( | ) | const |
TeamUnits::UnitIterator ASR::Team::getUnitIterator | ( | ) | const |
Get an iterator for a list that contains each Unit of this Team.
Definition at line 169 of file Team.cpp.
References ASR::TeamUnits::getUnitIterator(), and mUnits.
Referenced by ASR::UnitSelecter::_selectUnits(), and ASR::TeamUpdater::updateBeforeFrame().
00170 { 00171 return mUnits->getUnitIterator (); 00172 }
void ASR::Team::setActiveControlGroup | ( | ControlGroup * | group | ) |
Changes the currently selected group to the specified group.
Definition at line 176 of file Team.cpp.
References mActiveGroup.
Referenced by ASR::UnitSelecter::_createActiveGroup(), ASR::UnitSelecter::_unselectDeadUnits(), and Team().
00177 { 00178 mActiveGroup = group; 00179 }
friend class TeamUpdater [friend] |
ControlGroup* ASR::Team::mActiveGroup [private] |
Definition at line 54 of file Team.h.
Referenced by destroyActiveControlGroup(), getActiveControlGroup(), setActiveControlGroup(), and Team().
String ASR::Team::mBaseMaterialName [private] |
TeamBuildings* ASR::Team::mBuildings [private] |
ControlGroups ASR::Team::mControlGroups [private] |
Definition at line 53 of file Team.h.
Referenced by _destroyAllControlGroups(), createControlGroup(), destroyControlGroup(), and Team().
String ASR::Team::mFeathersMaterialName [private] |
FogOfWar* ASR::Team::mFogOfWar [private] |
Definition at line 48 of file Team.h.
Referenced by getFogOfWar(), Team(), ASR::TeamUpdater::updateBeforeFrame(), and ~Team().
String ASR::Team::mName [private] |
String ASR::Team::mShoulderMaterialName [private] |
TeamUnits* ASR::Team::mUnits [private] |
Definition at line 46 of file Team.h.
Referenced by createUnit(), findTargets(), getAdjacentUnits(), getUnitIterator(), Team(), ASR::TeamUpdater::updateAfterFrame(), ASR::TeamUpdater::updateBeforeFrame(), and ~Team().
TeamUpdater* ASR::Team::mUpdater [private] |