OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
abstracttrigger.h
Go to the documentation of this file.
1#pragma once
2
3#include <zenkit/vobs/Misc.hh>
4#include <zenkit/vobs/Trigger.hh>
5#include <string>
6
7#include "world/objects/vob.h"
10
11class Npc;
12class World;
13
14class TriggerEvent final {
15 public:
27
28 TriggerEvent()=default;
29 TriggerEvent(std::string target, std::string emitter, Type type):target(std::move(target)), emitter(std::move(emitter)), type(type){}
30 TriggerEvent(std::string target, std::string emitter, uint64_t t, Type type)
32
33 void save(Serialize& fout) const;
34 void load(Serialize &fin);
35
36 std::string target;
37 std::string emitter;
39 uint64_t timeBarrier = 0;
40 struct {
41 zenkit::MoverMessageType msg = zenkit::MoverMessageType::FIXED_DIRECT;
42 int32_t key = 0;
44 };
45
46class AbstractTrigger : public Vob {
47 public:
48 AbstractTrigger(Vob* parent, World& world, const zenkit::VirtualObject& data, Flags flags);
49 virtual ~AbstractTrigger();
50
51 std::string_view name() const;
52 bool isEnabled() const;
53 bool hasDelayedEvents() const;
54
56 void processEvent(const TriggerEvent& evt);
57 virtual void onIntersect(Npc& n);
58 virtual void tick(uint64_t dt);
59
60 void save(Serialize& fout) const override;
61 void load(Serialize &fin) override;
62
63 protected:
69
70 virtual void onTrigger(const TriggerEvent& evt);
71 virtual void onUntrigger(const TriggerEvent& evt);
72 virtual void onGotoMsg(const TriggerEvent& evt);
73 void moveEvent() override;
74
75 bool hasTicksEnabled() const;
76 void enableTicks();
77 void disableTicks();
78 const std::vector<Npc*>& intersections() const;
79
80 void implProcessEvent(const TriggerEvent& evt);
81
82 private:
83 Cb callback;
85 CollisionZone boxNpc;
86 Tempest::Vec3 bboxSize, bboxOrigin;
87
88 uint64_t fireDelay = 0;
89 uint64_t retriggerDelay = 0;
90 uint32_t maxActivationCount = uint32_t(-1);
91 bool sendUntrigger = true;
92 bool reactToOnTrigger = true;
93 bool reactToOnTouch = true;
94 bool respondToNpc = true;
95 bool respondToPlayer = true;
96 bool respondToObject = true;
97
98 uint32_t emitCount = 0;
99 bool disabled = false;
100 uint64_t emitTimeLast = 0;
101
102 TriggerEvent delayedEvent;
103 bool ticksEnabled = false;
104
105 protected:
106 std::string vobName;
107 std::string target;
108 };
const std::vector< Npc * > & intersections() const
void load(Serialize &fin) override
void save(Serialize &fout) const override
std::string vobName
virtual void onTrigger(const TriggerEvent &evt)
bool hasDelayedEvents() const
bool isEnabled() const
void moveEvent() override
virtual void onGotoMsg(const TriggerEvent &evt)
virtual ~AbstractTrigger()
bool hasTicksEnabled() const
virtual void onIntersect(Npc &n)
void implProcessEvent(const TriggerEvent &evt)
void processEvent(const TriggerEvent &evt)
virtual void tick(uint64_t dt)
virtual void onUntrigger(const TriggerEvent &evt)
std::string_view name() const
Definition npc.h:25
TriggerEvent(std::string target, std::string emitter, uint64_t t, Type type)
TriggerEvent()=default
std::string target
void load(Serialize &fin)
std::string emitter
TriggerEvent(std::string target, std::string emitter, Type type)
uint64_t timeBarrier
zenkit::MoverMessageType msg
void save(Serialize &fout) const
struct TriggerEvent::@26 move
Definition vob.h:11
Flags
Definition vob.h:13
World & world
Definition vob.h:45
Definition world.h:31
Cb(AbstractTrigger *tg)
void onCollide(DynamicWorld::BulletBody &other) override
AbstractTrigger * tg