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
12
class
Inventory
;
13
class
IItemDefManager
;
14
15
class
ItemStackMetadata
:
public
SimpleMetadata
16
{
17
public
:
18
ItemStackMetadata
():
19
toolcaps_overridden
(false)
20
{}
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
29
const
ToolCapabilities
&
getToolCapabilities
(
30
const
ToolCapabilities
&default_caps)
const
31
{
32
return
toolcaps_overridden
?
toolcaps_override
: default_caps;
33
}
34
35
void
setToolCapabilities
(
const
ToolCapabilities
&caps);
36
void
clearToolCapabilities
();
37
38
const
std::optional<WearBarParams> &
getWearBarParamOverride
()
const
39
{
40
return
wear_bar_override
;
41
}
42
43
44
void
setWearBarParams
(
const
WearBarParams
¶ms);
45
void
clearWearBarParams
();
46
47
private
:
48
void
updateToolCapabilities
();
49
void
updateWearBarParams
();
50
51
bool
toolcaps_overridden
;
52
ToolCapabilities
toolcaps_override
;
53
std::optional<WearBarParams>
wear_bar_override
;
54
};
IItemDefManager
Definition
itemdef.h:129
Inventory
Definition
inventory.h:314
ItemStackMetadata
Definition
itemstackmetadata.h:16
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:107
ItemStackMetadata::toolcaps_overridden
bool toolcaps_overridden
Definition
itemstackmetadata.h:51
ItemStackMetadata::ItemStackMetadata
ItemStackMetadata()
Definition
itemstackmetadata.h:18
ItemStackMetadata::getToolCapabilities
const ToolCapabilities & getToolCapabilities(const ToolCapabilities &default_caps) const
Definition
itemstackmetadata.h:29
ItemStackMetadata::clearWearBarParams
void clearWearBarParams()
Definition
itemstackmetadata.cpp:129
ItemStackMetadata::toolcaps_override
ToolCapabilities toolcaps_override
Definition
itemstackmetadata.h:52
ItemStackMetadata::wear_bar_override
std::optional< WearBarParams > wear_bar_override
Definition
itemstackmetadata.h:53
ItemStackMetadata::updateToolCapabilities
void updateToolCapabilities()
Definition
itemstackmetadata.cpp:88
ItemStackMetadata::getWearBarParamOverride
const std::optional< WearBarParams > & getWearBarParamOverride() const
Definition
itemstackmetadata.h:38
ItemStackMetadata::updateWearBarParams
void updateWearBarParams()
Definition
itemstackmetadata.cpp:112
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:100
ItemStackMetadata::setWearBarParams
void setWearBarParams(const WearBarParams ¶ms)
Definition
itemstackmetadata.cpp:122
SimpleMetadata
Definition
metadata.h:63
metadata.h
ToolCapabilities
Definition
tool.h:46
WearBarParams
Definition
tool.h:78
tool.h
itemstackmetadata.h
Generated on Fri Nov 1 2024 10:48:59 for Luanti by
1.11.0