3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef NODEMETADATA_HEADER
21 #define NODEMETADATA_HEADER
23 #include "common_irrlicht.h"
31 - Item that is being burned
33 - Item stack that is being heated
45 typedef NodeMetadata* (*Factory)(std::istream&);
48 virtual ~NodeMetadata();
50 static NodeMetadata* deSerialize(std::istream &is);
51 void serialize(std::ostream &os);
53 // This usually is the CONTENT_ value
54 virtual u16 typeId() const = 0;
55 virtual NodeMetadata* clone() = 0;
56 virtual void serializeBody(std::ostream &os) = 0;
57 virtual std::string infoText() {return "<todo: remove this text>";}
58 virtual Inventory* getInventory() {return NULL;}
59 // This is called always after the inventory is modified, before
60 // the changes are copied elsewhere
61 virtual void inventoryModified(){}
64 static void registerType(u16 id, Factory f);
66 static core::map<u16, Factory> m_types;
69 class SignNodeMetadata : public NodeMetadata
72 SignNodeMetadata(std::string text);
73 //~SignNodeMetadata();
75 virtual u16 typeId() const;
76 static NodeMetadata* create(std::istream &is);
77 virtual NodeMetadata* clone();
78 virtual void serializeBody(std::ostream &os);
79 virtual std::string infoText();
81 std::string getText(){ return m_text; }
82 void setText(std::string t){ m_text = t; }
88 class ChestNodeMetadata : public NodeMetadata
94 virtual u16 typeId() const;
95 static NodeMetadata* create(std::istream &is);
96 virtual NodeMetadata* clone();
97 virtual void serializeBody(std::ostream &os);
98 virtual std::string infoText();
99 virtual Inventory* getInventory() {return m_inventory;}
102 Inventory *m_inventory;
105 class FurnaceNodeMetadata : public NodeMetadata
108 FurnaceNodeMetadata();
109 ~FurnaceNodeMetadata();
111 virtual u16 typeId() const;
112 virtual NodeMetadata* clone();
113 static NodeMetadata* create(std::istream &is);
114 virtual void serializeBody(std::ostream &os);
115 virtual std::string infoText();
116 virtual Inventory* getInventory() {return m_inventory;}
117 virtual void inventoryModified();
120 Inventory *m_inventory;
124 List of metadata of all the nodes of a block
127 class NodeMetadataList
132 void serialize(std::ostream &os);
133 void deSerialize(std::istream &is);
135 // Get pointer to data
136 NodeMetadata* get(v3s16 p);
138 void remove(v3s16 p);
139 // Deletes old data and sets a new one
140 void set(v3s16 p, NodeMetadata *d);
142 core::map<v3s16, NodeMetadata*> m_data;