Luanti 5.11.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:
20
21 // Overrides
22 void clear() override;
23 bool setString(const std::string &name, std::string_view var) override;
24
25 void serialize(std::ostream &os) const;
26 void deSerialize(std::istream &is);
27
29 const ToolCapabilities &default_caps) const
30 {
31 return toolcaps_override.has_value() ? *toolcaps_override : default_caps;
32 }
33
34 void setToolCapabilities(const ToolCapabilities &caps);
36
37 const std::optional<WearBarParams> &getWearBarParamOverride() const
38 {
39 return wear_bar_override;
40 }
41
42 void setWearBarParams(const WearBarParams &params);
43 void clearWearBarParams();
44
45private:
48
49 std::optional<ToolCapabilities> toolcaps_override;
50 std::optional<WearBarParams> wear_bar_override;
51};
Definition itemdef.h:129
Definition inventory.h:314
Definition itemstackmetadata.h:16
std::optional< ToolCapabilities > toolcaps_override
Definition itemstackmetadata.h:49
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:106
ItemStackMetadata()
Definition itemstackmetadata.h:18
const ToolCapabilities & getToolCapabilities(const ToolCapabilities &default_caps) const
Definition itemstackmetadata.h:28
void clearWearBarParams()
Definition itemstackmetadata.cpp:128
std::optional< WearBarParams > wear_bar_override
Definition itemstackmetadata.h:50
void updateToolCapabilities()
Definition itemstackmetadata.cpp:88
const std::optional< WearBarParams > & getWearBarParamOverride() const
Definition itemstackmetadata.h:37
void updateWearBarParams()
Definition itemstackmetadata.cpp:111
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:99
void setWearBarParams(const WearBarParams &params)
Definition itemstackmetadata.cpp:121
Definition metadata.h:63
Definition tool.h:53
Definition tool.h:85