reserve unit place while morphing. (first try)
This commit is contained in:
parent
c2d43c8b86
commit
75032c3287
|
@ -3382,6 +3382,13 @@ void Game::render3d(){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// renderTeamColorCircle
|
||||||
|
renderer.renderMorphEffects();
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
|
|
||||||
//units
|
//units
|
||||||
renderer.renderUnits(avgRenderFps);
|
renderer.renderUnits(avgRenderFps);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderUnits]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderUnits]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||||
|
|
|
@ -5062,6 +5062,47 @@ void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::renderMorphEffects(){
|
||||||
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||||
|
if(qCache.visibleQuadUnitList.empty() == false) {
|
||||||
|
bool initialized=false;
|
||||||
|
for(int visibleUnitIndex = 0;
|
||||||
|
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
||||||
|
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||||
|
if(unit->getCurrSkill() != NULL && unit->getCurrSkill()->getClass() == scMorph) {
|
||||||
|
Command *command= unit->getCurrCommand();
|
||||||
|
if(command != NULL && command->getCommandType()->commandTypeClass == ccMorph){
|
||||||
|
const MorphCommandType *mct= static_cast<const MorphCommandType*>(command->getCommandType());
|
||||||
|
const UnitType* mType=mct->getMorphUnit();
|
||||||
|
|
||||||
|
if(!initialized){
|
||||||
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glLineWidth(2.f);
|
||||||
|
initialized=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3f currVec= unit->getCurrVectorFlat();
|
||||||
|
glColor4f(0.2f, 0.2f, 0.2f, 0.4f);
|
||||||
|
renderSelectionCircle(currVec, mType->getSize(), 0.8f, 0.55f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(initialized) {
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::renderSelectionEffects() {
|
void Renderer::renderSelectionEffects() {
|
||||||
|
|
|
@ -560,6 +560,7 @@ public:
|
||||||
inline Quad2i getVisibleQuadFromCamera() const {return visibleQuadFromCamera;}
|
inline Quad2i getVisibleQuadFromCamera() const {return visibleQuadFromCamera;}
|
||||||
void renderTeamColorPlane();
|
void renderTeamColorPlane();
|
||||||
void renderTeamColorCircle();
|
void renderTeamColorCircle();
|
||||||
|
void renderMorphEffects();
|
||||||
|
|
||||||
//static
|
//static
|
||||||
static Shadows strToShadows(const string &s);
|
static Shadows strToShadows(const string &s);
|
||||||
|
|
|
@ -1012,7 +1012,6 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
||||||
this->animationRandomCycleCount = 0;
|
this->animationRandomCycleCount = 0;
|
||||||
}
|
}
|
||||||
this->currSkill= currSkill;
|
this->currSkill= currSkill;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::setCurrSkill(SkillClass sc) {
|
void Unit::setCurrSkill(SkillClass sc) {
|
||||||
|
@ -2951,6 +2950,12 @@ CommandResult Unit::undoCommand(Command *command){
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->currSkill->getClass() == scMorph){
|
||||||
|
// clear cells of morphed unit and set those of current unit!
|
||||||
|
map->clearUnitCells(this, this->getPos());
|
||||||
|
map->putUnitCells(this, this->getPos(),true);
|
||||||
|
}
|
||||||
|
|
||||||
//return cost
|
//return cost
|
||||||
const ProducibleType *produced= command->getCommandType()->getProduced();
|
const ProducibleType *produced= command->getCommandType()->getProduced();
|
||||||
if(produced!=NULL){
|
if(produced!=NULL){
|
||||||
|
|
|
@ -1361,7 +1361,7 @@ bool Map::isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,
|
||||||
}
|
}
|
||||||
|
|
||||||
//put a units into the cells
|
//put a units into the cells
|
||||||
void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
|
void Map::putUnitCells(Unit *unit, const Vec2i &pos, bool ignoreSkill) {
|
||||||
assert(unit != NULL);
|
assert(unit != NULL);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
throw megaglest_runtime_error("ut == NULL");
|
throw megaglest_runtime_error("ut == NULL");
|
||||||
|
@ -1370,6 +1370,19 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos) {
|
||||||
bool canPutInCell = true;
|
bool canPutInCell = true;
|
||||||
const UnitType *ut= unit->getType();
|
const UnitType *ut= unit->getType();
|
||||||
|
|
||||||
|
// block space for morphing units
|
||||||
|
if(ignoreSkill==false &&
|
||||||
|
unit->getCurrSkill() != NULL &&
|
||||||
|
unit->getCurrSkill()->getClass() == scMorph) {
|
||||||
|
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()){
|
||||||
|
ut=mct->getMorphUnit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < ut->getSize(); ++i) {
|
for(int i = 0; i < ut->getSize(); ++i) {
|
||||||
for(int j = 0; j < ut->getSize(); ++j) {
|
for(int j = 0; j < ut->getSize(); ++j) {
|
||||||
Vec2i currPos= pos + Vec2i(i, j);
|
Vec2i currPos= pos + Vec2i(i, j);
|
||||||
|
@ -1439,6 +1452,16 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos) {
|
||||||
|
|
||||||
const UnitType *ut= unit->getType();
|
const UnitType *ut= unit->getType();
|
||||||
|
|
||||||
|
if(unit->getCurrSkill() != NULL &&
|
||||||
|
unit->getCurrSkill()->getClass() == scMorph) {
|
||||||
|
Command *command= unit->getCurrCommand();
|
||||||
|
const MorphCommandType *mct= static_cast<const MorphCommandType*>(command->getCommandType());
|
||||||
|
if(unit->getType()->getSize()<=mct->getMorphUnit()->getSize()){
|
||||||
|
ut=mct->getMorphUnit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(int i=0; i<ut->getSize(); ++i){
|
for(int i=0; i<ut->getSize(); ++i){
|
||||||
for(int j=0; j<ut->getSize(); ++j){
|
for(int j=0; j<ut->getSize(); ++j){
|
||||||
Vec2i currPos= pos + Vec2i(i, j);
|
Vec2i currPos= pos + Vec2i(i, j);
|
||||||
|
|
|
@ -396,7 +396,7 @@ public:
|
||||||
//unit placement
|
//unit placement
|
||||||
bool aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::map<Vec2i, std::map<Vec2i, std::map<int, std::map<int, std::map<Field,bool> > > > > *lookupCache=NULL) const;
|
bool aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::map<Vec2i, std::map<Vec2i, std::map<int, std::map<int, std::map<Field,bool> > > > > *lookupCache=NULL) const;
|
||||||
bool canMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2,std::map<Vec2i, std::map<Vec2i, std::map<int, std::map<Field,bool> > > > *lookupCache=NULL) const;
|
bool canMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2,std::map<Vec2i, std::map<Vec2i, std::map<int, std::map<Field,bool> > > > *lookupCache=NULL) const;
|
||||||
void putUnitCells(Unit *unit, const Vec2i &pos);
|
void putUnitCells(Unit *unit, const Vec2i &pos,bool ignoreSkill = false);
|
||||||
void clearUnitCells(Unit *unit, const Vec2i &pos);
|
void clearUnitCells(Unit *unit, const Vec2i &pos);
|
||||||
|
|
||||||
Vec2i computeRefPos(const Selection *selection) const;
|
Vec2i computeRefPos(const Selection *selection) const;
|
||||||
|
|
|
@ -1900,6 +1900,9 @@ void UnitUpdater::updateMorph(Unit *unit, int frameIndex) {
|
||||||
//if not morphing, check space
|
//if not morphing, check space
|
||||||
if(map->isFreeCellsOrHasUnit(unit->getPos(), mct->getMorphUnit()->getSize(), mct->getMorphUnit()->getField(), unit, mct->getMorphUnit())){
|
if(map->isFreeCellsOrHasUnit(unit->getPos(), mct->getMorphUnit()->getSize(), mct->getMorphUnit()->getField(), unit, mct->getMorphUnit())){
|
||||||
unit->setCurrSkill(mct->getMorphSkillType());
|
unit->setCurrSkill(mct->getMorphSkillType());
|
||||||
|
// block space for morphing units ( block space before and after morph ! )
|
||||||
|
map->putUnitCells(unit, unit->getPos());
|
||||||
|
map->putUnitCells(unit, unit->getPos(), true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(unit->getFactionIndex()==world->getThisFactionIndex()){
|
if(unit->getFactionIndex()==world->getThisFactionIndex()){
|
||||||
|
|
Loading…
Reference in New Issue