3 Copyright (C) 2010-2013 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser 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.
23 #include "irrlichttypes.h"
26 #include "util/cpp11_container.h"
27 #include "itemgroup.h"
31 UNORDERED_MAP<int, float> times;
40 bool getTime(int rating, float *time) const
42 UNORDERED_MAP<int, float>::const_iterator i = times.find(rating);
43 if (i == times.end()) {
53 typedef UNORDERED_MAP<std::string, struct ToolGroupCap> ToolGCMap;
54 typedef UNORDERED_MAP<std::string, s16> DamageGroup;
56 struct ToolCapabilities
58 float full_punch_interval;
61 DamageGroup damageGroups;
64 float full_punch_interval_=1.4,
65 int max_drop_level_=1,
66 const ToolGCMap &groupcaps_ = ToolGCMap(),
67 const DamageGroup &damageGroups_ = DamageGroup()
69 full_punch_interval(full_punch_interval_),
70 max_drop_level(max_drop_level_),
71 groupcaps(groupcaps_),
72 damageGroups(damageGroups_)
75 void serialize(std::ostream &os, u16 version) const;
76 void deSerialize(std::istream &is);
82 // Digging time in seconds
86 std::string main_group;
88 DigParams(bool a_diggable = false, float a_time = 0.0f, u16 a_wear = 0,
89 const std::string &a_main_group = ""):
93 main_group(a_main_group)
97 DigParams getDigParams(const ItemGroupList &groups,
98 const ToolCapabilities *tp, float time_from_last_punch);
100 DigParams getDigParams(const ItemGroupList &groups,
101 const ToolCapabilities *tp);
108 HitParams(s16 hp_=0, s16 wear_=0):
114 HitParams getHitParams(const ItemGroupList &armor_groups,
115 const ToolCapabilities *tp, float time_from_last_punch);
117 HitParams getHitParams(const ItemGroupList &armor_groups,
118 const ToolCapabilities *tp);
120 struct PunchDamageResult
135 PunchDamageResult getPunchDamage(
136 const ItemGroupList &armor_groups,
137 const ToolCapabilities *toolcap,
138 const ItemStack *punchitem,
139 float time_from_last_punch