Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SupportStationAreaMeshComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Area Mesh", description: "")]
3 {
4 }
5 
6 class SCR_SupportStationAreaMeshComponent : SCR_BaseAreaMeshComponent
7 {
8  [Attribute(desc: "Set NONE to get first found support station. Else it will find the specific support station of the same type. It will always search itself, the parent, compartments and the compartments of the parents to find the SupportStation", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ESupportStationType), category: "Support Station")]
9  protected ESupportStationType m_eSearchForType;
10 
11  [Attribute("{6FD8A355A2011A46}Assets/Editor/VirtualArea/VirtualArea_SupportStation_Disabled.emat", desc: "Material mapped on outside and inside of the mesh when support station is disabled. Inside mapping is mirrored.", uiwidget: UIWidgets.ResourcePickerThumbnail, params: "emat", category: "Virtual Area")]
12  protected ResourceName m_sDisabledMaterial;
13 
14  [Attribute("1", desc: "Used when mesh area is a child of the Support Station. This will make sure that the preview displayed when placing is the correct size", category: "Support Station")]
15  protected float m_fRadius;
16 
17  //~ Save ref of support station after getting it
18  protected SCR_BaseSupportStationComponent m_SupportStationComponent;
19 
20  //------------------------------------------------------------------------------------------------
21  override float GetRadius()
22  {
24  return m_fRadius;
25 
26  //~ Range is set to Pow2 in runtime so make sure to Sqrt it
27  if (SCR_Global.IsEditMode())
28  return m_SupportStationComponent.GetRange();
29  else
30  return Math.Sqrt(m_SupportStationComponent.GetRange());
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  //~ Get support station component from owner, parent or siblings
35  protected SCR_BaseSupportStationComponent GetSupportStation(IEntity owner)
36  {
37  if (!owner)
38  return null;
39 
40  SCR_BaseSupportStationComponent supportStation = SCR_BaseSupportStationComponent.FindSupportStation(owner, m_eSearchForType, SCR_EComponentFinderQueryFlags.ENTITY | SCR_EComponentFinderQueryFlags.SLOTS | SCR_EComponentFinderQueryFlags.PARENT);
41 
42  if (supportStation && supportStation.GetOwner() != owner && supportStation.GetOwner() != owner.GetParent())
43  {
44  if (SCR_Global.IsEditMode() && m_fRadius != supportStation.GetRange())
45  Print("'SCR_SupportStationAreaMeshComponent' is on a child entity yet the m_fRadius (" + m_fRadius + ") is not equal to the support Station range (" + supportStation.GetRange() + ") make sure it is equal else the preview will not show correctly", LogLevel.ERROR);
46  else if (!SCR_Global.IsEditMode() && m_fRadius != Math.Sqrt(supportStation.GetRange()))
47  Print("'SCR_SupportStationAreaMeshComponent' is on a child entity yet the m_fRadius (" + m_fRadius + ") is not equal to the support Station range (" + Math.Sqrt(supportStation.GetRange()) + ") make sure it is equal else the preview will not show correctly", LogLevel.ERROR);
48  }
49 
50  return supportStation;
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  //~ Get material used for area mesh. Enabled states sets the correct mesh area
55  protected override ResourceName GetMaterial()
56  {
58  return m_sDisabledMaterial;
59  else
60  return super.GetMaterial();
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  //~ Regenerates mesh area if on enabled changed as material changed
65  protected void OnEnabledChanged(bool enabled)
66  {
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  override void EOnInit(IEntity owner)
72  {
73  if (!owner)
74  return;
75 
77 
78  //~ Did not find support station
80  {
81  //~ Give warning in workbench
82  #ifdef WORKBENCH
83  Print("'SCR_SupportStationAreaMeshComponent' (" + owner + ") Component must be attached to enity with SCR_BaseSupportStationComponent! BasePrefab should not have a support Station component", LogLevel.WARNING);
84  return;
85  #endif
86 
87  //~ Call one frame later to make sure that Support Station component is known to system
88  GetGame().GetCallqueue().CallLater(Init, param1: owner);
89  return;
90  }
91 
92  //~ Call actual init if Support Station was found
93  Init(owner);
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  protected void Init(IEntity owner)
98  {
100  {
102 
104  {
105  Print("'SCR_SupportStationAreaMeshComponent' (" + owner + ") Component must be attached to enity with SCR_BaseSupportStationComponent! BasePrefab should not have a support Station component", LogLevel.WARNING);
106  return;
107  }
108  }
109 
110  //~ Ignore if does not use range
111  if (!m_SupportStationComponent.UsesRange())
112  return;
113 
114  vector offset = m_SupportStationComponent.GetOffset();
115  if (offset != vector.Zero)
116  {
117  if (m_SupportStationComponent.GetOwner() != owner)
118  {
119  vector localTransform[4];
120  owner.GetLocalTransform(localTransform);
121 
122  if (localTransform[3] != offset)
123  Print("'SCR_SupportStationAreaMeshComponent' (" + owner + ") linked support station (" + typename.EnumToString(ESupportStationType, m_SupportStationComponent.GetSupportStationType()) + ") has an offset but the local position of the area mesh is: '" + localTransform[3] + "' were as the support station offset is '" + offset + "' this must be the same else the zone shows an incorrect area!", LogLevel.ERROR);
124  }
125  else
126  {
127  Print("'SCR_SupportStationAreaMeshComponent' (" + owner + ") linked support station (" + typename.EnumToString(ESupportStationType, m_SupportStationComponent.GetSupportStationType()) + ") has an offset but the support station is on the same entity as the mesh so no offset could be given. Make the mesh a child entity of the support station else the zone shows an incorrect area!", LogLevel.ERROR);
128  }
129  }
130 
131  //~ Only show when enabled. If disabled it will only start showing the zone if enabled in runtime (including disabled zone)
132  if (m_SupportStationComponent.IsEnabled())
134 
135  //~ Listen to when support station is enabled/disabled
136  m_SupportStationComponent.GetOnEnabledChanged().Insert(OnEnabledChanged);
137  }
138 
139  //------------------------------------------------------------------------------------------------
140  override void OnDelete(IEntity owner)
141  {
142  super.OnDelete(owner);
143 
145  m_SupportStationComponent.GetOnEnabledChanged().Remove(OnEnabledChanged);
146  }
147 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
Init
protected void Init(IEntity owner)
Definition: SCR_SupportStationAreaMeshComponent.c:97
GetRadius
override float GetRadius()
Definition: SCR_SupportStationAreaMeshComponent.c:21
GetSupportStation
protected SCR_BaseSupportStationComponent GetSupportStation(IEntity owner)
Definition: SCR_SupportStationAreaMeshComponent.c:35
SCR_BaseAreaMeshComponentClass
Definition: SCR_BaseAreaMeshComponent.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnDelete
override void OnDelete(IEntity owner)
Definition: SCR_SupportStationAreaMeshComponent.c:140
OnEnabledChanged
protected void OnEnabledChanged(bool enabled)
Definition: SCR_SupportStationAreaMeshComponent.c:65
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetMaterial
protected override ResourceName GetMaterial()
Definition: SCR_SupportStationAreaMeshComponent.c:55
ESupportStationType
ESupportStationType
Definition: ESupportStationType.c:2
Attribute
SCR_SupportStationAreaMeshComponentClass SCR_BaseAreaMeshComponentClass Attribute(desc:"Set NONE to get first found support station. Else it will find the specific support station of the same type. It will always search itself, the parent, compartments and the compartments of the parents to find the SupportStation", uiwidget:UIWidgets.SearchComboBox, enums:ParamEnumArray.FromEnum(ESupportStationType), category:"Support Station")] protected ESupportStationType m_eSearchForType
m_fRadius
protected float m_fRadius
Definition: SCR_SupportStationAreaMeshComponent.c:15
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_SupportStationAreaMeshComponent.c:71
SCR_EComponentFinderQueryFlags
SCR_EComponentFinderQueryFlags
Used for component finding to know where it can search to get the given component.
Definition: SCR_EntityHelper.c:424
SCR_Global
Definition: Functions.c:6
m_SupportStationComponent
protected SCR_BaseSupportStationComponent m_SupportStationComponent
Definition: SCR_SupportStationAreaMeshComponent.c:18
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_sDisabledMaterial
protected ResourceName m_sDisabledMaterial
Definition: SCR_SupportStationAreaMeshComponent.c:12
GenerateAreaMesh
void GenerateAreaMesh()
Generate area mesh based on its settings.
Definition: SCR_BaseAreaMeshComponent.c:128
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_SupportStationAreaMeshComponentClass
Definition: SCR_SupportStationAreaMeshComponent.c:2