Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableDescriptorComponent.c
Go to the documentation of this file.
1 void ScriptInvoker_EditableDescriptorLocationChangeMethod(SCR_EditableCommentComponent location);
3 typedef ScriptInvokerBase<ScriptInvoker_EditableDescriptorLocationChangeMethod> ScriptInvoker_EditableDescriptorLocationChange;
4 
5 [ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
7 {
8 }
9 
11 
13 class SCR_EditableDescriptorComponent : SCR_EditableSystemComponent
14 {
15  [Attribute("300", UIWidgets.Slider, "Detect locations within this radius.", params: "0 10000 1")]
16  protected float m_fMaxLocationSize;
17 
23 
24  //------------------------------------------------------------------------------------------------
27  {
28  if (!m_OnChange)
30 
31  return m_OnChange;
32  }
33 
34  //------------------------------------------------------------------------------------------------
38  bool UpdateNearestLocation(vector pos = vector.Zero)
39  {
41  if (!core)
42  return false;
43 
44  //--- Find nearest location
45  if (pos == vector.Zero)
46  pos = GetOwner().GetOrigin();
47 
48  EntityID nearestLocationID;
49  SCR_EditableEntityComponent nearestLocation = core.FindNearestEntity(pos, EEditableEntityType.COMMENT, EEditableEntityFlag.LOCAL);
50  if (nearestLocation)
51  {
52  //--- Check if it's close enough
53  vector locationPos;
54  if (nearestLocation.GetPos(locationPos) && vector.DistanceSqXZ(locationPos, pos) < m_fMaxLocationSize)
55  {
56  //--- Terminate if the location didn't change
57  nearestLocationID = nearestLocation.GetOwner().GetID();
58  if (nearestLocationID == m_NearestLocationID)
59  return false;
60  }
61  }
62 
63  //--- Update
64  UpdateNearestLocationBroadcast(nearestLocationID);
65  Rpc(UpdateNearestLocationBroadcast, nearestLocationID);
66  return true;
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
71  protected void UpdateNearestLocationBroadcast(EntityID nearestLocationID)
72  {
73  m_NearestLocationID = nearestLocationID;
74 
75  IEntity nearestLocationEntity = GetGame().GetWorld().FindEntityByID(m_NearestLocationID);
76  m_NearestLocation = SCR_EditableEntityComponent.GetEditableEntity(nearestLocationEntity);
77 
79  if (m_OnChange)
80  m_OnChange.Invoke(SCR_EditableCommentComponent.Cast(m_NearestLocation));
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  protected void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation);
85 
86  //------------------------------------------------------------------------------------------------
87  protected void UpdateInfo(SCR_UIDescription from = null)
88  {
89  if (!m_UIInfoDescriptor)
90  {
92  m_UIInfoDescriptor.CopyFrom(GetInfo());
93  SetInfoInstance(m_UIInfoDescriptor);
94  }
95 
96  //--- Copy custom texts
97  if (from)
98  m_UIInfoDescriptor.CopyFrom(from);
99 
100  if (m_NearestLocation)
101  m_UIInfoDescriptor.SetLocationName(m_NearestLocation.GetInfo().GetName());
102  else
103  m_UIInfoDescriptor.SetLocationName(GetOwner().GetOrigin());
104 
105  Event_OnUIRefresh.Invoke();
106  }
107 
108  //------------------------------------------------------------------------------------------------
109  override bool RplSave(ScriptBitWriter writer)
110  {
111  if (!super.RplSave(writer))
112  return false;
113 
114  writer.WriteEntityId(m_NearestLocationID);
115 
116  return true;
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  override bool RplLoad(ScriptBitReader reader)
121  {
122  if (!super.RplLoad(reader))
123  return false;
124 
125  reader.ReadEntityId(m_NearestLocationID);
126 
128 
129  return true;
130  }
131 
132  //------------------------------------------------------------------------------------------------
133  // constructor
137  void SCR_EditableDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
138  {
139  m_fMaxLocationSize *= m_fMaxLocationSize;
140  }
141 }
GetOnLocationChange
protected void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
Definition: SCR_EditableSpawnPointComponent.c:24
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition: EEditableEntityFlag.c:5
SCR_EditableEntityCore
Definition: SCR_EditableEntityCore.c:10
SCR_EditableDescriptorUIInfo
Definition: SCR_EditableDescriptorUIInfo.c:2
Attribute
SCR_EditableDescriptorComponentClass SCR_EditableSystemComponentClass Attribute("300", UIWidgets.Slider, "Detect locations within this radius.", params:"0 10000 1")] protected float m_fMaxLocationSize
Editable entity which can contain location description.
Event_OnUIRefresh
protected ref ScriptInvoker Event_OnUIRefresh
Definition: SCR_EditableGroupComponent.c:38
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
RplSave
override bool RplSave(ScriptBitWriter writer)
Definition: SCR_EditableDescriptorComponent.c:109
GetInfo
override SCR_UIInfo GetInfo(IEntity owner=null)
Definition: SCR_EditablePlayerDelegateComponent.c:140
m_NearestLocationID
protected EntityID m_NearestLocationID
Definition: SCR_EditableDescriptorComponent.c:19
m_UIInfoDescriptor
protected ref SCR_EditableDescriptorUIInfo m_UIInfoDescriptor
Definition: SCR_EditableDescriptorComponent.c:21
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
func
func
Definition: SCR_AIThreatSystem.c:5
m_OnChange
protected ref ScriptInvoker_EditableDescriptorLocationChange m_OnChange
Definition: SCR_EditableDescriptorComponent.c:22
GetOrigin
vector GetOrigin()
Definition: SCR_AIUtilityComponent.c:279
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_EditableDescriptorComponent.c:120
ScriptInvoker_EditableDescriptorLocationChange
ScriptInvokerBase< ScriptInvoker_EditableDescriptorLocationChangeMethod > ScriptInvoker_EditableDescriptorLocationChange
Definition: SCR_EditableDescriptorComponent.c:3
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
EntityID
SCR_CompositionSlotManagerComponentClass EntityID
GetOnChange
ScriptInvoker_EditableDescriptorLocationChange GetOnChange()
Definition: SCR_EditableDescriptorComponent.c:26
m_sLocationName
protected LocalizedString m_sLocationName
Definition: SCR_EditableDescriptorComponent.c:18
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
ScriptInvoker_EditableDescriptorLocationChangeMethod
func ScriptInvoker_EditableDescriptorLocationChangeMethod
Definition: SCR_EditableDescriptorComponent.c:2
UpdateNearestLocation
bool UpdateNearestLocation(vector pos=vector.Zero)
Definition: SCR_EditableDescriptorComponent.c:38
SCR_EditableDescriptorComponentClass
Definition: SCR_EditableDescriptorComponent.c:6
SCR_EditableSystemComponentClass
Definition: SCR_EditableSystemComponent.c:2
UpdateInfo
protected void UpdateInfo(SCR_UIDescription from=null)
Definition: SCR_EditableDescriptorComponent.c:87
m_NearestLocation
protected SCR_EditableEntityComponent m_NearestLocation
Definition: SCR_EditableDescriptorComponent.c:20
SCR_EditableDescriptorComponent
void SCR_EditableDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_EditableDescriptorComponent.c:137
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
LocalizedString
Definition: LocalizedString.c:21
SCR_UIDescription
Definition: SCR_UIDescription.c:5
UpdateNearestLocationBroadcast
protected void UpdateNearestLocationBroadcast(EntityID nearestLocationID)
Definition: SCR_EditableDescriptorComponent.c:71
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180