Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EntityEnableResourceEditorAttribute.c
Go to the documentation of this file.
3 {
4  [Attribute(EResourceType.SUPPLIES.ToString(), desc: "Which resource is set enabled/disabled", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EResourceType))]
5  protected EResourceType m_eResourceToSetEnabled;
6 
7  //------------------------------------------------------------------------------------------------
8  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
9  {
10  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
11  if (!editableEntity)
12  return null;
13 
14  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(SCR_EntityHelper.FindComponent(editableEntity.GetOwner(), SCR_ResourceComponent));
15  if (!resourceComponent || !resourceComponent.CanResourceTypeEnabledBeChanged(m_eResourceToSetEnabled))
16  return null;
17 
18  //~ Does not use available resources
19  float availableResources;
20 
21  if (!SCR_ResourceSystemHelper.GetAvailableResources(resourceComponent, availableResources))
22  return null;
23 
24  return SCR_BaseEditorAttributeVar.CreateBool(resourceComponent.IsResourceTypeEnabled(m_eResourceToSetEnabled));
25  }
26 
27  //------------------------------------------------------------------------------------------------
28  override void UpdateInterlinkedVariables(SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, bool isInit = false)
29  {
30  if (isInit)
31  manager.SetAttributeEnabled(SCR_EntityEnableResourceEditorAttribute, SCR_ResourceSystemHelper.IsGlobalResourceTypeEnabled(m_eResourceToSetEnabled));
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
36  {
37  if (!var)
38  return;
39 
40  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
41  if (!editableEntity)
42  return;
43 
44  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(SCR_EntityHelper.FindComponent(editableEntity.GetOwner(), SCR_ResourceComponent));
45  if (!resourceComponent || !resourceComponent.CanResourceTypeEnabledBeChanged(m_eResourceToSetEnabled))
46  return;
47 
48  //~ Does not use available resources
49  float availableResources;
50 
51  if (!SCR_ResourceSystemHelper.GetAvailableResources(resourceComponent, availableResources))
52  return;
53 
54  resourceComponent.SetResourceTypeEnabled(var.GetBool(), m_eResourceToSetEnabled);
55  }
56 };
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
SCR_ResourceSystemHelper
Definition: SCR_ResourceSystemHelper.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_EntityEnableResourceEditorAttribute
Definition: SCR_EntityEnableResourceEditorAttribute.c:2
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
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