KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
map.hpp
1/*
2 KTech, Kaup's C++ 2D terminal game engine library.
3 Copyright (C) 2023-2025 Ethan Kaufman (AKA Kaup)
4
5 This file is part of KTech.
6
7 KTech is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 any later version.
11
12 KTech is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with KTech. If not, see <https://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23#define KTECH_DEFINITION
24#include "../ktech.hpp"
25#undef KTECH_DEFINITION
26#include "../utility/id.hpp"
27
28#include <string>
29#include <vector>
30
35{
36public:
39 std::string m_name;
40 std::vector<ID<Camera>> m_cameras = {};
41 std::vector<ID<Layer>> m_layers = {};
42
43 Map(Engine& engine, std::string name = "");
44 virtual ~Map();
45
46 auto AddLayer(const ID<Layer>& layer) -> bool;
47 auto AddCamera(const ID<Camera>& camera) -> bool;
48
49 auto RemoveLayer(const ID<Layer>& layer) -> bool;
50 auto RemoveCamera(const ID<Camera>& camera) -> bool;
51 auto RemoveAllLayers() -> bool;
52 auto RemoveAllCameras() -> bool;
53
54protected:
55 virtual auto OnTick() -> bool;
56
57 friend class KTech::Memory;
58};
Complete engine containing all engine components.
Definition engine.hpp:41
World structure that contains Layers and Cameras.
Definition map.hpp:35
std::string m_name
String name.
Definition map.hpp:39
std::vector< ID< Camera > > m_cameras
Contained Cameras.
Definition map.hpp:40
auto AddCamera(const ID< Camera > &camera) -> bool
Add a Camera.
Definition map.cpp:82
auto RemoveAllCameras() -> bool
Remove all contained Cameras.
Definition map.cpp:171
virtual auto OnTick() -> bool
Virtual function called once each tick.
Definition map.cpp:200
std::vector< ID< Layer > > m_layers
Contained Layers.
Definition map.hpp:41
auto RemoveLayer(const ID< Layer > &layer) -> bool
Remove a Layer.
Definition map.cpp:106
auto RemoveCamera(const ID< Camera > &camera) -> bool
Remove a Camera.
Definition map.cpp:129
virtual ~Map()
Remove all Layers and Cameras, then remove itself from Memory.
Definition map.cpp:44
auto RemoveAllLayers() -> bool
Remove all contained Layers.
Definition map.cpp:150
Map(Engine &engine, std::string name="")
Construct a Map.
Definition map.cpp:35
auto AddLayer(const ID< Layer > &layer) -> bool
Add a Layer.
Definition map.cpp:58
const ID< Map > m_id
Personal ID.
Definition map.hpp:38
Engine & engine
Parent Engine.
Definition map.hpp:37
Engine component responsible for registering all world structures.
Definition memory.hpp:36
Serializable world structure identifier.
Definition id.hpp:38