]> git.lizzy.rs Git - minetest.git/blob - src/craftitemdef.h
ObjectRef:get_player_name, ObjectRef:inventory_set_list, ObjectRef:inventory_get_list
[minetest.git] / src / craftitemdef.h
1 /*
2 Minetest-c55
3 Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2011 Kahrl <kahrl@gmx.net>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifndef CRAFTITEMDEF_HEADER
22 #define CRAFTITEMDEF_HEADER
23
24 #include "common_irrlicht.h"
25 #include <string>
26 #include <iostream>
27
28 struct CraftItemDefinition
29 {
30         std::string imagename;
31         std::string cookresult_item;
32         float furnace_cooktime;
33         float furnace_burntime;
34         bool usable;
35         bool liquids_pointable;
36         s16 dropcount;
37         s16 stack_max;
38
39         CraftItemDefinition();
40         std::string dump();
41         void serialize(std::ostream &os);
42         void deSerialize(std::istream &is);
43 };
44
45 class ICraftItemDefManager
46 {
47 public:
48         ICraftItemDefManager(){}
49         virtual ~ICraftItemDefManager(){}
50         virtual const CraftItemDefinition* getCraftItemDefinition(const std::string &itemname) const=0;
51         virtual std::string getImagename(const std::string &itemname) const =0;
52
53         virtual void serialize(std::ostream &os)=0;
54 };
55
56 class IWritableCraftItemDefManager : public ICraftItemDefManager
57 {
58 public:
59         IWritableCraftItemDefManager(){}
60         virtual ~IWritableCraftItemDefManager(){}
61         virtual const CraftItemDefinition* getCraftItemDefinition(const std::string &itemname) const=0;
62         virtual std::string getImagename(const std::string &itemname) const =0;
63
64         virtual bool registerCraftItem(std::string itemname, const CraftItemDefinition &def)=0;
65         virtual void clear()=0;
66
67         virtual void serialize(std::ostream &os)=0;
68         virtual void deSerialize(std::istream &is)=0;
69 };
70
71 IWritableCraftItemDefManager* createCraftItemDefManager();
72
73 #endif