Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkerSquadMember.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Markers")]
5
7class SCR_MapMarkerSquadMember : SCR_MapMarkerEntity
8{
9 [RplProp(onRplName: "OnPlayerIdUpdate")]
10 protected int m_iPlayerID; // target ID, needed for visibility rules and fetching group
11
12 protected SCR_MapMarkerSquadMemberComponent m_SquadMemberWidgetComp;
13 protected bool m_bDoLocalVisibilityUpdate;
14
15 //------------------------------------------------------------------------------------------------
18 {
19 m_bDoLocalVisibilityUpdate = false;
20
21 PlayerController pController = GetGame().GetPlayerController();
22 if (!pController)
23 return;
24
25 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
26 if (!groupManager)
27 return;
28
29 if (m_iPlayerID == pController.GetPlayerId()) // if this is us, dont display
30 {
31 SetLocalVisible(false);
32 return;
33 }
34
35 SCR_AIGroup localPlayerGroup = groupManager.GetPlayerGroup(pController.GetPlayerId());
36
37 if (!localPlayerGroup)
38 {
39 SetLocalVisible(false);
40 return;
41 }
42
43 if (localPlayerGroup.IsPlayerLeader(pController.GetPlayerId()) && localPlayerGroup.IsPlayerInGroup(m_iPlayerID))
44 {
45 // player to whom the mark belongs is in the group
46 SetLocalVisible(true);
48 return;
49 }
50
51 SetLocalVisible(false);
52 }
53
54 //------------------------------------------------------------------------------------------------
60
61 //------------------------------------------------------------------------------------------------
63 void SetPlayerID(int id)
64 {
66 m_MarkerFaction = SCR_FactionManager.SGetPlayerFaction(id);
67
68 Replication.BumpMe();
69
70 if (!System.IsConsoleApp())
72
74 }
75
76 //------------------------------------------------------------------------------------------------
79 protected void UpdateTarget()
80 {
81 IEntity ent = GetGame().GetPlayerManager().GetPlayerControlledEntity(m_iPlayerID);
82 if (ent)
83 {
85 if (!charController.IsDead())
86 {
87 SetTarget(ent);
88 SetGlobalVisible(true);
89
90 return;
91 }
92 }
93
94 SetTarget(null);
95 SetGlobalVisible(false);
96 }
97
98 //------------------------------------------------------------------------------------------------
101 {
102 if (!m_wRoot)
103 return;
104
105 if (!m_MarkerFaction)
106 m_MarkerFaction = SCR_FactionManager.SGetPlayerFaction(m_iPlayerID);
107
108 if (!m_MarkerFaction)
109 return;
110
111 m_SquadMemberWidgetComp.SetFaction(m_MarkerFaction);
112 }
113
114 //------------------------------------------------------------------------------------------------
116 protected void OnPlayerLeaderChanged(int groupID, int playerId)
117 {
118 if (m_iPlayerID != playerId)
119 return;
120
121 m_bDoLocalVisibilityUpdate = true;
122 }
123
124 //------------------------------------------------------------------------------------------------
126 protected void OnPlayerAdded(SCR_AIGroup group, int playerId)
127 {
128 if (m_iPlayerID != playerId)
129 return;
130
131 m_bDoLocalVisibilityUpdate = true;
132 }
133
134 //------------------------------------------------------------------------------------------------
136 protected void OnPlayerRemoved(SCR_AIGroup group, int playerId)
137 {
138 if (m_iPlayerID != playerId)
139 return;
140
141 m_bDoLocalVisibilityUpdate = true;
142 }
143
144 //------------------------------------------------------------------------------------------------
145 override protected void OnMapLayerChanged(int layerID)
146 {
147 super.OnMapLayerChanged(layerID);
148
149 if (m_SquadMemberWidgetComp)
150 m_SquadMemberWidgetComp.SetLayerID(layerID);
151 }
152
153 //------------------------------------------------------------------------------------------------
154 override void OnCreateMarker()
155 {
156 RplComponent rplComp = RplComponent.Cast(FindComponent(RplComponent));
157 if (rplComp.IsOwner())
158 {
159 IEntity ent = GetGame().GetPlayerManager().GetPlayerControlledEntity(m_iPlayerID);
160 if (ent)
161 SetTarget(ent);
162 }
163
164 Faction markerFaction = SCR_FactionManager.SGetPlayerFaction(m_iPlayerID);
165 Faction localFaction = SCR_FactionManager.SGetLocalPlayerFaction();
166 if (!localFaction || localFaction.IsFactionEnemy(markerFaction)) // markers could still get streamed in rare cases due to distance based streaming, in which case we check for faction and dont display
167 return;
168
169 super.OnCreateMarker();
170
171 m_bDoLocalVisibilityUpdate = true;
172
173 m_SquadMemberWidgetComp = SCR_MapMarkerSquadMemberComponent.Cast(m_MarkerWidgetComp);
174 }
175
176 //------------------------------------------------------------------------------------------------
177 override void OnUpdate()
178 {
179 // updates only if the marker is visible and when the map is open
180 if (m_bDoLocalVisibilityUpdate)
182
183 if (!m_wRoot)
184 return;
185
186 super.OnUpdate();
187 }
188
189 //------------------------------------------------------------------------------------------------
190 override protected void EOnInit(IEntity owner)
191 {
192 super.EOnInit(owner);
193
194 if (RplSession.Mode() == RplMode.Dedicated)
195 return;
196
200 }
201
202 //------------------------------------------------------------------------------------------------
210}
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
RplMode
Mode of replication.
Definition RplMode.c:9
void SCR_AIGroup(IEntitySource src, IEntity parent)
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SCR_FactionManager(IEntitySource src, IEntity parent)
Widget m_wRoot
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void UpdateLocalVisibility()
Check whether we are in a squad and if it should be visible on map.
void OnPlayerAdded(SCR_AIGroup group, int playerId)
void UpdatePlayerAffiliation()
Check whether we are in a squad and if it should be visible on map.
void UpdateTarget()
void OnPlayerLeaderChanged(int groupID, int playerId)
void OnPlayerRemoved(SCR_AIGroup group, int playerId)
SCR_AIGroup event.
void ~SCR_MapMarkerSquadMember()
void OnPlayerIdUpdate()
Rpl event when m_iPlayerID is updated.
void SetPlayerID(int playerID)
proto external Managed FindComponent(typename typeName)
Main replication API.
Definition Replication.c:14
bool IsPlayerLeader(int playerID)
static ScriptInvoker GetOnPlayerRemoved()
static ScriptInvoker GetOnPlayerLeaderChanged()
static ScriptInvoker GetOnPlayerAdded()
bool IsPlayerInGroup(int playerID)
void OnMapLayerChanged(int layerID)
void EOnInit(IEntity owner)
void SetTarget(IEntity target)
Set entity this marker is tracking.
void OnUpdate()
Called from SCR_MapMarkerManagerComponent.
void SetLocalVisible(bool state)
void SetGlobalVisible(bool state)
void OnCreateMarker()
Fetch marker definition from config & create widget.
SCR_EditorManagerCore m_iPlayerID