mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 10:49:48 +02:00
particles for ressouces ... the gold will glow tomorrow :-D
This commit is contained in:
@@ -68,7 +68,7 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
|
||||
fixed= fixedNode->getAttribute("value")->getBoolValue();
|
||||
}
|
||||
|
||||
void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
||||
const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
|
||||
ups->setTexture(texture);
|
||||
ups->setPrimitive(UnitParticleSystem::strToPrimitive(primitive));
|
||||
ups->setOffset(offset);
|
||||
|
@@ -55,7 +55,7 @@ protected:
|
||||
public:
|
||||
void load(const XmlNode *particleSystemNode, const string &dir, RendererInterface *newTexture);
|
||||
void load(const string &dir, const string &path, RendererInterface *newTexture);
|
||||
void setValues(UnitParticleSystem *uts);
|
||||
const void setValues (UnitParticleSystem *uts);
|
||||
bool hasTexture() const { return(texture != NULL); }
|
||||
};
|
||||
|
||||
|
@@ -81,6 +81,11 @@ void Object::initParticles(){
|
||||
if(this->objectType==NULL) return;
|
||||
if(this->objectType->hasParticles()){
|
||||
ObjectParticleSystemTypes *particleTypes= this->objectType->getObjectParticleSystemTypes(variation);
|
||||
initParticlesFromTypes(particleTypes);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::initParticlesFromTypes(const ObjectParticleSystemTypes *particleTypes){
|
||||
if(Config::getInstance().getBool("TilesetParticles","true") && (particleTypes->empty() == false)
|
||||
&& (unitParticleSystems.empty() == true)){
|
||||
for(ObjectParticleSystemTypes::const_iterator it= particleTypes->begin(); it != particleTypes->end(); ++it){
|
||||
@@ -94,9 +99,9 @@ void Object::initParticles(){
|
||||
Renderer::getInstance().manageParticleSystem(ups, rsGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Object::setHeight(float height){
|
||||
pos.y=height;
|
||||
|
||||
@@ -120,6 +125,7 @@ bool Object::getWalkable() const{
|
||||
void Object::setResource(const ResourceType *resourceType, const Vec2i &pos){
|
||||
resource= new Resource();
|
||||
resource->init(resourceType, pos);
|
||||
initParticlesFromTypes(resourceType->getObjectParticleSystemTypes());
|
||||
}
|
||||
|
||||
void Object::setVisible( bool visible)
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "vec.h"
|
||||
#include "leak_dumper.h"
|
||||
#include "particle.h"
|
||||
#include "object_type.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
@@ -63,6 +64,7 @@ public:
|
||||
|
||||
void end(); //to kill particles
|
||||
void initParticles();
|
||||
void initParticlesFromTypes(const ObjectParticleSystemTypes *particleTypes);
|
||||
static void setStateCallback(ObjectStateInterface *value) { stateCallback=value; }
|
||||
|
||||
const ObjectType *getType() const {return objectType;}
|
||||
|
@@ -38,6 +38,13 @@ ResourceType::ResourceType() {
|
||||
model = NULL;
|
||||
}
|
||||
|
||||
ResourceType::~ResourceType(){
|
||||
while(!(particleTypes.empty())){
|
||||
delete particleTypes.back();
|
||||
particleTypes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum) {
|
||||
|
||||
string path, str;
|
||||
@@ -79,6 +86,21 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
||||
model= renderer.newModel(rsGame);
|
||||
model->load(path);
|
||||
|
||||
if(modelNode->hasChild("particles")){
|
||||
const XmlNode *particleNode= modelNode->getChild("particles");
|
||||
bool particleEnabled= particleNode->getAttribute("value")->getBoolValue();
|
||||
if(particleEnabled){
|
||||
for(int k= 0; k < particleNode->getChildCount(); ++k){
|
||||
const XmlNode *particleFileNode= particleNode->getChild("particle-file", k);
|
||||
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
||||
|
||||
ObjectParticleSystemType *objectParticleSystemType= new ObjectParticleSystemType();
|
||||
objectParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
||||
particleTypes.push_back(objectParticleSystemType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//default resources
|
||||
const XmlNode *defaultAmountNode= typeNode->getChild("default-amount");
|
||||
defResPerPatch= defaultAmountNode->getAttribute("value")->getIntValue();
|
||||
@@ -134,7 +156,6 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==================== misc ====================
|
||||
|
||||
ResourceClass ResourceType::strToRc(const string &s){
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include "model.h"
|
||||
#include "checksum.h"
|
||||
#include "leak_dumper.h"
|
||||
#include "unit_particle_type.h"
|
||||
#include "object_type.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
@@ -35,6 +37,7 @@ enum ResourceClass{
|
||||
/// A type of resource that can be harvested or not
|
||||
// =====================================================
|
||||
|
||||
|
||||
class ResourceType: public DisplayableType{
|
||||
private:
|
||||
ResourceClass resourceClass;
|
||||
@@ -45,9 +48,11 @@ private:
|
||||
bool recoup_cost;
|
||||
|
||||
Model *model;
|
||||
ObjectParticleSystemTypes particleTypes;
|
||||
|
||||
public:
|
||||
ResourceType();
|
||||
~ResourceType();
|
||||
void load(const string &dir, Checksum* checksum,Checksum *techtreeChecksum);
|
||||
|
||||
//get
|
||||
@@ -59,6 +64,10 @@ public:
|
||||
Model *getModel() const {return model;}
|
||||
bool getRecoup_cost() const { return recoup_cost;}
|
||||
|
||||
bool hasParticles() const {return !particleTypes.empty();}
|
||||
const ObjectParticleSystemTypes *getObjectParticleSystemTypes() const {return &particleTypes;}
|
||||
|
||||
|
||||
static ResourceClass strToRc(const string &s);
|
||||
void deletePixels();
|
||||
};
|
||||
|
Reference in New Issue
Block a user