OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
globaleffects.h
Go to the documentation of this file.
1#pragma once
2
3#include <Tempest/Matrix4x4>
4#include <Tempest/Painter>
5#include <Tempest/Texture2d>
6
7#include <vector>
8#include <memory>
9#include <cstdint>
10
11class World;
12class VisualFx;
13class GlobalFx;
14
16 public:
17 GlobalEffects(World& owner);
18
19 void tick(uint64_t dt);
20 GlobalFx startEffect(std::string_view what, uint64_t len, const std::string* argv, size_t argc);
21 void stopEffect (const VisualFx& vfx);
22
23 void scaleTime(uint64_t& dt);
24 void morph(Tempest::Matrix4x4& proj);
25 void scrBlend(Tempest::Painter& p, const Tempest::Rect& rect);
26
27 private:
28 struct Effect {
29 virtual ~Effect(){}
30 virtual void stop();
31 uint64_t timeUntil = 0;
32 uint64_t timeStart = 0;
33 uint64_t timeLen = 0;
34 uint64_t timeLoop = 0;
35 };
36
37 struct SlowTime:Effect {
38 // world time scaler
39 uint64_t mul = 0;
40 uint64_t div = 0;
41 // TODO: player time scaler
42 };
43
44 struct ScreenBlend:Effect {
45 float loop = 0; // screenblend loop duration
46 Tempest::Color cl = {1,1,1,1}; // screenblend color
47 float inout = 0; // screenblend in/out duration
48 std::vector<const Tempest::Texture2d*> frames; // screenblend texture
49 size_t fps = 1; // tex ani fps
50 };
51
52 struct Morph:Effect {
53 float amplitude = 1; // fov morph amplitude scaler
54 float speed = 1; // fov morph speed scaler
55 float baseX = 0; // fov base x (leave empty for default)
56 float baseY = 0; // fov base y (leave empty for default)
57 };
58
59 struct Quake:Effect {
60 };
61
62 template<class T>
63 void tick(uint64_t dt, std::vector<T>& eff);
64
65 GlobalFx create (std::string_view what, const std::string* argv, size_t argc);
66 GlobalFx addSlowTime (const std::string* argv, size_t argc);
67 GlobalFx addScreenBlend(const std::string* argv, size_t argc);
68 GlobalFx addMorphFov (const std::string* argv, size_t argc);
69 GlobalFx addEarthQuake (const std::string* argv, size_t argc);
70
71
72 static Tempest::Color parseColor(std::string_view c);
73
74 World& owner;
75 uint64_t timeWrldRem = 0;
76
77 std::vector<std::shared_ptr<SlowTime>> timeEff;
78 std::vector<std::shared_ptr<ScreenBlend>> scrEff;
79 std::vector<std::shared_ptr<Morph>> morphEff;
80 std::vector<std::shared_ptr<Quake>> quakeEff;
81 friend class GlobalFx;
82 };
83
void scrBlend(Tempest::Painter &p, const Tempest::Rect &rect)
void tick(uint64_t dt)
void scaleTime(uint64_t &dt)
void stopEffect(const VisualFx &vfx)
GlobalFx startEffect(std::string_view what, uint64_t len, const std::string *argv, size_t argc)
void morph(Tempest::Matrix4x4 &proj)
Definition world.h:31