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_SupplyContainerValueAttribute.c
Go to the documentation of this file.
1
[
BaseContainerProps
(),
SCR_BaseEditorAttributeCustomTitle
()]
2
class
SCR_SupplyContainerValueAttribute
:
SCR_BaseValueListEditorAttribute
3
{
4
override
SCR_BaseEditorAttributeVar
ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
5
{
6
SCR_EditableEntityComponent
editableEntity =
SCR_EditableEntityComponent
.Cast(item);
7
if
(!editableEntity)
8
return
null;
9
10
GenericEntity
entity = editableEntity.
GetOwnerScripted
();
11
if
(!entity)
12
return
null;
13
14
SCR_ResourceComponent resourceComponent;
15
SCR_ResourceContainer
supplyContainer = GetContainer(entity, resourceComponent);
16
if
(!supplyContainer)
17
return
null;
18
19
float
currentValue = supplyContainer.
GetResourceValue
();
20
float
maxValue = supplyContainer.
GetMaxResourceValue
();
21
22
if
(maxValue == 0)
23
return
null;
24
25
return
SCR_BaseEditorAttributeVar
.
CreateFloat
((currentValue / maxValue) * 100);
26
}
27
28
override
void
WriteVariable(Managed item,
SCR_BaseEditorAttributeVar
var, SCR_AttributesManagerEditorComponent manager,
int
playerID)
29
{
30
SCR_EditableEntityComponent
editableEntity =
SCR_EditableEntityComponent
.Cast(item);
31
if
(!editableEntity)
32
return
;
33
34
GenericEntity
entity = editableEntity.
GetOwnerScripted
();
35
if
(!entity)
36
return
;
37
38
SCR_ResourceComponent resourceComponent;
39
SCR_ResourceContainer
supplyContainer = GetContainer(entity, resourceComponent);
40
if
(!supplyContainer)
41
return
;
42
43
float
percentage = var.
GetFloat
();
44
float
maxValue = supplyContainer.
GetMaxResourceValue
();
45
float
newValue = maxValue * (percentage / 100);
46
47
supplyContainer.
SetResourceValue
(newValue);
48
}
49
50
SCR_ResourceContainer
GetContainer(notnull
IEntity
entity, out SCR_ResourceComponent component)
51
{
52
component = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
53
SCR_ResourceContainer
container;
54
55
if
(component)
56
{
57
container = component.GetContainer(
EResourceType
.SUPPLIES);
58
if
(container)
59
return
container;
60
}
61
62
IEntity
iteratedEntity = entity.
GetChildren
();
63
while
(iteratedEntity)
64
{
65
component = SCR_ResourceComponent.Cast(iteratedEntity.
FindComponent
(SCR_ResourceComponent));
66
if
(component)
67
{
68
container = component.GetContainer(
EResourceType
.SUPPLIES);
69
if
(container)
70
return
container;
71
}
72
73
iteratedEntity = iteratedEntity.
GetSibling
();
74
}
75
76
return
null;
77
}
78
}
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
GenericEntity
Definition
GenericEntity.c:16
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetChildren
proto external IEntity GetChildren()
IEntity::GetSibling
proto external IEntity GetSibling()
SCR_BaseEditorAttributeCustomTitle
Definition
SCR_BaseEditorAttribute.c:876
SCR_BaseEditorAttributeVar
Definition
SCR_BaseEditorAttributeVar.c:2
SCR_BaseEditorAttributeVar::GetFloat
float GetFloat()
Definition
SCR_BaseEditorAttributeVar.c:38
SCR_BaseEditorAttributeVar::CreateFloat
static SCR_BaseEditorAttributeVar CreateFloat(float value)
Definition
SCR_BaseEditorAttributeVar.c:113
SCR_BaseValueListEditorAttribute
Definition
SCR_BaseValueListEditorAttribute.c:6
SCR_EditableEntityComponent
Definition
SCR_EditableEntityComponent.c:14
SCR_EditableEntityComponent::GetOwnerScripted
GenericEntity GetOwnerScripted()
Definition
SCR_EditableEntityComponent.c:252
SCR_ResourceContainer
Definition
SCR_ResourceContainer.c:35
SCR_ResourceContainer::GetResourceValue
float GetResourceValue()
Definition
SCR_ResourceContainer.c:95
SCR_ResourceContainer::SetResourceValue
bool SetResourceValue(float value, bool notifyChange=true)
Definition
SCR_ResourceContainer.c:411
SCR_ResourceContainer::GetMaxResourceValue
float GetMaxResourceValue()
Definition
SCR_ResourceContainer.c:101
SCR_SupplyContainerValueAttribute
Definition
SCR_SupplyContainerValueAttribute.c:3
scripts
Game
Editor
Containers
Attributes
SCR_SupplyContainerValueAttribute.c
Generated by
1.17.0