Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SetPropBaseBudgetEditorAttribute.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  IEntity provider = editableEntity.GetOwner();
12  if (!provider)
13  return null;
14 
15  SCR_CampaignBuildingProviderComponent providerComponent = GetProviderComponent(provider);
16  if (!providerComponent)
17  return null;
18 
19  //~ Send over current and max value as max value is used in UI to set slider max.
20  return SCR_BaseEditorAttributeVar.CreateFloat((providerComponent.GetCurrentPropValue() / providerComponent.GetMaxBudgetValue(EEditableEntityBudget.PROPS)) * 100);
21  }
22 
23  //------------------------------------------------------------------------------------------------
24  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
25  {
26  if (!var)
27  return;
28 
29  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
30  if (!editableEntity)
31  return;
32 
33  IEntity provider = editableEntity.GetOwner();
34  if (!provider)
35  return;
36 
37  SCR_CampaignBuildingProviderComponent providerComponent = GetProviderComponent(provider);
38  if (!providerComponent)
39  return;
40 
41  providerComponent.SetPropValue(providerComponent.GetMaxBudgetValue(EEditableEntityBudget.PROPS) * (var.GetFloat() * 0.01));
42  }
43 
44  //------------------------------------------------------------------------------------------------
46  SCR_CampaignBuildingProviderComponent GetProviderComponent(notnull IEntity entity)
47  {
48  array<IEntity> output = {};
49  SCR_EntityHelper.GetHierarchyEntityList(entity, output);
50 
51  foreach (IEntity ent : output)
52  {
53  SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(ent.FindComponent(SCR_CampaignBuildingProviderComponent));
54  if (providerComponent)
55  return providerComponent;
56  }
57 
58  return null;
59  }
60 };
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
EEditableEntityBudget
EEditableEntityBudget
Definition: EEditableEntityBudget.c:1
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
SetPropBaseBudgetEditorAttribute
Definition: SCR_SetPropBaseBudgetEditorAttribute.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