Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SupplyContainerDecayAttribute.c
Go to the documentation of this file.
3 {
4  [Attribute()]
5  float m_fDefaultDecayTickRate;
6 
7  [Attribute()]
8  float m_fDefaultDecayValue;
9 
10  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
11  {
12  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
13  if (!editableEntity)
14  return null;
15 
16  GenericEntity entity = editableEntity.GetOwnerScripted();
17  if (!entity)
18  return null;
19 
20  RplComponent rpl = RplComponent.Cast(entity.FindComponent(RplComponent));
21  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(entity);
22  if (!resourceComponent)
23  return null;
24 
25  SCR_ResourceContainer supplyContainer = resourceComponent.GetContainer(EResourceType.SUPPLIES);
26  //:| Dont display Attribute for encapsulated Containers.
27  if (!supplyContainer || supplyContainer.IsEncapsulated())
28  return null;
29 
30  return SCR_BaseEditorAttributeVar.CreateBool(supplyContainer.IsResourceDecayEnabled());
31  }
32 
33  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
34  {
35  SCR_ResourceContainer supplyContainer = GetResourceContainer(item);
36 
37  //:| Dont display Attribute for encapsulated Containers.
38  if (!supplyContainer || supplyContainer.IsEncapsulated())
39  return;
40 
41  bool enabled = var.GetBool();
42  supplyContainer.EnableDecay(enabled);
43 
44  if (!enabled)
45  return;
46 
47  if (supplyContainer.GetResourceDecayTickrate() <= 0)
48  supplyContainer.SetResourceDecayTickrate(m_fDefaultDecayTickRate);
49 
50  if (supplyContainer.GetResourceDecay() <= 0)
51  supplyContainer.SetResourceDecay(m_fDefaultDecayValue);
52  }
53 
54  SCR_ResourceContainer GetResourceContainer(Managed item)
55  {
56  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
57  if (!editableEntity)
58  return null;
59 
60  GenericEntity entity = editableEntity.GetOwnerScripted();
61  if (!entity)
62  return null;
63 
64  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(entity);
65  if (!resourceComponent)
66  return null;
67 
68  return resourceComponent.GetContainer(EResourceType.SUPPLIES);
69  }
70 }
SCR_SupplyContainerDecayAttribute
Definition: SCR_SupplyContainerDecayAttribute.c:2
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
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
SCR_ResourceContainer
Definition: SCR_ResourceContainer.c:34
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