Uniformselection
Added uniform selection of units. Uniform means you can select multiple units, but only of the same type. To make a unit uniform-selectable you need to add ```<uniform-selection value="true"/>``` to the ```<parameters>``` tag of a unit.
This commit is contained in:
parent
3639e111ef
commit
74ed3d73be
|
@ -81,6 +81,16 @@ bool Selection::select(Unit *unit) {
|
|||
return false;
|
||||
}
|
||||
|
||||
//check if multitypesel
|
||||
if(selectedUnits.size() > 0) {
|
||||
if(selectedUnits.front()->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
||||
return false;
|
||||
}
|
||||
if(unit->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//check if enemy
|
||||
if(canSelectUnitFactionCheck(unit) == false && isEmpty() == false) {
|
||||
return false;
|
||||
|
@ -270,6 +280,19 @@ bool Selection::addUnitToGroup(int groupIndex,Unit *unit) {
|
|||
}
|
||||
}
|
||||
|
||||
// check for uniformselect units
|
||||
if((int)groups[groupIndex].size()>0 ){
|
||||
Unit* unitInGroup=groups[groupIndex][0];
|
||||
if( unit->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()) {
|
||||
//dont add uniform selection unit
|
||||
return false;
|
||||
}
|
||||
if( unitInGroup->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()){
|
||||
//dont add another unit to a group of uniform selection units
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(unit != NULL && !groupIsFull) {
|
||||
groups[groupIndex].push_back(unit);
|
||||
return true;
|
||||
|
|
|
@ -93,6 +93,7 @@ UnitType::UnitType() : ProducibleType() {
|
|||
healthbarthickness=-1.0f;
|
||||
healthbarVisible=hbvUndefined;
|
||||
multiSelect= false;
|
||||
uniformSelect= false;
|
||||
commandable= true;
|
||||
armorType= NULL;
|
||||
rotatedBuildPos=0;
|
||||
|
@ -356,6 +357,11 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
|
|||
//multi selection
|
||||
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
||||
|
||||
//uniform selection
|
||||
if(parametersNode->hasChild("uniform-selection")) {
|
||||
uniformSelect= parametersNode->getChild("uniform-selection")->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
|
||||
//commandable
|
||||
if(parametersNode->hasChild("commandable")){
|
||||
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
|
||||
|
@ -1307,6 +1313,7 @@ std::string UnitType::toString() const {
|
|||
result += " light = " + intToStr(light);
|
||||
result += " lightColor = " + lightColor.getString();
|
||||
result += " multiSelect = " + intToStr(multiSelect);
|
||||
result += " uniformSelect = " + intToStr(uniformSelect);
|
||||
result += " commandable = " + intToStr(commandable);
|
||||
result += " sight = " + intToStr(sight);
|
||||
result += " size = " + intToStr(size);
|
||||
|
|
|
@ -192,6 +192,7 @@ private:
|
|||
float healthbarthickness;
|
||||
int healthbarVisible;
|
||||
bool multiSelect;
|
||||
bool uniformSelect;
|
||||
bool commandable;
|
||||
int sight;
|
||||
int size; //size in cells
|
||||
|
@ -283,6 +284,7 @@ public:
|
|||
inline float getHealthbarThickness() const {return healthbarthickness;}
|
||||
inline int getHealthbarVisible() const {return healthbarVisible;}
|
||||
inline bool getMultiSelect() const {return multiSelect;}
|
||||
inline bool getUniformSelect() const {return uniformSelect;}
|
||||
inline bool isCommandable() const {return commandable;}
|
||||
inline int getSight() const {return sight;}
|
||||
inline int getSize() const {return size;}
|
||||
|
|
Loading…
Reference in New Issue