Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SetBuildingProgressEditorAttribute.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
6 {
8 if (!editableEntity)
9 return null;
10
11 SCR_CampaignBuildingLayoutComponent layoutComponent = GetLayoutComponent(editableEntity);
12 if (!layoutComponent)
13 return null;
14
15 if (layoutComponent.GetToBuildValue() <= 0)
16 return null;
17
18 //~ Send over current and max value as max value is used in UI to set slider max.
19 return SCR_BaseEditorAttributeVar.CreateFloat((layoutComponent.GetCurrentBuildValue() / layoutComponent.GetToBuildValue()) * 100);
20 }
21
22 //------------------------------------------------------------------------------------------------
23 protected SCR_CampaignBuildingLayoutComponent GetLayoutComponent(notnull SCR_EditableEntityComponent editableEntity)
24 {
25 IEntity child = editableEntity.GetOwner().GetChildren();
26 SCR_CampaignBuildingLayoutComponent layoutComponent;
27 while (child)
28 {
29 // The preview exist at this moment but will be deleted, skip it.
30 layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(child.FindComponent(SCR_CampaignBuildingLayoutComponent));
31 if (layoutComponent)
32 break;
33
34 child = child.GetSibling();
35 }
36
37 return layoutComponent;
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
42 {
43 if (!var)
44 return;
45
47 if (!editableEntity)
48 return;
49
50 SCR_CampaignBuildingLayoutComponent layoutComponent = GetLayoutComponent(editableEntity);
51 if (!layoutComponent)
52 return;
53
54 layoutComponent.SetBuildingValue(layoutComponent.GetToBuildValue() * (var.GetFloat() * 0.01));
55 }
56};
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external Managed FindComponent(typename typeName)
proto external IEntity GetChildren()
proto external IEntity GetSibling()
static SCR_BaseEditorAttributeVar CreateFloat(float value)
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
SCR_CampaignBuildingLayoutComponent GetLayoutComponent(notnull SCR_EditableEntityComponent editableEntity)