Skip to content

Commit

Permalink
[ISerializable] Moved to GameKit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jun 19, 2020
1 parent 1f7d83b commit afc4918
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 137 deletions.
2 changes: 1 addition & 1 deletion external/gamekit
2 changes: 1 addition & 1 deletion source/common/core/Registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "Tree.hpp"
#include "Sky.hpp"

class Registry : public ISerializable {
class Registry : public gk::ISerializable {
public:
template<typename T>
auto registerBlock(const TilesDef &tiles, const std::string &stringID, const std::string &label) -> typename std::enable_if<std::is_base_of<Block, T>::value, T&>::type {
Expand Down
5 changes: 2 additions & 3 deletions source/common/core/TilesDef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
#include <SFML/Network/Packet.hpp>

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include <sol/sol.hpp>

#include "ISerializable.hpp"

enum BlockFace : u8 {
West = 0,
East = 1,
Expand All @@ -47,7 +46,7 @@ enum BlockFace : u8 {
Top = 5,
};

class TilesDef : public ISerializable {
class TilesDef : public gk::ISerializable {
public:
TilesDef() = default;
TilesDef(const std::string &texture) { m_textureFilenames.emplace_back(texture); }
Expand Down
4 changes: 2 additions & 2 deletions source/common/inventory/Inventory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

#include <vector>

#include <gk/core/ISerializable.hpp>
#include <gk/core/Vector3.hpp>

#include "ItemStack.hpp"
#include "ISerializable.hpp"

class Inventory : public ISerializable {
class Inventory : public gk::ISerializable {
public:
Inventory() = default;
Inventory(u16 width, u16 height, const std::string &name = "")
Expand Down
4 changes: 2 additions & 2 deletions source/common/inventory/Item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
#include <string>

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include "ItemType.hpp"
#include "ISerializable.hpp"
#include "TilesDef.hpp"

class Item : public ISerializable {
class Item : public gk::ISerializable {
public:
Item() = default;
Item(u32 id, const TilesDef &tiles, const std::string &stringID, const std::string &label);
Expand Down
7 changes: 3 additions & 4 deletions source/common/inventory/Recipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
#ifndef RECIPE_HPP_
#define RECIPE_HPP_

#include "Inventory.hpp"
#include "ISerializable.hpp"
#include <gk/core/ISerializable.hpp>

namespace sf { class Packet; }
#include "Inventory.hpp"

class Recipe : public ISerializable {
class Recipe : public gk::ISerializable {
public:
Recipe(const std::string &type, const ItemStack &result = {}) : m_type(type), m_result(result) {}
virtual ~Recipe() = default;
Expand Down
38 changes: 0 additions & 38 deletions source/common/network/ISerializable.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions source/common/network/ISerializable.hpp

This file was deleted.

3 changes: 2 additions & 1 deletion source/common/scene/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* =====================================================================================
*/
#include <gk/core/Debug.hpp>
#include <gk/core/ISerializable.hpp>

#include <entt/entt.hpp>

Expand Down Expand Up @@ -75,7 +76,7 @@ T &set(entt::registry &registry, entt::entity entity, const T &instance) {
template<typename T>
Network::Packet serialize(entt::entity entity, T &component) {
Network::Packet packet;
if constexpr(std::is_base_of_v<ISerializable, std::decay_t<T>>) {
if constexpr(std::is_base_of_v<gk::ISerializable, std::decay_t<T>>) {
if (component.isUpdated) {
packet << component.packetType << entity << component;
component.isUpdated = false;
Expand Down
1 change: 0 additions & 1 deletion source/common/scene/Scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <deque>

#include "AbstractController.hpp"
#include "ISerializable.hpp"

class Scene {
public:
Expand Down
6 changes: 3 additions & 3 deletions source/common/scene/component/AnimationComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <vector>

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include "ISerializable.hpp"
#include "Network.hpp"
#include "NetworkUtils.hpp"

Expand All @@ -40,7 +40,7 @@ enum class AnimationType {
Translation,
};

struct AnimationData : public ISerializable {
struct AnimationData : public gk::ISerializable {
AnimationType type;

union {
Expand Down Expand Up @@ -88,7 +88,7 @@ struct AnimationData : public ISerializable {
}
};

struct AnimationComponent : public ISerializable {
struct AnimationComponent : public gk::ISerializable {
void addRotation(float axisX, float axisY, float axisZ, float angle) {
list.emplace_back();
AnimationData &data = list.back();
Expand Down
4 changes: 2 additions & 2 deletions source/common/scene/component/DrawableDef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#define DRAWABLEDEF_HPP_

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include "ISerializable.hpp"
#include "InventoryCubeDef.hpp"
#include "Network.hpp"

Expand All @@ -40,7 +40,7 @@ namespace DrawableType {
};
}

class DrawableDef : public ISerializable {
class DrawableDef : public gk::ISerializable {
public:
InventoryCubeDef &addInventoryCube();

Expand Down
4 changes: 2 additions & 2 deletions source/common/scene/component/InventoryCubeDef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

#include <string>

#include <gk/core/ISerializable.hpp>
#include <gk/core/Vector3.hpp>

#include "ISerializable.hpp"
#include "NetworkUtils.hpp"

struct InventoryCubeDef : public ISerializable {
struct InventoryCubeDef : public gk::ISerializable {
float size = 1.f;
gk::Vector3f origin{0, 0, 0};
std::string blockID{"_:air"};
Expand Down
4 changes: 2 additions & 2 deletions source/common/scene/component/PositionComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#define POSITIONCOMPONENT_HPP_

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include "ISerializable.hpp"
#include "Network.hpp"

struct PositionComponent : public ISerializable {
struct PositionComponent : public gk::ISerializable {
PositionComponent() = default;
PositionComponent(double x_, double y_, double z_, u16 dimension_)
: x(x_), y(y_), z(z_), dimension(dimension_) {}
Expand Down
5 changes: 3 additions & 2 deletions source/common/scene/component/RotationComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@

#include <glm/gtc/quaternion.hpp>

#include "ISerializable.hpp"
#include <gk/core/ISerializable.hpp>

#include "Network.hpp"

struct RotationComponent : public ISerializable {
struct RotationComponent : public gk::ISerializable {
glm::quat quat{1, 0, 0, 0};

bool isUpdated = true;
Expand Down
4 changes: 2 additions & 2 deletions source/common/world/Biome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include <vector>

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include "ISerializable.hpp"
#include "PlacementEntry.hpp"

class Biome : public ISerializable {
class Biome : public gk::ISerializable {
public:
Biome() = default;
Biome(u16 id, const std::string &stringID, const std::string &label);
Expand Down
4 changes: 2 additions & 2 deletions source/common/world/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

#include <gk/core/Box.hpp>
#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>
#include <gk/graphics/Color.hpp>

#include "ItemStack.hpp"
#include "ISerializable.hpp"
#include "TilesDef.hpp"

class Chunk;
Expand All @@ -53,7 +53,7 @@ enum class BlockDrawType : u8 {
BoundingBox = 6, // FIXME: Temporary
};

class Block : public ISerializable {
class Block : public gk::ISerializable {
public:
Block() = default;
Block(u32 id, const TilesDef &tiles, const std::string &stringID, const std::string &label);
Expand Down
7 changes: 3 additions & 4 deletions source/common/world/BlockMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@

#include <sol/sol.hpp>

#include <gk/core/IntTypes.hpp>
#include <gk/core/Exception.hpp>

#include "ISerializable.hpp"
#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

class BlockMetadataValue {
public:
Expand Down Expand Up @@ -65,7 +64,7 @@ class BlockMetadataValue {
Type m_type = Type::Undefined;
};

class BlockMetadata : public ISerializable {
class BlockMetadata : public gk::ISerializable {
public:
void setString(const std::string &name, const std::string &value);
void setInt(const std::string &name, int value);
Expand Down
5 changes: 2 additions & 3 deletions source/common/world/Dimension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
#include <vector>

#include <gk/core/IntTypes.hpp>
#include <gk/core/ISerializable.hpp>

#include <sol/sol.hpp>

#include "ISerializable.hpp"

class Dimension : public ISerializable {
class Dimension : public gk::ISerializable {
public:
Dimension() = default;
Dimension(u16 id, const std::string &stringID, const std::string &name)
Expand Down
7 changes: 3 additions & 4 deletions source/common/world/Key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@

#include <sol/sol.hpp>

#include "ISerializable.hpp"
#include "NetworkUtils.hpp"
#include <gk/core/ISerializable.hpp>

#include <gk/core/Debug.hpp>
#include "NetworkUtils.hpp"

class Key : public ISerializable {
class Key : public gk::ISerializable {
public:
Key() = default;
Key(u16 id, const std::string &stringID, const std::string &name)
Expand Down
9 changes: 4 additions & 5 deletions source/common/world/PlacementEntry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
#include <SFML/Network/Packet.hpp>

#include <gk/core/IntTypes.hpp>

#include "ISerializable.hpp"
#include <gk/core/ISerializable.hpp>

namespace PlacementEntry {

struct Flora : public ISerializable {
struct Flora : public gk::ISerializable {
u16 blockID;
u16 spawnsOnBlockID;
double probability;
Expand All @@ -49,7 +48,7 @@ struct Flora : public ISerializable {
}
};

struct Ore : public ISerializable {
struct Ore : public gk::ISerializable {
u16 blockID;
double probability;
double size;
Expand All @@ -63,7 +62,7 @@ struct Ore : public ISerializable {
}
};

struct Tree : public ISerializable {
struct Tree : public gk::ISerializable {
u16 treeID;
double probability;

Expand Down
Loading

0 comments on commit afc4918

Please sign in to comment.