generated from vorlac/godot-roguelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.hpp
57 lines (45 loc) · 1.61 KB
/
level.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <atomic>
#include <vector>
#include <godot_cpp/classes/node2d.hpp>
#include <godot_cpp/classes/sprite2d.hpp>
#include "core/constants.hpp"
#include "entity/character/player.hpp"
#include "entity/controller/player_controller.hpp"
#include "entity/projectile/projectile_spawner.hpp"
#include "util/bind.hpp"
#include "util/scene.hpp"
namespace godot
{
class RigidBody2D;
}
namespace rl
{
class Player;
class Level : public godot::Node2D
{
GDCLASS(Level, godot::Node2D);
public:
Level();
~Level() = default;
virtual void _ready() override;
void _draw() override;
void _process(double delta_time) override;
void activate(bool active = true);
bool active() const;
protected:
static void _bind_methods();
[[signal_slot]] void on_physics_box_entered(godot::Node* node) const;
[[signal_slot]] void on_physics_box_exited(godot::Node* node) const;
[[signal_slot]] void on_player_spawn_projectile(godot::Node* obj);
[[signal_slot]] void on_character_position_changed(const godot::Object* const obj,
godot::Vector2 location) const;
private:
std::atomic<bool> m_active{ false };
godot::Node* m_background{ nullptr };
ProjectileSpawner* m_projectile_spawner{ memnew(rl::ProjectileSpawner) };
resource::preload::scene<Player> player_scene{ path::scene::Player };
Player* m_player{ player_scene.instantiate(memnew(PlayerController)) };
godot::RigidBody2D* m_physics_box{ nullptr };
};
}