Otclient
14/8/2020
particleeffect.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#include "
particleeffect.h
"
24
25
ParticleEffectType::ParticleEffectType
()
26
{
27
28
}
29
30
void
ParticleEffectType::load
(
const
OTMLNodePtr
& node)
31
{
32
m_node = node->
clone
();
33
for
(
const
OTMLNodePtr
& childNode : node->
children
()) {
34
if
(childNode->tag() ==
"name"
)
35
m_name = childNode->value();
36
else
if
(childNode->tag() ==
"description"
)
37
m_description = childNode->value();
38
}
39
}
40
41
void
ParticleEffect::load
(
const
ParticleEffectTypePtr
& effectType)
42
{
43
if
(!effectType)
44
stdext::throw_exception
(
"effect type not found"
);
45
46
for
(
const
OTMLNodePtr
& childNode : effectType->getNode()->children()) {
47
if
(childNode->tag() ==
"System"
) {
48
ParticleSystemPtr
system =
ParticleSystemPtr
(
new
ParticleSystem
);
49
system->load(childNode);
50
m_systems.push_back(system);
51
}
52
}
53
}
54
55
void
ParticleEffect::render
()
56
{
57
for
(
auto
&system: m_systems)
58
system->render();
59
}
60
61
void
ParticleEffect::update
()
62
{
63
for
(
auto
it = m_systems.begin(); it != m_systems.end();) {
64
const
ParticleSystemPtr
& system = *it;
65
66
if
(system->hasFinished()) {
67
it = m_systems.erase(it);
68
}
else
{
69
system->update();
70
++it;
71
}
72
}
73
}
ParticleEffectType::ParticleEffectType
ParticleEffectType()
Definition:
particleeffect.cpp:25
ParticleEffect::render
void render()
Definition:
particleeffect.cpp:55
OTMLNode::children
OTMLNodeList children()
Definition:
otmlnode.cpp:170
ParticleEffectType::load
void load(const OTMLNodePtr &node)
Definition:
particleeffect.cpp:30
ParticleEffect::load
void load(const ParticleEffectTypePtr &effectType)
Definition:
particleeffect.cpp:41
particleeffect.h
OTMLNode::clone
OTMLNodePtr clone()
Definition:
otmlnode.cpp:179
ParticleSystemPtr
stdext::shared_object_ptr< ParticleSystem > ParticleSystemPtr
Definition:
declarations.h:61
stdext::throw_exception
void throw_exception(const std::string &what)
Throws a generic exception.
Definition:
exception.h:43
stdext::shared_object_ptr< OTMLNode >
ParticleSystem
Definition:
particlesystem.h:31
ParticleEffect::update
void update()
Definition:
particleeffect.cpp:61
src
framework
graphics
particleeffect.cpp
Generated by
1.8.17
For more information visit
https://forum.opentibia.dev/