again new morphing feature: better way to handle the blocked places for morphing units

This commit is contained in:
Titus Tscharntke 2012-09-21 23:45:59 +00:00
parent a4ad1f5aea
commit 5b6ffbd361
3 changed files with 11 additions and 4 deletions

View File

@ -424,6 +424,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos,
this->ignoreCheckCommand = false;
this->inBailOutAttempt = false;
this->lastHarvestResourceTarget.first = Vec2i(0);
this->morphFieldsBlocked=false;
//this->lastBadHarvestListPurge = 0;
level= NULL;

View File

@ -345,6 +345,7 @@ private:
int progress2;
int kills;
int enemyKills;
bool morphFieldsBlocked;
UnitReference targetRef;
@ -562,6 +563,10 @@ public:
inline void setCurrField(Field currField) {this->currField= currField;}
void setCurrSkill(const SkillType *currSkill);
void setCurrSkill(SkillClass sc);
void setMorphFieldsBlocked ( bool value ) {this->morphFieldsBlocked=value;}
bool getMorphFieldsBlocked() const { return morphFieldsBlocked; }
inline void setLoadCount(int loadCount) {this->loadCount= loadCount;}
inline void setLoadType(const ResourceType *loadType) {this->loadType= loadType;}
inline void setProgress2(int progress2) {this->progress2= progress2;}

View File

@ -1390,9 +1390,8 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos, bool ignoreSkill) {
Command *command= unit->getCurrCommand();
if(command != NULL && command->getCommandType()->commandTypeClass == ccMorph){
const MorphCommandType *mct= static_cast<const MorphCommandType*>(command->getCommandType());
if(unit->getType()->getSize()<=mct->getMorphUnit()->getSize()){
putUnitCellsPrivate(unit, pos, mct->getMorphUnit(),true);
}
putUnitCellsPrivate(unit, pos, mct->getMorphUnit(),true);
unit->setMorphFieldsBlocked(true);
}
}
}
@ -1490,12 +1489,14 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos, bool ignoreSkill) {
if(ignoreSkill==false &&
unit->getCurrSkill() != NULL &&
unit->getCurrSkill()->getClass() == scMorph) {
unit->getCurrSkill()->getClass() == scMorph &&
unit->getMorphFieldsBlocked() == true) {
Command *command= unit->getCurrCommand();
const MorphCommandType *mct= static_cast<const MorphCommandType*>(command->getCommandType());
if(unit->getType()->getSize()<=mct->getMorphUnit()->getSize()){
ut=mct->getMorphUnit();
currentField=ut->getField();
unit->setMorphFieldsBlocked(false);
}
}