Translated using Weblate (Lithuanian)
[oweals/minetest.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 #pragma once
21
22 #include <string>
23 #include "irrlichttypes_bloated.h"
24 #include "tileanimation.h"
25 #include "mapnode.h"
26
27 // This file defines the particle-related structures that both the server and
28 // client need. The ParticleManager and rendering is in client/particles.h
29
30 struct CommonParticleParams {
31         bool collisiondetection = false;
32         bool collision_removal = false;
33         bool object_collision = false;
34         bool vertical = false;
35         std::string texture;
36         struct TileAnimationParams animation;
37         u8 glow = 0;
38         MapNode node;
39         u8 node_tile = 0;
40
41         CommonParticleParams() {
42                 animation.type = TAT_NONE;
43                 node.setContent(CONTENT_IGNORE);
44         }
45
46         /* This helper is useful for copying params from
47          * ParticleSpawnerParameters to ParticleParameters */
48         inline void copyCommon(CommonParticleParams &to) const {
49                 to.collisiondetection = collisiondetection;
50                 to.collision_removal = collision_removal;
51                 to.object_collision = object_collision;
52                 to.vertical = vertical;
53                 to.texture = texture;
54                 to.animation = animation;
55                 to.glow = glow;
56                 to.node = node;
57                 to.node_tile = node_tile;
58         }
59 };
60
61 struct ParticleParameters : CommonParticleParams {
62         v3f pos;
63         v3f vel;
64         v3f acc;
65         f32 expirationtime = 1;
66         f32 size = 1;
67
68         void serialize(std::ostream &os, u16 protocol_ver) const;
69         void deSerialize(std::istream &is, u16 protocol_ver);
70 };
71
72 struct ParticleSpawnerParameters : CommonParticleParams {
73         u16 amount = 1;
74         v3f minpos, maxpos, minvel, maxvel, minacc, maxacc;
75         f32 time = 1;
76         f32 minexptime = 1, maxexptime = 1, minsize = 1, maxsize = 1;
77
78         // For historical reasons no (de-)serialization methods here
79 };