Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableEntityComponentClass.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
2 class SCR_EditableEntityComponentClass : ScriptComponentClass
3 {
4  [Attribute("0", UIWidgets.ComboBox, category: "Editable Entity", desc: "System type of the entity.", enums: ParamEnumArray.FromEnum(EEditableEntityType))]
5  protected EEditableEntityType m_EntityType;
6 
7  [Attribute(category: "Visualization", desc: "GUI representation")]
8  protected ref SCR_UIInfo m_UIInfo;
9 
10  [Attribute("", UIWidgets.Auto, category: "Visualization", desc: "Bone to which the icon is attached to")]
11  protected string m_sIconBoneName;
12 
13  [Attribute(category: "Editable Entity")]
14  protected ref SCR_EditableEntityInteraction m_EntityInteraction;
15 
16  //------------------------------------------------------------------------------------------------
19  EEditableEntityType GetEntityType()
20  {
21  return m_EntityType;
22  }
23 
24  //------------------------------------------------------------------------------------------------
27  SCR_UIInfo GetInfo()
28  {
29  return m_UIInfo;
30  }
31 
32  //------------------------------------------------------------------------------------------------
35  string GetIconBoneName()
36  {
37  return m_sIconBoneName;
38  }
39 
40  //------------------------------------------------------------------------------------------------
43  SCR_EditableEntityInteraction GetEntityInteraction()
44  {
45  if (m_EntityInteraction)
46  return m_EntityInteraction;
47 
49  if (core)
50  return core.GetEntityInteraction(GetEntityType());
51  else
52  return null;
53  }
54 
55  //------------------------------------------------------------------------------------------------
59  static IEntityComponentSource GetEditableEntitySource(Resource entityResource)
60  {
61  if (!entityResource)
62  return null;
63 
64  BaseResourceObject entityBase = entityResource.GetResource();
65  if (!entityBase)
66  return null;
67 
68  IEntitySource entitySource = entityBase.ToEntitySource();
69  if (!entitySource)
70  return null;
71 
72  return GetEditableEntitySource(entitySource);
73  }
74 
75  //------------------------------------------------------------------------------------------------
79  static IEntityComponentSource GetEditableEntitySource(IEntitySource entitySource)
80  {
81  if (!entitySource)
82  return null;
83 
84  int componentsCount = entitySource.GetComponentCount();
85  for (int i = 0; i < componentsCount; i++)
86  {
87  IEntityComponentSource componentSource = entitySource.GetComponent(i);
88  if (componentSource.GetClassName().ToType().IsInherited(SCR_EditableEntityComponent))
89  return componentSource;
90  }
91  return null;
92  }
93 
94  //------------------------------------------------------------------------------------------------
98  static SCR_EditableEntityUIInfo GetInfo(IEntityComponentSource componentSource)
99  {
100  BaseContainer infoSource = componentSource.GetObject("m_UIInfo");
101  if (!infoSource)
102  return null;
103 
104  SCR_EditableEntityUIInfo info = SCR_EditableEntityUIInfo.Cast(BaseContainerTools.CreateInstanceFromContainer(infoSource));
105  info.InitFromSource(componentSource);
106  return info;
107  }
108 
109  //------------------------------------------------------------------------------------------------
113  static EEditableEntityType GetEntityType(IEntityComponentSource componentSource)
114  {
116  componentSource.Get("m_EntityType", type);
117  return type;
118  }
119 
120  //------------------------------------------------------------------------------------------------
124  static SCR_EditableEntityInteraction GetEntityInteraction(IEntityComponentSource componentSource)
125  {
126  BaseContainer container = componentSource.GetObject("m_EntityInteraction");
127  if (container)
128  return SCR_EditableEntityInteraction.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
129 
131  if (core)
132  return core.GetEntityInteraction(GetEntityType(componentSource));
133  else
134  return null;
135  }
136 
137  //------------------------------------------------------------------------------------------------
141  static ResourceName GetSlotPrefab(IEntityComponentSource componentSource)
142  {
143  BaseContainer info = componentSource.GetObject("m_UIInfo");
144  if (!info)
145  return ResourceName.Empty;
146 
147  ResourceName slotPrefab;
148  info.Get("m_SlotPrefab", slotPrefab);
149  return slotPrefab;
150  }
151 
152  //------------------------------------------------------------------------------------------------
156  static EEditableEntityFlag GetEntityFlags(IEntityComponentSource componentSource)
157  {
158  EEditableEntityFlag flags;
159  componentSource.Get("m_Flags", flags);
160  return flags;
161  }
162 
163  //------------------------------------------------------------------------------------------------
168  static bool HasFlag(IEntityComponentSource componentSource, EEditableEntityFlag flag)
169  {
170  EEditableEntityFlag flags;
171  componentSource.Get("m_Flags", flags);
172  return flags & flag;
173  }
174 
175  //------------------------------------------------------------------------------------------------
181  static bool GetEntitySourceBudgetCost(IEntityComponentSource editableEntitySource, out notnull array<ref SCR_EntityBudgetValue> budgetValues)
182  {
183  if (!editableEntitySource)
184  return false;
185 
186  SCR_EditableEntityUIInfo editableEntityUIInfo = SCR_EditableEntityUIInfo.Cast(SCR_EditableEntityComponentClass.GetInfo(editableEntitySource));
187  if (editableEntityUIInfo)
188  return editableEntityUIInfo.GetEntityBudgetCost(budgetValues);
189 
190  return !budgetValues.IsEmpty();
191  }
192 
193  //------------------------------------------------------------------------------------------------
198  static bool GetEntitySourceChildrenBudgetCosts(IEntityComponentSource editableEntitySource, out notnull array<ref SCR_EntityBudgetValue> budgetValues)
199  {
200  if (!editableEntitySource)
201  return false;
202 
203  SCR_EditableEntityUIInfo editableEntityUIInfo = SCR_EditableEntityUIInfo.Cast(SCR_EditableEntityComponentClass.GetInfo(editableEntitySource));
204  if (editableEntityUIInfo)
205  editableEntityUIInfo.GetEntityChildrenBudgetCost(budgetValues);
206 
207  return !budgetValues.IsEmpty();
208  }
209 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition: EEditableEntityFlag.c:5
SCR_EditableEntityCore
Definition: SCR_EditableEntityCore.c:10
m_UIInfo
protected SCR_UIInfo m_UIInfo
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:17
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_EditableEntityInteraction
Definition: SCR_EditableEntityInteraction.c:2
SCR_EditableEntityComponentClass
Definition: SCR_EditableEntityComponentClass.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180