Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 
46  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
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_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseValueListEditorAttribute
Definition: SCR_BaseValueListEditorAttribute.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SetBuildingProgressEditorAttribute
Definition: SCR_SetBuildingProgressEditorAttribute.c:2
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468