From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- .../Common/GameRules/GameRuleDefinition.h | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Minecraft.Client/Common/GameRules/GameRuleDefinition.h (limited to 'Minecraft.Client/Common/GameRules/GameRuleDefinition.h') diff --git a/Minecraft.Client/Common/GameRules/GameRuleDefinition.h b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h new file mode 100644 index 00000000..afec8fbc --- /dev/null +++ b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h @@ -0,0 +1,66 @@ +#pragma once +using namespace std; +#include +#include + +#include "..\..\..\Minecraft.World\ItemInstance.h" +#include "ConsoleGameRulesConstants.h" + +#include "GameRulesInstance.h" + +class GameRule; +class LevelRuleset; +class Player; +class WstringLookup; + +class GameRuleDefinition +{ +private: + // Owner type defines who this rule applies to + GameRulesInstance::EGameRulesInstanceType m_ownerType; + +protected: + // These attributes should map to those in the XSD GameRuleType + wstring m_descriptionId; + wstring m_promptId; + int m_4JDataValue; + +public: + GameRuleDefinition(); + + virtual ConsoleGameRules::EGameRuleType getActionType() = 0; + + void setOwnerType(GameRulesInstance::EGameRulesInstanceType ownerType) { m_ownerType = ownerType;} + + virtual void write(DataOutputStream *); + + virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void getChildren(vector *); + + virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); + virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue); + + virtual void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule); + + bool getComplete(GameRule *rule); + void setComplete(GameRule *rule, bool val); + + virtual int getGoal() { return 0; } + virtual int getProgress(GameRule *rule) { return 0; } + + virtual int getIcon() { return -1; } + virtual int getAuxValue() { return 0; } + + // Here we should have functions for all the hooks, with a GameRule* as the first parameter + virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z) { return false; } + virtual bool onCollectItem(GameRule *rule, shared_ptr item) { return false; } + virtual void postProcessPlayer(shared_ptr player) { } + + vector *enumerate(); + unordered_map *enumerateMap(); + + // Static functions + static GameRulesInstance *generateNewGameRulesInstance(GameRulesInstance::EGameRulesInstanceType type, LevelRuleset *rules, Connection *connection); + static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = NULL, int dataLength = 0); + +}; \ No newline at end of file -- cgit v1.2.3