gamedef.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include <vector>
  19. #include "irrlichttypes.h"
  20. class IItemDefManager;
  21. class NodeDefManager;
  22. class ICraftDefManager;
  23. class ITextureSource;
  24. class IShaderSource;
  25. class IRollbackManager;
  26. class EmergeManager;
  27. class Camera;
  28. class ModChannel;
  29. class ModMetadata;
  30. namespace irr { namespace scene {
  31. class IAnimatedMesh;
  32. class ISceneManager;
  33. }}
  34. struct ModSpec;
  35. /*
  36. An interface for fetching game-global definitions like tool and
  37. mapnode properties
  38. */
  39. class IGameDef
  40. {
  41. public:
  42. // These are thread-safe IF they are not edited while running threads.
  43. // Thus, first they are set up and then they are only read.
  44. virtual IItemDefManager* getItemDefManager()=0;
  45. virtual const NodeDefManager* getNodeDefManager()=0;
  46. virtual ICraftDefManager* getCraftDefManager()=0;
  47. // Used for keeping track of names/ids of unknown nodes
  48. virtual u16 allocateUnknownNodeId(const std::string &name)=0;
  49. // Only usable on the server, and NOT thread-safe. It is usable from the
  50. // environment thread.
  51. virtual IRollbackManager* getRollbackManager() { return NULL; }
  52. // Shorthands
  53. IItemDefManager *idef() { return getItemDefManager(); }
  54. const NodeDefManager *ndef() { return getNodeDefManager(); }
  55. ICraftDefManager *cdef() { return getCraftDefManager(); }
  56. IRollbackManager *rollback() { return getRollbackManager(); }
  57. virtual const std::vector<ModSpec> &getMods() const = 0;
  58. virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
  59. virtual std::string getWorldPath() const { return ""; }
  60. virtual std::string getModStoragePath() const = 0;
  61. virtual bool registerModStorage(ModMetadata *storage) = 0;
  62. virtual void unregisterModStorage(const std::string &name) = 0;
  63. virtual bool joinModChannel(const std::string &channel) = 0;
  64. virtual bool leaveModChannel(const std::string &channel) = 0;
  65. virtual bool sendModChannelMessage(const std::string &channel,
  66. const std::string &message) = 0;
  67. virtual ModChannel *getModChannel(const std::string &channel) = 0;
  68. };