#pragma once #include "Common.h" #include #include #include #include namespace Feather { // Represents the state data of a particular instance of a Block class BlockState { friend struct std::hash; // PLACEHOLDER std::string_view m_name; std::map m_properties; public: BlockState(std::string_view name) : m_name(name) {} inline const std::string_view GetName() const { return m_name; } inline void AddProperty(std::string_view key, std::string_view value) { m_properties.insert({ key, value }); } inline bool operator ==(const BlockState that) const { if (m_name != that.m_name) return false; for (auto& [key, value] : that.m_properties) { if (!m_properties.contains(key) || m_properties.at(key) != value) return false; } return true; } }; } template <> struct std::hash { size_t operator()(const Feather::BlockState& state) const { using std::hash; using std::string_view; size_t accum = 0; accum += hash()(state.GetName()); // pretty basic hash, sum of all keys and values + block name for (auto& [key, value] : state.m_properties) accum += hash()(key) + hash()(value); return accum; } };