Added to booleans

1. selectable	| if this is false, you cant select the unit.
2. commandable	| if this is false, you cant give the units commands.

I advise to set a non-selectable unit to non-commandable too if you want to make a normal unit morph into it.
This commit is contained in:
titison 2014-07-28 17:03:36 +02:00
parent 6fc59dc5f2
commit 72828c39a3
3 changed files with 28 additions and 1 deletions

View File

@ -71,6 +71,16 @@ bool Selection::select(Unit *unit) {
return false;
}
//check if selectable
if(unit->getType()->isSelectable() == false) {
return false;
}
//check if selectable
if(unit->getType()->isCommandable() == false && isEmpty() == false) {
return false;
}
//check if multisel
if(unit->getType()->getMultiSelect() == false && isEmpty() == false) {
return false;
@ -181,7 +191,8 @@ bool Selection::isCommandable() const {
return
isEmpty() == false &&
isEnemy() == false &&
(selectedUnits.size() == 1 && selectedUnits.front()->isAlive() == false) == false;
(selectedUnits.size() == 1 && selectedUnits.front()->isAlive() == false) == false &&
selectedUnits.front()->getType()->isCommandable();
}
bool Selection::isCancelable() const {

View File

@ -89,6 +89,8 @@ UnitType::UnitType() : ProducibleType() {
lightColor= Vec3f(0.f);
light= false;
multiSelect= false;
selectable= true;
commandable= true;
armorType= NULL;
rotatedBuildPos=0;
@ -333,6 +335,14 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
//multi selection
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
//selectable
if(parametersNode->hasChild("selectable")){
selectable= parametersNode->getChild("selectable")->getAttribute("value")->getBoolValue();
}
//commandable
if(parametersNode->hasChild("commandable")){
commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue();
}
//cellmap
allowEmptyCellMap = false;
const XmlNode *cellMapNode= parametersNode->getChild("cellmap");
@ -1240,6 +1250,8 @@ std::string UnitType::toString() const {
result += " light = " + intToStr(light);
result += " lightColor = " + lightColor.getString();
result += " multiSelect = " + intToStr(multiSelect);
result += " selectable = " + intToStr(selectable);
result += " commandable = " + intToStr(commandable);
result += " sight = " + intToStr(sight);
result += " size = " + intToStr(size);
result += " height = " + intToStr(height);

View File

@ -171,6 +171,8 @@ private:
bool light;
Vec3f lightColor;
bool multiSelect;
bool selectable;
bool commandable;
int sight;
int size; //size in cells
int renderSize; //size to render in cells
@ -255,6 +257,8 @@ public:
inline bool getRotationAllowed() const {return rotationAllowed;}
inline Vec3f getLightColor() const {return lightColor;}
inline bool getMultiSelect() const {return multiSelect;}
inline bool isSelectable() const {return selectable;}
inline bool isCommandable() const {return commandable;}
inline int getSight() const {return sight;}
inline int getSize() const {return size;}
inline int getRenderSize() const {return renderSize;}