#pragma once // using namespace std; #include class CompoundTag; class GameRuleDefinition; class Connection; // A game rule maintains the state for one particular definition class GameRule { public: typedef struct _ValueType { union { __int64 i64; int i; char c; bool b; float f; double d; GameRule* gr; }; bool isPointer; _ValueType() { i64 = 0; isPointer = false; } } ValueType; private: GameRuleDefinition* m_definition; Connection* m_connection; public: typedef std::unordered_map stringValueMapType; stringValueMapType m_parameters; // These are the members of this rule that // maintain it's state public: GameRule(GameRuleDefinition* definition, Connection* connection = NULL); virtual ~GameRule(); Connection* getConnection() { return m_connection; } ValueType getParameter(const std::wstring& parameterName); void setParameter(const std::wstring& parameterName, ValueType value); GameRuleDefinition* getGameRuleDefinition(); // All the hooks go here void onUseTile(int tileId, int x, int y, int z); void onCollectItem(std::shared_ptr item); // 4J-JEV: For saving. // CompoundTag *toTags(std::unordered_map *map); // static GameRule *fromTags(Connection *c, CompoundTag *cTag, // std::vector *grds); void write(DataOutputStream* dos); void read(DataInputStream* dos); };