Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableDescriptorComponent.c
Go to the documentation of this file.
3typedef ScriptInvokerBase<ScriptInvoker_EditableDescriptorLocationChangeMethod> ScriptInvoker_EditableDescriptorLocationChange;
4
5[ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
9
11
13class 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 //------------------------------------------------------------------------------------------------
33
34 //------------------------------------------------------------------------------------------------
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;
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);
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 {
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
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
138 {
139 m_fMaxLocationSize *= m_fMaxLocationSize;
140 }
141}
vector location
ArmaReforgerScripted GetGame()
Definition game.c:1398
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
vector GetOrigin()
override bool RplSave(ScriptBitWriter writer)
EntityID m_NearestLocationID
void UpdateNearestLocationBroadcast(EntityID nearestLocationID)
LocalizedString m_sLocationName
void SCR_EditableDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_EditableEntityComponent m_NearestLocation
ref SCR_EditableDescriptorUIInfo m_UIInfoDescriptor
ScriptInvokerBase< ScriptInvoker_EditableDescriptorLocationChangeMethod > ScriptInvoker_EditableDescriptorLocationChange
ScriptInvoker_EditableDescriptorLocationChange GetOnChange()
ref ScriptInvoker_EditableDescriptorLocationChange m_OnChange
void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
bool UpdateNearestLocation(vector pos=vector.Zero)
func ScriptInvoker_EditableDescriptorLocationChangeMethod
void UpdateInfo(SCR_UIDescription from=null)
ref ScriptInvoker Event_OnUIRefresh
override SCR_UIInfo GetInfo()
proto external vector GetOrigin()
proto external BaseWorld GetWorld()
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
SCR_EditableEntityComponent FindNearestEntity(vector pos, EEditableEntityType type, EEditableEntityFlag flags=0, bool onlyDirect=true)
IEntity GetOwner()
Owner entity of the fuel tank.
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
EEditableEntityFlag
Unique flags of the entity.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14