- fix for harvesting workers to reset to original harvest location each time they deliver resources
This commit is contained in:
parent
0f6f5cfe21
commit
68f1ec06b5
|
@ -30,6 +30,7 @@ Command::Command(const CommandType *ct, const Vec2i &pos){
|
|||
|
||||
this->commandType= ct;
|
||||
this->pos= pos;
|
||||
this->originalPos = this->pos;
|
||||
this->unitRef= NULL;
|
||||
unitType= NULL;
|
||||
stateType = cst_None;
|
||||
|
@ -39,6 +40,7 @@ Command::Command(const CommandType *ct, const Vec2i &pos){
|
|||
Command::Command(const CommandType *ct, Unit* unit) {
|
||||
this->commandType= ct;
|
||||
this->pos= Vec2i(0);
|
||||
this->originalPos = this->pos;
|
||||
this->unitRef= unit;
|
||||
unitType= NULL;
|
||||
if(unit!=NULL) {
|
||||
|
@ -52,6 +54,7 @@ Command::Command(const CommandType *ct, Unit* unit) {
|
|||
Command::Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing) {
|
||||
this->commandType= ct;
|
||||
this->pos= pos;
|
||||
this->originalPos = this->pos;
|
||||
this->unitRef= NULL;
|
||||
this->unitType= unitType;
|
||||
this->facing = facing;
|
||||
|
@ -71,7 +74,7 @@ int Command::getPriority(){
|
|||
}
|
||||
// =============== set ===============
|
||||
|
||||
void Command::setCommandType(const CommandType *commandType){
|
||||
void Command::setCommandType(const CommandType *commandType) {
|
||||
this->commandType= commandType;
|
||||
}
|
||||
|
||||
|
@ -79,6 +82,14 @@ void Command::setPos(const Vec2i &pos){
|
|||
this->pos= pos;
|
||||
}
|
||||
|
||||
void Command::setOriginalPos(const Vec2i &pos) {
|
||||
this->originalPos= pos;
|
||||
}
|
||||
|
||||
void Command::setPosToOriginalPos() {
|
||||
this->pos= this->originalPos;
|
||||
}
|
||||
|
||||
void Command::setUnit(Unit *unit){
|
||||
this->unitRef= unit;
|
||||
}
|
||||
|
@ -88,13 +99,15 @@ std::string Command::toString() const {
|
|||
|
||||
std::string result = "";
|
||||
if(commandType != NULL) {
|
||||
result = "commandType id = " + intToStr(commandType->getId()) + ", desc = " + commandType->toString() + ", pos = " + pos.getString() + ", facing = " + intToStr(facing.asInt());
|
||||
result = "commandType id = " + intToStr(commandType->getId()) + ", desc = " + commandType->toString();
|
||||
}
|
||||
else {
|
||||
result = "commandType = NULL";
|
||||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||
|
||||
result += ", pos = " + pos.getString() + ", originalPos = " + originalPos.getString() + ", facing = " + intToStr(facing.asInt());
|
||||
|
||||
//if(unitRef.getUnit() != NULL) {
|
||||
if(unitRef.getUnitId() >= 0) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
|
||||
|
|
|
@ -39,6 +39,7 @@ enum CommandStateType {
|
|||
class Command {
|
||||
private:
|
||||
const CommandType *commandType;
|
||||
Vec2i originalPos;
|
||||
Vec2i pos;
|
||||
UnitReference unitRef; //target unit, used to move and attack optionally
|
||||
CardinalDir facing; // facing, for build command
|
||||
|
@ -56,6 +57,7 @@ public:
|
|||
//get
|
||||
const CommandType *getCommandType() const {return commandType;}
|
||||
Vec2i getPos() const {return pos;}
|
||||
Vec2i getOriginalPos() const {return originalPos;}
|
||||
Unit* getUnit() const {return unitRef.getUnit();}
|
||||
const UnitType* getUnitType() const {return unitType;}
|
||||
CardinalDir getFacing() const {return facing;}
|
||||
|
@ -66,6 +68,9 @@ public:
|
|||
//set
|
||||
void setCommandType(const CommandType *commandType);
|
||||
void setPos(const Vec2i &pos);
|
||||
void setOriginalPos(const Vec2i &pos);
|
||||
void setPosToOriginalPos();
|
||||
|
||||
void setUnit(Unit *unit);
|
||||
|
||||
void setStateType(CommandStateType value) { stateType = value; }
|
||||
|
|
|
@ -1042,6 +1042,8 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
|
|||
unit->getPath()->clear();
|
||||
unit->setCurrSkill(scStop);
|
||||
unit->setLoadCount(0);
|
||||
|
||||
command->setPosToOriginalPos();
|
||||
}
|
||||
}
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
|
Loading…
Reference in New Issue