File: particle_type.h

package info (click to toggle)
megaglest 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,904 kB
  • ctags: 18,215
  • sloc: cpp: 144,232; ansic: 11,860; sh: 2,949; perl: 1,899; python: 1,751; objc: 142; asm: 42; makefile: 24
file content (168 lines) | stat: -rw-r--r-- 4,816 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// ==============================================================
//	This file is part of Glest (www.glest.org)
//
//	Copyright (C) 2001-2008 MartiƱo Figueroa
//
//	You can redistribute this code and/or modify it under 
//	the terms of the GNU General Public License as published 
//	by the Free Software Foundation; either version 2 of the 
//	License, or (at your option) any later version
// ==============================================================

#ifndef _GLEST_GAME_PARTICLETYPE_H_
#define _GLEST_GAME_PARTICLETYPE_H_

#ifdef WIN32
    #include <winsock2.h>
    #include <winsock.h>
#endif

#include <string>
#include <list>
#include "particle.h"
#include "factory.h"
#include "texture.h"
#include "vec.h"
#include "xml_parser.h"
#include "graphics_interface.h"
#include "leak_dumper.h"

using std::string;
using namespace Shared::Graphics;

namespace Glest{ namespace Game{

using Shared::Graphics::ParticleSystem;
using Shared::Graphics::UnitParticleSystem;
using Shared::Graphics::AttackParticleSystem;
using Shared::Graphics::ProjectileParticleSystem;
using Shared::Graphics::SplashParticleSystem;
using Shared::Graphics::Texture2D;
using Shared::Graphics::Vec3f;
using Shared::Graphics::Vec4f;
using Shared::Graphics::Model;
using Shared::Util::MultiFactory;
using Shared::Xml::XmlNode;

class UnitParticleSystemType;

// ===========================================================
//	class ParticleSystemType 
//
///	A type of particle system
// ===========================================================

class ParticleSystemType : public ParticleSystemTypeInterface {
protected:
	string type;
	Texture2D *texture;
	Model *model;
	float modelCycle;
	string primitive;
	Vec3f offset;
	Vec4f color;
	Vec4f colorNoEnergy;
	float size;
	float sizeNoEnergy;
	float speed;
	float speedUpRelative;
	float speedUpConstant;
	float gravity;
	float emissionRate;
	int energyMax;
	int energyVar;
	string mode;
	bool teamcolorNoEnergy;
    bool teamcolorEnergy;
    int alternations;
    int particleSystemStartDelay;
	typedef std::list<UnitParticleSystemType*> Children;
	Children children;

    bool minmaxEnabled;
    int minHp;
    int maxHp;
    bool minmaxIsPercent;

    void copyAll(const ParticleSystemType &src);
public:

    ParticleSystemType();
	virtual ~ParticleSystemType();

	ParticleSystemType & operator=(const ParticleSystemType &src);
	ParticleSystemType(const ParticleSystemType &src);

	void load(const XmlNode *particleSystemNode, const string &dir,
			RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
			string parentLoader, string techtreePath);
	void setValues(AttackParticleSystem *ats);
	bool hasTexture() const { return(texture != NULL); }
	bool hasModel() const { return(model != NULL); }

    bool getMinmaxEnabled() const { return minmaxEnabled;}
    int getMinHp() const { return minHp;}
    int getMaxHp() const { return maxHp;}
    bool getMinmaxIsPercent() const { return minmaxIsPercent; }

    void setMinmaxEnabled(bool value) { minmaxEnabled=value;}
    void setMinHp(int value) { minHp=value;}
    void setMaxHp(int value) { maxHp=value;}
    void setMinmaxIsPercent(bool value) { minmaxIsPercent=value; }

    string getType() const { return type; };

    virtual void saveGame(XmlNode *rootNode);
    virtual void loadGame(const XmlNode *rootNode);

protected:

};

// ===========================================================
//	class ParticleSystemTypeProjectile
// ===========================================================

class ParticleSystemTypeProjectile: public ParticleSystemType{
private:
	string trajectory;
	float trajectorySpeed;
	float trajectoryScale;
	float trajectoryFrequency;

public:
	ParticleSystemTypeProjectile();
	void load(const XmlNode *particleFileNode, const string &dir, const string &path,
			RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
			string parentLoader, string techtreePath);
	ProjectileParticleSystem *create(ParticleOwner *owner);

	virtual void saveGame(XmlNode *rootNode);
};

// ===========================================================
//	class ParticleSystemTypeSplash
// ===========================================================

class ParticleSystemTypeSplash: public ParticleSystemType {
public:

	ParticleSystemTypeSplash();
	void load(const XmlNode *particleFileNode, const string &dir, const string &path,
			RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
			string parentLoader, string techtreePath);
	SplashParticleSystem *create(ParticleOwner *owner);

	virtual void saveGame(XmlNode *rootNode);

private:
	float emissionRateFade;
	float verticalSpreadA;
	float verticalSpreadB;
	float horizontalSpreadA;
	float horizontalSpreadB;
};

}}//end namespace

#endif