summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scenery-proto.cpp60
-rw-r--r--src/scenery-proto.hpp44
-rw-r--r--src/scenery-type.hpp9
-rw-r--r--src/scenery.cpp55
-rw-r--r--src/scenery.hpp49
-rw-r--r--src/world.cpp1
6 files changed, 119 insertions, 99 deletions
diff --git a/src/scenery-proto.cpp b/src/scenery-proto.cpp
new file mode 100644
index 00000000..6781d84f
--- /dev/null
+++ b/src/scenery-proto.cpp
@@ -0,0 +1,60 @@
+#include "scenery-proto.hpp"
+#include "compat/overloaded.hpp"
+
+namespace floormat {
+
+// ---------- generic_scenery_proto ----------
+
+bool generic_scenery_proto::operator==(const generic_scenery_proto& p) const = default;
+enum scenery_type generic_scenery_proto::scenery_type() { return scenery_type::generic; }
+
+// ---------- door_scenery_proto ----------
+
+bool door_scenery_proto::operator==(const door_scenery_proto& p) const = default;
+enum scenery_type door_scenery_proto::scenery_type() { return scenery_type::door; }
+
+// --- scenery_proto ---
+
+scenery_proto::scenery_proto() noexcept { type = object_type::scenery; }
+scenery_proto::~scenery_proto() noexcept = default;
+scenery_proto::operator bool() const { return atlas != nullptr; }
+
+scenery_proto& scenery_proto::operator=(const scenery_proto&) noexcept = default;
+scenery_proto::scenery_proto(const scenery_proto&) noexcept = default;
+scenery_proto& scenery_proto::operator=(scenery_proto&&) noexcept = default;
+scenery_proto::scenery_proto(scenery_proto&&) noexcept = default;
+
+enum scenery_type scenery_proto::scenery_type() const
+{
+ return std::visit(overloaded {
+ [](std::monostate) { return scenery_type::none; },
+ []<typename T>(const T&) { return T::scenery_type(); },
+ }, subtype
+ );
+}
+
+bool scenery_proto::operator==(const object_proto& e0) const
+{
+ if (type != e0.type)
+ return false;
+
+ if (!object_proto::operator==(e0))
+ return false;
+
+ const auto& sc = static_cast<const scenery_proto&>(e0);
+
+ if (subtype.index() != sc.subtype.index())
+ return false;
+
+ return std::visit(
+ [](const auto& a, const auto& b) -> bool {
+ if constexpr(std::is_same_v<std::decay_t<decltype(a)>, std::decay_t<decltype(b)>>)
+ return a == b;
+ else
+ fm_assert(false);
+ },
+ subtype, sc.subtype
+ );
+}
+
+} // namespace floormat
diff --git a/src/scenery-proto.hpp b/src/scenery-proto.hpp
new file mode 100644
index 00000000..c5889b04
--- /dev/null
+++ b/src/scenery-proto.hpp
@@ -0,0 +1,44 @@
+#pragma once
+#include "scenery-type.hpp"
+#include "object.hpp"
+#include <variant>
+
+namespace floormat {
+
+struct generic_scenery_proto
+{
+ bool active : 1 = false;
+ bool interactive : 1 = false;
+
+ bool operator==(const generic_scenery_proto& p) const;
+ static enum scenery_type scenery_type();
+};
+
+struct door_scenery_proto
+{
+ bool active : 1 = false;
+ bool interactive : 1 = true;
+ bool closing : 1 = false;
+
+ bool operator==(const door_scenery_proto& p) const;
+ static enum scenery_type scenery_type();
+};
+
+using scenery_proto_variants = std::variant<std::monostate, generic_scenery_proto, door_scenery_proto>;
+
+struct scenery_proto : object_proto
+{
+ scenery_proto_variants subtype; // todo! add std::monostate
+
+ scenery_proto() noexcept;
+ ~scenery_proto() noexcept override;
+ explicit operator bool() const;
+ bool operator==(const object_proto& proto) const override;
+ enum scenery_type scenery_type() const;
+ scenery_proto(const scenery_proto&) noexcept;
+ scenery_proto& operator=(const scenery_proto&) noexcept;
+ scenery_proto(scenery_proto&&) noexcept;
+ scenery_proto& operator=(scenery_proto&&) noexcept;
+};
+
+} // namespace floormat
diff --git a/src/scenery-type.hpp b/src/scenery-type.hpp
new file mode 100644
index 00000000..3879e225
--- /dev/null
+++ b/src/scenery-type.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace floormat {
+
+enum class scenery_type : unsigned char {
+ none, generic, door, COUNT,
+};
+
+} // namespace floormat
diff --git a/src/scenery.cpp b/src/scenery.cpp
index e0b62211..442b712c 100644
--- a/src/scenery.cpp
+++ b/src/scenery.cpp
@@ -1,70 +1,17 @@
#include "scenery.hpp"
+#include "scenery-proto.hpp"
#include "compat/assert.hpp"
#include "compat/exception.hpp"
-#include "compat/overloaded.hpp"
#include "tile-constants.hpp"
#include "anim-atlas.hpp"
#include "rotation.inl"
-#include "nanosecond.hpp"
#include "world.hpp"
#include "shaders/shader.hpp"
#include <mg/Functions.h>
namespace floormat {
-// ---------- generic_scenery_proto ----------
-bool generic_scenery_proto::operator==(const generic_scenery_proto& p) const = default;
-enum scenery_type generic_scenery_proto::scenery_type() { return scenery_type::generic; }
-
-// ---------- door_scenery_proto ----------
-
-bool door_scenery_proto::operator==(const door_scenery_proto& p) const = default;
-enum scenery_type door_scenery_proto::scenery_type() { return scenery_type::door; }
-
-// --- scenery_proto ---
-
-scenery_proto::scenery_proto() noexcept { type = object_type::scenery; }
-scenery_proto::~scenery_proto() noexcept = default;
-scenery_proto::operator bool() const { return atlas != nullptr; }
-
-scenery_proto& scenery_proto::operator=(const scenery_proto&) noexcept = default;
-scenery_proto::scenery_proto(const scenery_proto&) noexcept = default;
-scenery_proto& scenery_proto::operator=(scenery_proto&&) noexcept = default;
-scenery_proto::scenery_proto(scenery_proto&&) noexcept = default;
-
-enum scenery_type scenery_proto::scenery_type() const
-{
- return std::visit(overloaded {
- [](std::monostate) { return scenery_type::none; },
- []<typename T>(const T&) { return T::scenery_type(); },
- }, subtype
- );
-}
-
-bool scenery_proto::operator==(const object_proto& e0) const
-{
- if (type != e0.type)
- return false;
-
- if (!object_proto::operator==(e0))
- return false;
-
- const auto& sc = static_cast<const scenery_proto&>(e0);
-
- if (subtype.index() != sc.subtype.index())
- return false;
-
- return std::visit(
- [](const auto& a, const auto& b) -> bool {
- if constexpr(std::is_same_v<std::decay_t<decltype(a)>, std::decay_t<decltype(b)>>)
- return a == b;
- else
- fm_assert(false);
- },
- subtype, sc.subtype
- );
-}
// --- scenery ---
diff --git a/src/scenery.hpp b/src/scenery.hpp
index 8db32f91..6699fe2f 100644
--- a/src/scenery.hpp
+++ b/src/scenery.hpp
@@ -1,56 +1,15 @@
#pragma once
#include "object.hpp"
-#include <variant>
-#include <Magnum/Math/Vector2.h>
-#include <Magnum/Magnum.h>
+#include "scenery-type.hpp"
namespace floormat {
class chunk;
class anim_atlas;
class world;
-
-enum class scenery_type : unsigned char {
- none, generic, door, COUNT,
-};
-
-struct generic_scenery_proto
-{
- bool active : 1 = false;
- bool interactive : 1 = false;
-
- bool operator==(const generic_scenery_proto& p) const;
- static enum scenery_type scenery_type();
-};
-
-struct door_scenery_proto
-{
- bool active : 1 = false;
- bool interactive : 1 = true;
- bool closing : 1 = false;
-
- bool operator==(const door_scenery_proto& p) const;
- static enum scenery_type scenery_type();
-};
-
-using scenery_proto_variants = std::variant<std::monostate, generic_scenery_proto, door_scenery_proto>;
-
-struct scenery_proto : object_proto
-{
- scenery_proto_variants subtype; // todo! add std::monostate
-
- scenery_proto() noexcept;
- ~scenery_proto() noexcept override;
- explicit operator bool() const;
- bool operator==(const object_proto& proto) const override;
- enum scenery_type scenery_type() const;
- scenery_proto(const scenery_proto&) noexcept;
- scenery_proto& operator=(const scenery_proto&) noexcept;
- scenery_proto(scenery_proto&&) noexcept;
- scenery_proto& operator=(scenery_proto&&) noexcept;
-};
-
-struct scenery;
+struct scenery_proto;
+struct generic_scenery_proto;
+struct door_scenery_proto;
struct scenery : object
{
diff --git a/src/world.cpp b/src/world.cpp
index 821e4c65..1012b303 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -3,6 +3,7 @@
#include "object.hpp"
#include "critter.hpp"
#include "scenery.hpp"
+#include "scenery-proto.hpp"
#include "light.hpp"
#include "compat/shared-ptr-wrapper.hpp"
#include "compat/int-hash.hpp"