Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_CharacterQuickBarSerializer.c
Go to the documentation of this file.
1
class
SCR_PersistentQuickSlotItem
2
{
3
int
m_iIndex;
4
UUID
m_sEntityId;
5
}
6
7
class
SCR_CharacterQuickBarSerializer :
BaseInventoryStorageComponentSerializer
8
{
9
[
Attribute
(
desc
:
"Filter to only handle specific quick slots. e.g. 0-3 are fixed through weapon slots and must not be saved."
)]
10
ref array<int> m_aSlotIndexFilter;
11
12
//------------------------------------------------------------------------------------------------
13
override
static
typename
GetTargetType
()
14
{
15
return
SCR_CharacterInventoryStorageComponent
;
16
}
17
18
//------------------------------------------------------------------------------------------------
19
override
protected
ESerializeResult
Serialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
SaveContext
context)
20
{
21
const
SCR_CharacterInventoryStorageComponent
charStorage =
SCR_CharacterInventoryStorageComponent
.Cast(component);
22
23
array<ref SCR_PersistentQuickSlotItem> slots();
24
foreach
(
int
idx
,
auto
quickslot : charStorage.
GetQuickSlotItems
())
25
{
26
if
(!m_aSlotIndexFilter.IsEmpty() && !m_aSlotIndexFilter.Contains(
idx
))
27
continue
;
28
29
auto
container =
SCR_QuickslotEntityContainer
.Cast(quickslot);
30
if
(!container)
31
continue
;
32
33
const
UUID
id
= GetSystem().GetId(container.GetEntity());
34
if
(
id
.IsNull())
35
continue
;
36
37
SCR_PersistentQuickSlotItem
slot();
38
slot.m_iIndex =
idx
;
39
slot.m_sEntityId =
id
;
40
slots.Insert(slot);
41
}
42
43
context.StartObject(
"base"
);
44
const
ESerializeResult
baseResult = super.Serialize(owner, component, context);
45
context.EndObject();
46
if
(baseResult ==
ESerializeResult
.ERROR)
47
return
baseResult;
48
49
if
(baseResult ==
ESerializeResult
.DEFAULT && slots.IsEmpty())
50
return
baseResult;
51
52
context.WriteValue(
"version"
, 1);
53
const
bool
prev = context.EnableTypeDiscriminator(
false
);
54
context.WriteValue(
"quickSlots"
, slots);
55
context.EnableTypeDiscriminator(prev);
56
return
ESerializeResult
.OK;
57
}
58
59
//------------------------------------------------------------------------------------------------
60
override
protected
bool
Deserialize
(notnull
IEntity
owner, notnull
GenericComponent
component, notnull
LoadContext
context)
61
{
62
auto
charStorage =
SCR_CharacterInventoryStorageComponent
.Cast(component);
63
64
if
(context.DoesObjectExist(
"base"
))
65
{
66
if
(!context.StartObject(
"base"
) ||
67
!super.Deserialize(owner, component, context) ||
68
!context.EndObject())
69
{
70
return
false
;
71
}
72
}
73
74
int
version;
75
context.Read(version);
76
77
array<ref SCR_PersistentQuickSlotItem> slots();
78
const
bool
prev = context.EnableTypeDiscriminator(
false
);
79
context.ReadValue(
"quickSlots"
, slots);
80
context.EnableTypeDiscriminator(prev);
81
82
array<int> allSlots();
83
allSlots.Copy(m_aSlotIndexFilter);
84
85
foreach
(
auto
quickSlot : slots)
86
{
87
// We are on the storage that must have held the items, and do direct lookup, so any deferred deserialize is not relevant here
88
const
IEntity
entity =
IEntity
.Cast(GetSystem().FindById(quickSlot.m_sEntityId));
89
if
(!entity)
90
continue
;
91
92
charStorage.StoreItemToQuickSlot(entity, quickSlot.m_iIndex,
true
);
93
charStorage.SetQuickSlotInitialized(quickSlot.m_iIndex);
94
allSlots.RemoveItem(quickSlot.m_iIndex);
95
}
96
97
foreach
(
int
noDataSlotIdx : allSlots)
98
{
99
charStorage.SetQuickSlotInitialized(noDataSlotIdx);
100
}
101
102
return
true
;
103
}
104
}
GetTargetType
class SCR_PersistentThreatSector GetTargetType()
Definition
AIControlComponentSerializer.c:12
idx
int idx
Definition
AIControlComponentSerializer.c:13
id
AddonBuildInfoTool id
SCR_QuickslotEntityContainer
void SCR_QuickslotEntityContainer(IEntity entity)
Definition
SCR_QuickslotBaseContainer.c:41
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseInventoryStorageComponentSerializer
Definition
BaseInventoryStorageComponentSerializer.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
LoadContext
Definition
LoadContext.c:17
SCR_CharacterInventoryStorageComponent
Definition
SCR_CharacterInventoryStorageComponent.c:90
SCR_CharacterInventoryStorageComponent::GetQuickSlotItems
array< ref SCR_QuickslotBaseContainer > GetQuickSlotItems()
Definition
SCR_CharacterInventoryStorageComponent.c:480
SCR_PersistentQuickSlotItem
Definition
SCR_CharacterQuickBarSerializer.c:2
SaveContext
Definition
SaveContext.c:17
ScriptedComponentSerializer::Serialize
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
Definition
ScriptedComponentSerializer.c:34
ScriptedComponentSerializer::Deserialize
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
Definition
ScriptedComponentSerializer.c:39
UUID
Definition
UUID.c:28
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ESerializeResult
ESerializeResult
Definition
ESerializeResult.c:13
scripts
Game
Plugins
Persistence
System
Serializers
Components
Character
SCR_CharacterQuickBarSerializer.c
Generated by
1.17.0