- unit particles now support minHp / mapHp tags
This commit is contained in:
parent
04bc3b9f06
commit
3b3132ccce
|
@ -1 +1 @@
|
|||
Subproject commit 1503ca70fd0813c5fd090aef2b024e04bb1c3161
|
||||
Subproject commit 3de3304fd08fed556c5bfee168fcaa64bbf75612
|
|
@ -1,3 +1,4 @@
|
|||
/windows_deps*/
|
||||
/glest_game/facilities/gitversion.h
|
||||
/glest_game/site/
|
||||
/Debug
|
||||
|
|
|
@ -1371,6 +1371,8 @@ void MainWindow::loadParticle(string path) {
|
|||
|
||||
for(std::vector<UnitParticleSystemType *>::const_iterator it= unitParticleSystemTypes.begin(); it != unitParticleSystemTypes.end(); ++it) {
|
||||
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
||||
|
||||
ups->setParticleType((*it));
|
||||
(*it)->setValues(ups);
|
||||
if(size > 0) {
|
||||
//getCurrVectorFlat() + Vec3f(0.f, type->getHeight()/2.f, 0.f);
|
||||
|
|
|
@ -305,6 +305,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
|
|||
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
||||
UnitParticleSystem *child = new UnitParticleSystem();
|
||||
child->setParticleOwner(ats->getParticleOwner());
|
||||
child->setParticleType((*i));
|
||||
(*i)->setValues(child);
|
||||
ats->addChild(child);
|
||||
child->setState(ParticleSystem::sPlay);
|
||||
|
|
|
@ -52,7 +52,7 @@ class UnitParticleSystemType;
|
|||
/// A type of particle system
|
||||
// ===========================================================
|
||||
|
||||
class ParticleSystemType {
|
||||
class ParticleSystemType : public ParticleSystemTypeInterface {
|
||||
protected:
|
||||
string type;
|
||||
Texture2D *texture;
|
||||
|
|
|
@ -218,6 +218,7 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
|||
for(Children::iterator i=children.begin(); i!=children.end(); ++i){
|
||||
UnitParticleSystem *child = new UnitParticleSystem();
|
||||
child->setParticleOwner(ups->getParticleOwner());
|
||||
child->setParticleType((*i));
|
||||
(*i)->setValues(child);
|
||||
ups->addChild(child);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ void Object::initParticlesFromTypes(const ModelParticleSystemTypes *particleType
|
|||
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
||||
UnitParticleSystem *ups= new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType((*it));
|
||||
(*it)->setValues(ups);
|
||||
ups->setPos(this->pos);
|
||||
ups->setRotation(this->rotation);
|
||||
|
|
|
@ -331,6 +331,8 @@ void UnitAttackBoostEffect::applyLoadedAttackBoostParticles(UnitParticleSystemTy
|
|||
ups = new UnitParticleSystem(200);
|
||||
//ups->loadGame(node2);
|
||||
ups->setParticleOwner(unit);
|
||||
ups->setParticleType(upst);
|
||||
|
||||
upst->setValues(ups);
|
||||
ups->setPos(unit->getCurrVector());
|
||||
ups->setRotation(unit->getRotation());
|
||||
|
@ -1291,12 +1293,16 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
|||
unitParticleSystems.empty() == true) {
|
||||
//printf("START - particle system type\n");
|
||||
|
||||
for(UnitParticleSystemTypes::const_iterator it= currSkill->unitParticleSystemTypes.begin(); it != currSkill->unitParticleSystemTypes.end(); ++it) {
|
||||
/*
|
||||
for(UnitParticleSystemTypes::const_iterator it= currSkill->unitParticleSystemTypes.begin();
|
||||
it != currSkill->unitParticleSystemTypes.end(); ++it) {
|
||||
if((*it)->getStartTime() == 0.0) {
|
||||
//printf("Adding NON-queued particle system type [%s] [%f] [%f]\n",(*it)->getType().c_str(),(*it)->getStartTime(),(*it)->getEndTime());
|
||||
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType((*it));
|
||||
|
||||
(*it)->setValues(ups);
|
||||
ups->setPos(getCurrVector());
|
||||
ups->setRotation(getRotation());
|
||||
|
@ -1313,6 +1319,9 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
|
|||
queuedUnitParticleSystemTypes.push_back(*it);
|
||||
}
|
||||
}
|
||||
*/
|
||||
checkCustomizedUnitParticleListTriggers(unitParticleSystems,
|
||||
currSkill->unitParticleSystemTypes,queuedUnitParticleSystemTypes);
|
||||
}
|
||||
progress2= 0;
|
||||
if(this->currSkill != currSkill) {
|
||||
|
@ -2396,6 +2405,8 @@ void Unit::updateAttackBoostProgress(const Game* game) {
|
|||
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleOwner(this);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleType(currentAttackBoostOriginatorEffect.currentAppliedEffect->upst);
|
||||
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
||||
|
@ -2507,6 +2518,8 @@ void Unit::updateAttackBoostProgress(const Game* game) {
|
|||
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups = new UnitParticleSystem(200);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleOwner(this);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setParticleType(currentAttackBoostOriginatorEffect.currentAppliedEffect->upst);
|
||||
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->upst->setValues(
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups);
|
||||
currentAttackBoostOriginatorEffect.currentAppliedEffect->ups->setPos(
|
||||
|
@ -2786,6 +2799,8 @@ void Unit::updateTimedParticles() {
|
|||
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType(pst);
|
||||
|
||||
pst->setValues(ups);
|
||||
ups->setPos(getCurrVector());
|
||||
ups->setRotation(getRotation());
|
||||
|
@ -2927,6 +2942,8 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
|||
|
||||
effect->ups = new UnitParticleSystem(200);
|
||||
effect->ups->setParticleOwner(this);
|
||||
effect->ups->setParticleType(effect->upst);
|
||||
|
||||
effect->upst->setValues(effect->ups);
|
||||
effect->ups->setPos(getCurrVector());
|
||||
effect->ups->setRotation(getRotation());
|
||||
|
@ -3977,8 +3994,131 @@ void Unit::stopDamageParticles(bool force) {
|
|||
checkCustomizedParticleTriggers(force);
|
||||
}
|
||||
|
||||
void Unit::checkCustomizedUnitParticleListTriggers(vector<UnitParticleSystem*> &unitParticleSystemsList,
|
||||
const UnitParticleSystemTypes &unitParticleSystemTypesList,
|
||||
vector<UnitParticleSystemType*> &queuedUnitParticleSystemTypesList) {
|
||||
if(showUnitParticles == true) {
|
||||
vector<ParticleSystemTypeInterface *> systemTypesInUse;
|
||||
|
||||
if(unitParticleSystemsList.empty() == false) {
|
||||
for(int index = (int)unitParticleSystemsList.size() - 1; index >= 0; index--) {
|
||||
UnitParticleSystem *ps = unitParticleSystemsList[index];
|
||||
if(ps != NULL) {
|
||||
if(Renderer::getInstance().validateParticleSystemStillExists(ps,rsGame) == true) {
|
||||
|
||||
bool stopParticle = false;
|
||||
if((ps->getParticleType() != NULL &&
|
||||
ps->getParticleType()->getMinmaxEnabled())) {
|
||||
|
||||
if(ps->getParticleType() != NULL) {
|
||||
if(ps->getParticleType()->getMinmaxIsPercent() == false) {
|
||||
if(hp < ps->getParticleType()->getMinHp() || hp > ps->getParticleType()->getMaxHp()) {
|
||||
stopParticle = true;
|
||||
|
||||
//printf("STOP Particle line: %d\n",__LINE__);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int hpPercent = (hp / type->getTotalMaxHp(&totalUpgrade) * 100);
|
||||
if(hpPercent < ps->getParticleType()->getMinHp() || hpPercent > ps->getParticleType()->getMaxHp()) {
|
||||
stopParticle = true;
|
||||
|
||||
//printf("STOP Particle line: %d\n",__LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(stopParticle == true) {
|
||||
ps->fade();
|
||||
unitParticleSystemsList.erase(unitParticleSystemsList.begin() + index);
|
||||
}
|
||||
}
|
||||
|
||||
if(ps->getParticleType() != NULL && stopParticle == false) {
|
||||
systemTypesInUse.push_back(ps->getParticleType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("Check Particle start line: %d size: %d\n",__LINE__,(int)unitParticleSystemTypesList.size());
|
||||
|
||||
if(unitParticleSystemTypesList.empty() == false) {
|
||||
|
||||
//for(unsigned int index = 0; index < unitParticleSystemTypesList.size(); ++index) {
|
||||
for(UnitParticleSystemTypes::const_iterator iterParticleType = unitParticleSystemTypesList.begin();
|
||||
iterParticleType != unitParticleSystemTypesList.end(); ++iterParticleType) {
|
||||
UnitParticleSystemType *pst = *iterParticleType;
|
||||
|
||||
vector<ParticleSystemTypeInterface *>::iterator iterFind = std::find(systemTypesInUse.begin(),systemTypesInUse.end(),pst);
|
||||
|
||||
//printf("Check Particle line: %d isenabled: %d already in use: %d\n",__LINE__,pst->getMinmaxEnabled(),(iterFind == systemTypesInUse.end()));
|
||||
|
||||
if(pst->getMinmaxEnabled() == true) {
|
||||
|
||||
//printf("Check Particle line: %d isenabled: %d already in use: %d\n",__LINE__,pst->getMinmaxEnabled(),(iterFind != systemTypesInUse.end()));
|
||||
|
||||
if(iterFind == systemTypesInUse.end()) {
|
||||
bool showParticle = false;
|
||||
if(pst->getMinmaxIsPercent() == false) {
|
||||
if(hp >= pst->getMinHp() && hp <= pst->getMaxHp()) {
|
||||
showParticle = true;
|
||||
|
||||
//printf("START Particle line: %d\n",__LINE__);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int hpPercent = (hp / type->getTotalMaxHp(&totalUpgrade) * 100);
|
||||
if(hpPercent >= pst->getMinHp() && hpPercent <= pst->getMaxHp()) {
|
||||
showParticle = true;
|
||||
|
||||
//printf("START Particle line: %d\n",__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
if(showParticle == true) {
|
||||
|
||||
if(pst->getStartTime() == 0.0) {
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType(pst);
|
||||
|
||||
pst->setValues(ups);
|
||||
ups->setPos(getCurrVector());
|
||||
ups->setRotation(getRotation());
|
||||
ups->setUnitModel(getCurrentModelPtr());
|
||||
if(getFaction()->getTexture()) {
|
||||
ups->setFactionColor(getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
|
||||
}
|
||||
unitParticleSystemsList.push_back(ups);
|
||||
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
||||
}
|
||||
else {
|
||||
queuedUnitParticleSystemTypesList.push_back(pst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Unit::checkCustomizedUnitParticleTriggers() {
|
||||
if(currSkill != NULL) {
|
||||
checkCustomizedUnitParticleListTriggers(unitParticleSystems,
|
||||
currSkill->unitParticleSystemTypes,queuedUnitParticleSystemTypes);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::checkCustomizedParticleTriggers(bool force) {
|
||||
// Now check if we have special hp triggered particles
|
||||
//
|
||||
// Now check if we have special pre-exisitng hp triggered particles and
|
||||
// end those that should no longer display
|
||||
//
|
||||
// end s particles
|
||||
if(damageParticleSystems.empty() == false) {
|
||||
for(int i = (int)damageParticleSystems.size()-1; i >= 0; --i) {
|
||||
UnitParticleSystem *ps = damageParticleSystems[i];
|
||||
|
@ -4028,7 +4168,9 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
|||
}
|
||||
}
|
||||
|
||||
// Now check if we have special hp triggered particles
|
||||
//
|
||||
// Now check if we have new special hp triggered particles to display
|
||||
//
|
||||
//start additional particles
|
||||
if(showUnitParticles &&
|
||||
type->damageParticleSystemTypes.empty() == false &&
|
||||
|
@ -4057,6 +4199,8 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
|||
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType(pst);
|
||||
|
||||
pst->setValues(ups);
|
||||
ups->setPos(getCurrVector());
|
||||
ups->setRotation(getRotation());
|
||||
|
@ -4071,6 +4215,8 @@ void Unit::checkCustomizedParticleTriggers(bool force) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkCustomizedUnitParticleTriggers();
|
||||
}
|
||||
|
||||
void Unit::startDamageParticles() {
|
||||
|
@ -4084,6 +4230,8 @@ void Unit::startDamageParticles() {
|
|||
if(pst->getMinmaxEnabled() == false && damageParticleSystemsInUse.find(i) == damageParticleSystemsInUse.end()) {
|
||||
UnitParticleSystem *ups = new UnitParticleSystem(200);
|
||||
ups->setParticleOwner(this);
|
||||
ups->setParticleType(pst);
|
||||
|
||||
pst->setValues(ups);
|
||||
ups->setPos(getCurrVector());
|
||||
ups->setRotation(getRotation());
|
||||
|
|
|
@ -821,7 +821,14 @@ private:
|
|||
void startDamageParticles();
|
||||
|
||||
uint32 getFrameCount() const;
|
||||
|
||||
void checkCustomizedParticleTriggers(bool force);
|
||||
void checkCustomizedUnitParticleTriggers();
|
||||
void checkCustomizedUnitParticleListTriggers(vector<UnitParticleSystem*> &unitParticleSystemsList,
|
||||
const UnitParticleSystemTypes &unitParticleSystemTypesList,
|
||||
vector<UnitParticleSystemType*> &queuedUnitParticleSystemTypesList);
|
||||
|
||||
|
||||
bool checkModelStateInfoForNewHpValue();
|
||||
void checkUnitLevel();
|
||||
|
||||
|
|
|
@ -533,9 +533,21 @@ void SkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
|
|||
unitParticleSystemType->setEndTime(particleNode->getAttribute("end-time")->getFloatValue());
|
||||
}
|
||||
|
||||
if(particleNode->getChild(i)->hasAttribute("minHp") && particleNode->getChild(i)->hasAttribute("maxHp")) {
|
||||
unitParticleSystemType->setMinmaxEnabled(true);
|
||||
unitParticleSystemType->setMinHp(particleNode->getChild(i)->getAttribute("minHp")->getIntValue());
|
||||
unitParticleSystemType->setMaxHp(particleNode->getChild(i)->getAttribute("maxHp")->getIntValue());
|
||||
|
||||
if(particleNode->getChild(i)->hasAttribute("ispercentbased")) {
|
||||
unitParticleSystemType->setMinmaxIsPercent(particleNode->getChild(i)->getAttribute("ispercentbased")->getBoolValue());
|
||||
}
|
||||
}
|
||||
|
||||
loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleFileNode->getAttribute("path")->getRestrictedValue()));
|
||||
unitParticleSystemTypes.push_back(unitParticleSystemType);
|
||||
}
|
||||
|
||||
//printf("Load skill particles line: %d size: %d\n",__LINE__,(int)unitParticleSystemTypes.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
public:
|
||||
Particle() {
|
||||
speedUpRelative = 0;
|
||||
size = 0;
|
||||
energy = 0;
|
||||
}
|
||||
|
@ -93,6 +94,20 @@ public:
|
|||
virtual void logParticleInfo(string info)= 0;
|
||||
};
|
||||
|
||||
|
||||
class ParticleSystemTypeInterface {
|
||||
public:
|
||||
|
||||
ParticleSystemTypeInterface() {};
|
||||
virtual ~ParticleSystemTypeInterface() {};
|
||||
|
||||
virtual bool getMinmaxEnabled() const = 0;
|
||||
virtual int getMinHp() const = 0;
|
||||
virtual int getMaxHp() const = 0;
|
||||
virtual bool getMinmaxIsPercent() const = 0;
|
||||
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ParticleSystem
|
||||
// =====================================================
|
||||
|
@ -344,12 +359,15 @@ private:
|
|||
float startTime;
|
||||
float endTime;
|
||||
|
||||
ParticleSystemTypeInterface *particleSystemType;
|
||||
|
||||
public:
|
||||
enum Shape{
|
||||
sLinear, // generated in a sphere, flying in direction
|
||||
sSpherical, // generated in a sphere, flying away from center
|
||||
sConical, // generated in a cone at angle from direction
|
||||
};
|
||||
|
||||
bool relative;
|
||||
bool relativeDirection;
|
||||
bool fixed;
|
||||
|
@ -376,6 +394,13 @@ public:
|
|||
|
||||
virtual ParticleSystemType getParticleSystemType() const { return pst_UnitParticleSystem;}
|
||||
|
||||
ParticleSystemTypeInterface * getParticleType() const {
|
||||
return particleSystemType;
|
||||
}
|
||||
void setParticleType(ParticleSystemTypeInterface *type) {
|
||||
particleSystemType = type;
|
||||
}
|
||||
|
||||
//virtual
|
||||
virtual void initParticle(Particle *p, int particleIndex);
|
||||
virtual void updateParticle(Particle *p);
|
||||
|
|
|
@ -1009,6 +1009,8 @@ Vec3f UnitParticleSystem::lightColor=Vec3f(1.0f,1.0f,1.0f);
|
|||
|
||||
UnitParticleSystem::UnitParticleSystem(int particleCount) :
|
||||
GameParticleSystem(particleCount), parent(NULL) {
|
||||
|
||||
particleSystemType = NULL;
|
||||
radius= 0.5f;
|
||||
speed= 0.01f;
|
||||
windSpeed= Vec3f(0.0f);
|
||||
|
|
Loading…
Reference in New Issue