"anim-hp-bound" is now called "anim-progress-bound" and available for produce/morph/upgrade skills too! Deprecated "anim-hp-bound" will be dropped VERY soon!

This commit is contained in:
Titus Tscharntke 2011-07-07 23:02:46 +00:00
parent 9a6aca1bdc
commit c21f07ec7d
5 changed files with 113 additions and 15 deletions

View File

@ -3068,7 +3068,7 @@ void Renderer::renderUnits(const int renderFps) {
//render
Model *model= unit->getCurrentModelPtr();
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive() && !unit->isBeingBuiltWithAnimHpBound());
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound());
modelRenderer->render(model);
triangleCount+= model->getTriangleCount();
@ -4733,7 +4733,7 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
//render
Model *model= unit->getCurrentModelPtr();
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive() && !unit->isBeingBuiltWithAnimHpBound());
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive() && !unit->isAnimProgressBound());
modelRenderer->render(model);
glPopMatrix();

View File

@ -487,6 +487,17 @@ int Unit::getProductionPercent() const{
return -1;
}
float Unit::getProgressRatio() const{
if(anyCommand()){
const ProducibleType *produced= commands.front()->getCommandType()->getProduced();
if(produced!=NULL){
float help=progress2;
return clamp(help/produced->getProductionTime(), 0.f, 1.f);
}
}
return -1;
}
float Unit::getHpRatio() const {
if(type == NULL) {
char szBuf[4096]="";
@ -550,7 +561,7 @@ bool Unit::isOperative() const{
return isAlive() && isBuilt();
}
bool Unit::isBeingBuiltWithAnimHpBound() const{
bool Unit::isAnimProgressBound() const{
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
@ -559,9 +570,27 @@ bool Unit::isBeingBuiltWithAnimHpBound() const{
bool result = false;
if(currSkill->getClass() == scBeBuilt) {
const BeBuiltSkillType *bbst = dynamic_cast<const BeBuiltSkillType*>(currSkill);
if(bbst != NULL) {
result = bbst->getAnimHpBound();
const BeBuiltSkillType *skill = dynamic_cast<const BeBuiltSkillType*>(currSkill);
if(skill != NULL) {
result = skill->getAnimProgressBound();
}
}
else if(currSkill->getClass() == scProduce) {
const ProduceSkillType *skill = dynamic_cast<const ProduceSkillType*>(currSkill);
if(skill != NULL) {
result = skill->getAnimProgressBound();
}
}
else if(currSkill->getClass() == scUpgrade) {
const UpgradeSkillType *skill = dynamic_cast<const UpgradeSkillType*>(currSkill);
if(skill != NULL) {
result = skill->getAnimProgressBound();
}
}
else if(currSkill->getClass() == scMorph) {
const MorphSkillType *skill = dynamic_cast<const MorphSkillType*>(currSkill);
if(skill != NULL) {
result = skill->getAnimProgressBound();
}
}
return result;
@ -1336,8 +1365,11 @@ bool Unit::update() {
float speedDenominator = (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()));
progress += (speed * diagonalFactor * heightFactor) / speedDenominator;
if(isBeingBuiltWithAnimHpBound() == true) {
animProgress=this->getHpRatio();
if(isAnimProgressBound() == true) {
if(currSkill->getClass() == scBeBuilt) animProgress = this->getHpRatio();
if(currSkill->getClass() == scProduce) animProgress = this->getProgressRatio();
if(currSkill->getClass() == scUpgrade) animProgress = this->getProgressRatio();
if(currSkill->getClass() == scMorph) animProgress = this->getProgressRatio();
}
else{
animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator;

View File

@ -404,6 +404,7 @@ public:
int getHp() const {return hp;}
int getEp() const {return ep;}
int getProductionPercent() const;
float getProgressRatio() const;
float getHpRatio() const;
float getEpRatio() const;
bool getToBeUndertaken() const {return toBeUndertaken;}
@ -443,7 +444,7 @@ public:
bool isOperative() const;
bool isBeingBuilt() const;
bool isBuilt() const;
bool isBeingBuiltWithAnimHpBound() const;
bool isAnimProgressBound() const;
bool isPutrefacting() const;
bool isAlly(const Unit *unit) const;
bool isDamaged() const;

View File

@ -588,6 +588,20 @@ ProduceSkillType::ProduceSkillType(){
skillClass= scProduce;
}
void ProduceSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
if(sn->hasChild("anim-progress-bound")){
animProgressBound= sn->getChild("anim-progress-bound")->getAttribute("value")->getBoolValue();
}
else {
animProgressBound=false;
}
}
string ProduceSkillType::toString() const{
return Lang::getInstance().get("Produce");
}
@ -606,6 +620,19 @@ UpgradeSkillType::UpgradeSkillType(){
skillClass= scUpgrade;
}
void UpgradeSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
if(sn->hasChild("anim-progress-bound")){
animProgressBound= sn->getChild("anim-progress-bound")->getAttribute("value")->getBoolValue();
}
else {
animProgressBound=false;
}
}
string UpgradeSkillType::toString() const{
return Lang::getInstance().get("Upgrade");
}
@ -629,11 +656,14 @@ void BeBuiltSkillType::load(const XmlNode *sn, const string &dir, const TechTree
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
if(sn->hasChild("anim-hp-bound")){
animHpBound= sn->getChild("anim-hp-bound")->getAttribute("value")->getBoolValue();
if(sn->hasChild("anim-progress-bound")){
animProgressBound= sn->getChild("anim-progress-bound")->getAttribute("value")->getBoolValue();
}
else if(sn->hasChild("anim-hp-bound")){ // deprecated!!!! remove it when you see it after 15th July 2011
animProgressBound= sn->getChild("anim-hp-bound")->getAttribute("value")->getBoolValue();
}
else {
animHpBound=false;
animProgressBound=false;
}
}
@ -650,6 +680,19 @@ MorphSkillType::MorphSkillType(){
skillClass= scMorph;
}
void MorphSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
if(sn->hasChild("anim-progress-bound")){
animProgressBound= sn->getChild("anim-progress-bound")->getAttribute("value")->getBoolValue();
}
else {
animProgressBound=false;
}
}
string MorphSkillType::toString() const{
return "Morph";
}

View File

@ -278,8 +278,15 @@ public:
// ===============================
class ProduceSkillType: public SkillType{
private:
bool animProgressBound;
public:
ProduceSkillType();
bool getAnimProgressBound() const {return animProgressBound;}
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
@ -290,8 +297,15 @@ public:
// ===============================
class UpgradeSkillType: public SkillType{
private:
bool animProgressBound;
public:
UpgradeSkillType();
bool getAnimProgressBound() const {return animProgressBound;}
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
@ -304,11 +318,11 @@ public:
class BeBuiltSkillType: public SkillType{
private:
bool animHpBound;
bool animProgressBound;
public:
BeBuiltSkillType();
bool getAnimHpBound() const {return animHpBound;}
bool getAnimProgressBound() const {return animProgressBound;}
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
@ -321,10 +335,18 @@ public:
// ===============================
class MorphSkillType: public SkillType{
private:
bool animProgressBound;
public:
MorphSkillType();
virtual string toString() const;
bool getAnimProgressBound() const {return animProgressBound;}
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader);
virtual string toString() const;
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
};