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
12
class
Inventory
;
13
class
IItemDefManager
;
14
15
class
ItemStackMetadata
:
public
SimpleMetadata
16
{
17
public
:
18
ItemStackMetadata
()
19
{}
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
28
const
ToolCapabilities
&
getToolCapabilities
(
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);
35
void
clearToolCapabilities
();
36
37
const
std::optional<WearBarParams> &
getWearBarParamOverride
()
const
38
{
39
return
wear_bar_override
;
40
}
41
42
void
setWearBarParams
(
const
WearBarParams
¶ms);
43
void
clearWearBarParams
();
44
45
private
:
46
void
updateToolCapabilities
();
47
void
updateWearBarParams
();
48
49
std::optional<ToolCapabilities>
toolcaps_override
;
50
std::optional<WearBarParams>
wear_bar_override
;
51
};
IItemDefManager
Definition
itemdef.h:129
Inventory
Definition
inventory.h:314
ItemStackMetadata
Definition
itemstackmetadata.h:16
ItemStackMetadata::toolcaps_override
std::optional< ToolCapabilities > toolcaps_override
Definition
itemstackmetadata.h:49
ItemStackMetadata::deSerialize
void deSerialize(std::istream &is)
Definition
itemstackmetadata.cpp:64
ItemStackMetadata::setString
bool setString(const std::string &name, std::string_view var) override
Definition
itemstackmetadata.cpp:37
ItemStackMetadata::clearToolCapabilities
void clearToolCapabilities()
Definition
itemstackmetadata.cpp:106
ItemStackMetadata::ItemStackMetadata
ItemStackMetadata()
Definition
itemstackmetadata.h:18
ItemStackMetadata::getToolCapabilities
const ToolCapabilities & getToolCapabilities(const ToolCapabilities &default_caps) const
Definition
itemstackmetadata.h:28
ItemStackMetadata::clearWearBarParams
void clearWearBarParams()
Definition
itemstackmetadata.cpp:128
ItemStackMetadata::wear_bar_override
std::optional< WearBarParams > wear_bar_override
Definition
itemstackmetadata.h:50
ItemStackMetadata::updateToolCapabilities
void updateToolCapabilities()
Definition
itemstackmetadata.cpp:88
ItemStackMetadata::getWearBarParamOverride
const std::optional< WearBarParams > & getWearBarParamOverride() const
Definition
itemstackmetadata.h:37
ItemStackMetadata::updateWearBarParams
void updateWearBarParams()
Definition
itemstackmetadata.cpp:111
ItemStackMetadata::serialize
void serialize(std::ostream &os) const
Definition
itemstackmetadata.cpp:52
ItemStackMetadata::clear
void clear() override
Definition
itemstackmetadata.cpp:23
ItemStackMetadata::setToolCapabilities
void setToolCapabilities(const ToolCapabilities &caps)
Definition
itemstackmetadata.cpp:99
ItemStackMetadata::setWearBarParams
void setWearBarParams(const WearBarParams ¶ms)
Definition
itemstackmetadata.cpp:121
SimpleMetadata
Definition
metadata.h:63
metadata.h
ToolCapabilities
Definition
tool.h:53
WearBarParams
Definition
tool.h:85
tool.h
itemstackmetadata.h
Generated on Wed Jan 1 2025 10:21:55 for Luanti by
1.11.0