]> git.lizzy.rs Git - dragonfireclient.git/blob - src/particles.h
Use player:set_hotbar_image() instead of hardcoded hotbar.png
[dragonfireclient.git] / src / particles.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef PARTICLES_HEADER
21 #define PARTICLES_HEADER
22
23 #define DIGGING_PARTICLES_AMOUNT 10
24
25 #include <iostream>
26 #include "irrlichttypes_extrabloated.h"
27 #include "tile.h"
28 #include "localplayer.h"
29 #include "environment.h"
30
31 class Particle : public scene::ISceneNode
32 {
33         public:
34         Particle(
35                 IGameDef* gamedef,
36                 scene::ISceneManager* mgr,
37                 LocalPlayer *player,
38                 ClientEnvironment &env,
39                 v3f pos,
40                 v3f velocity,
41                 v3f acceleration,
42                 float expirationtime,
43                 float size,
44                 bool collisiondetection,
45                 video::ITexture *texture,
46                 v2f texpos,
47                 v2f texsize
48         );
49         ~Particle();
50
51         virtual const core::aabbox3d<f32>& getBoundingBox() const
52         {
53                 return m_box;
54         }
55
56         virtual u32 getMaterialCount() const
57         {
58                 return 1;
59         }
60
61         virtual video::SMaterial& getMaterial(u32 i)
62         {
63                 return m_material;
64         }
65
66         virtual void OnRegisterSceneNode();
67         virtual void render();
68
69         void step(float dtime, ClientEnvironment &env);
70
71         bool get_expired ()
72         { return m_expiration < m_time; }
73
74 private:
75         void updateLight(ClientEnvironment &env);
76         void updateVertices();
77
78         video::S3DVertex m_vertices[4];
79         float m_time;
80         float m_expiration;
81
82         IGameDef *m_gamedef;
83         core::aabbox3d<f32> m_box;
84         core::aabbox3d<f32> m_collisionbox;
85         video::SMaterial m_material;
86         v2f m_texpos;
87         v2f m_texsize;
88         v3f m_pos;
89         v3f m_velocity;
90         v3f m_acceleration;
91         LocalPlayer *m_player;
92         float m_size;
93         u8 m_light;
94         bool m_collisiondetection;
95 };
96
97 class ParticleSpawner
98 {
99         public:
100         ParticleSpawner(IGameDef* gamedef,
101                 scene::ISceneManager *smgr,
102                 LocalPlayer *player,
103                 u16 amount,
104                 float time,
105                 v3f minp, v3f maxp,
106                 v3f minvel, v3f maxvel,
107                 v3f minacc, v3f maxacc,
108                 float minexptime, float maxexptime,
109                 float minsize, float maxsize,
110                 bool collisiondetection,
111                 video::ITexture *texture,
112                 u32 id);
113
114         ~ParticleSpawner();
115
116         void step(float dtime, ClientEnvironment &env);
117
118         bool get_expired ()
119         { return (m_amount <= 0) && m_spawntime != 0; }
120
121         private:
122         float m_time;
123         IGameDef *m_gamedef;
124         scene::ISceneManager *m_smgr;
125         LocalPlayer *m_player;
126         u16 m_amount;
127         float m_spawntime;
128         v3f m_minpos;
129         v3f m_maxpos;
130         v3f m_minvel;
131         v3f m_maxvel;
132         v3f m_minacc;
133         v3f m_maxacc;
134         float m_minexptime;
135         float m_maxexptime;
136         float m_minsize;
137         float m_maxsize;
138         video::ITexture *m_texture;
139         std::vector<float> m_spawntimes;
140         bool m_collisiondetection;
141 };
142
143 void allparticles_step (float dtime, ClientEnvironment &env);
144 void allparticlespawners_step (float dtime, ClientEnvironment &env);
145
146 void delete_particlespawner (u32 id);
147 void clear_particles ();
148
149 void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
150         LocalPlayer *player, ClientEnvironment &env, v3s16 pos,
151         const TileSpec tiles[]);
152
153 void addPunchingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
154         LocalPlayer *player, ClientEnvironment &env, v3s16 pos,
155         const TileSpec tiles[]);
156
157 void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr,
158         LocalPlayer *player, ClientEnvironment &env, v3s16 pos,
159         const TileSpec tiles[]);
160
161 #endif