Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
itemstackmetadata.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2017-8 rubenwardy <rw@rubenwardy.com>
4
5#pragma once
6
7#include "metadata.h"
8#include "tool.h"
9
10#include <optional>
11
12class Inventory;
13class IItemDefManager;
14
16{
17public:
21
22 // Overrides
23 void clear() override;
24 bool setString(const std::string &name, std::string_view var) override;
25
26 void serialize(std::ostream &os) const;
27 void deSerialize(std::istream &is);
28
30 const ToolCapabilities &default_caps) const
31 {
32 return toolcaps_overridden ? toolcaps_override : default_caps;
33 }
34
35 void setToolCapabilities(const ToolCapabilities &caps);
37
38 const std::optional<WearBarParams> &getWearBarParamOverride() const
39 {
40 return wear_bar_override;
41 }
42
43
44 void setWearBarParams(const WearBarParams &params);
45 void clearWearBarParams();
46
47private:
50
53 std::optional<WearBarParams> wear_bar_override;
54};
Definition itemdef.h:129
Definition inventory.h:314
Definition itemstackmetadata.h:16
void deSerialize(std::istream &is)
Definition itemstackmetadata.cpp:64
bool setString(const std::string &name, std::string_view var) override
Definition itemstackmetadata.cpp:37
void clearToolCapabilities()
Definition itemstackmetadata.cpp:107
bool toolcaps_overridden
Definition itemstackmetadata.h:51
ItemStackMetadata()
Definition itemstackmetadata.h:18
const ToolCapabilities & getToolCapabilities(const ToolCapabilities &default_caps) const
Definition itemstackmetadata.h:29
void clearWearBarParams()
Definition itemstackmetadata.cpp:129
ToolCapabilities toolcaps_override
Definition itemstackmetadata.h:52
std::optional< WearBarParams > wear_bar_override
Definition itemstackmetadata.h:53
void updateToolCapabilities()
Definition itemstackmetadata.cpp:88
const std::optional< WearBarParams > & getWearBarParamOverride() const
Definition itemstackmetadata.h:38
void updateWearBarParams()
Definition itemstackmetadata.cpp:112
void serialize(std::ostream &os) const
Definition itemstackmetadata.cpp:52
void clear() override
Definition itemstackmetadata.cpp:23
void setToolCapabilities(const ToolCapabilities &caps)
Definition itemstackmetadata.cpp:100
void setWearBarParams(const WearBarParams &params)
Definition itemstackmetadata.cpp:122
Definition metadata.h:63
Definition tool.h:46
Definition tool.h:78