OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
effect.h
Go to the documentation of this file.
1#pragma once
2
8#include "graphics/visualfx.h"
9
10#include "game/constants.h"
11
12#include <memory>
13
14class World;
15class Npc;
16class Pose;
17class Skeleton;
18
19class Effect final {
20 public:
21 Effect() = default;
22 Effect(Effect&&) = default;
23 Effect(PfxEmitter&& pfx, std::string_view node);
24 Effect(const VisualFx& vfx, World& owner, const Npc& src, SpellFxKey key = SpellFxKey::Count);
25 Effect(const VisualFx& vfx, World& owner, const Tempest::Vec3& pos, SpellFxKey key = SpellFxKey::Count);
26 ~Effect();
27
28 Effect& operator = (Effect&&) = default;
29 bool is(const VisualFx& vfx) const;
30 const VisualFx* handle() const { return root; }
31
32 void tick(uint64_t dt);
33
34 void setActive(bool e);
35 void setLooped(bool l);
36
37 void setTarget (const Npc* npc);
38 void setOrigin (Npc* npc);
39
40 void setObjMatrix(const Tempest::Matrix4x4& mt);
41 void setKey (World& owner, SpellFxKey key, int32_t keyLvl=0);
42 void setMesh (const MeshObjects::Mesh* mesh);
43 void setBullet (Bullet* b, World& owner);
44 void setSpellId (int32_t splId, World& owner);
45
46 uint64_t effectPrefferedTime() const;
47 bool isAlive() const;
48 void setPhysicsDisable();
49
50 void bindAttaches (const Pose& pose, const Skeleton& to);
51 static void onCollide (World& owner, const VisualFx* root, const Tempest::Vec3& pos, Npc* npc, Npc* other, int32_t splId);
52
53 private:
54 void syncAttaches(const Tempest::Matrix4x4& pos);
55 void syncAttachesSingle(const Tempest::Matrix4x4& inPos);
56 void setupLight(World& owner);
57 void setupPfx(World& owner);
58 void setupSfx(World& owner);
59 void setupCollision(World& owner);
60
61 const VisualFx::Key* key = nullptr;
62 const VisualFx* root = nullptr;
63
64 PfxEmitter pfx;
65 Sound sfx;
66 GlobalFx gfx;
68
69 Npc* origin = nullptr;
70 const Npc* target = nullptr;
71
72 Bullet* bullet = nullptr;
73 int32_t splId = 0;
74
75 std::string_view nodeSlot;
76 size_t boneId = size_t(-1);
77 const Skeleton* skeleton = nullptr;
78 const Pose* pose = nullptr;
79
80 const MeshObjects::Mesh* meshEmitter = nullptr;
81
82 Tempest::Matrix4x4 pos;
83 Tempest::Vec3 selfRotation;
84
85 bool active = false;
86 bool looped = false;
87 bool noPhysics = false;
88
89 std::unique_ptr<Effect> next;
90 };
91
void setMesh(const MeshObjects::Mesh *mesh)
Definition effect.cpp:242
void setActive(bool e)
Definition effect.cpp:115
const VisualFx * handle() const
Definition effect.h:30
void setTarget(const Npc *npc)
Definition effect.cpp:132
Effect(const VisualFx &vfx, World &owner, const Tempest::Vec3 &pos, SpellFxKey key=SpellFxKey::Count)
static void onCollide(World &owner, const VisualFx *root, const Tempest::Vec3 &pos, Npc *npc, Npc *other, int32_t splId)
Definition effect.cpp:301
void tick(uint64_t dt)
Definition effect.cpp:99
void bindAttaches(const Pose &pose, const Skeleton &to)
Definition effect.cpp:286
bool is(const VisualFx &vfx) const
Definition effect.cpp:95
void setOrigin(Npc *npc)
Definition effect.cpp:140
void setKey(World &owner, SpellFxKey key, int32_t keyLvl=0)
Definition effect.cpp:209
bool isAlive() const
Definition effect.cpp:275
Effect & operator=(Effect &&)=default
uint64_t effectPrefferedTime() const
Definition effect.cpp:264
Effect()=default
void setLooped(bool l)
Definition effect.cpp:123
void setObjMatrix(const Tempest::Matrix4x4 &mt)
Definition effect.cpp:148
~Effect()
Definition effect.cpp:30
void setBullet(Bullet *b, World &owner)
Definition effect.cpp:250
void setPhysicsDisable()
Definition effect.cpp:281
void setSpellId(int32_t splId, World &owner)
Definition effect.cpp:257
Effect(Effect &&)=default
Definition npc.h:25
Definition pose.h:16
Definition sound.h:5
Definition world.h:31
SpellFxKey
Definition constants.h:268