Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkerEntryDynamicExample.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
6{
7 // Optional: Define attributes for anything you want to be able to change through MapMarkerConfig instead of script
8 [Attribute("", UIWidgets.Object, "Visual configuration")]
9 protected ref SCR_MarkerSimpleConfig m_EntryConfig;
10
11 //------------------------------------------------------------------------------------------------
12 //
13 // Logic for creating & deleting the markers, in this case we just use gamemode events to create marker on player spawn and remove them on player death/deletion
14 //
15 //------------------------------------------------------------------------------------------------
17 void OnPlayerSpawned(int playerId, IEntity player)
18 {
19 if (m_MarkerMgr.GetDynamicMarkerByTarget(GetMarkerType(), player))
20 return;
21
22 SCR_MapMarkerEntity markerEnt = m_MarkerMgr.InsertDynamicMarker(GetMarkerType(), player, 1);
23 markerEnt.SetGlobalVisible(true);
24 }
25
26 //------------------------------------------------------------------------------------------------
28 void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
29 {
30 SCR_MapMarkerEntity markerEnt = m_MarkerMgr.GetDynamicMarkerByTarget(GetMarkerType(), instigatorContextData.GetVictimEntity());
31 if (markerEnt)
32 m_MarkerMgr.RemoveDynamicMarker(markerEnt);
33 }
34
35 //------------------------------------------------------------------------------------------------
37 void OnPlayerDeleted(int playerId, IEntity player)
38 {
39 SCR_MapMarkerEntity markerEnt = m_MarkerMgr.GetDynamicMarkerByTarget(GetMarkerType(), player);
40 if (markerEnt)
41 m_MarkerMgr.RemoveDynamicMarker(markerEnt);
42 }
43
44 //------------------------------------------------------------------------------------------------
45 //
46 // Unique marker type is required for dynamic markers because each requires a custom create/remove logic -> define it here!
47 // While we only add this class to marker config, it needs to be searchable by type using this enum
48 //
49 //------------------------------------------------------------------------------------------------
51 {
52 return SCR_EMapMarkerType.DYNAMIC_EXAMPLE;
53 }
54
55 //------------------------------------------------------------------------------------------------
56 //
57 // This is called during marker widget creation in order to set up marker visuals
58 // Any visual attributes you add to this class should be set through the SCR_MapMarkerDynamicWComponent component here
59 // If SCR_MapMarkerDynamicWComponent is not enough for the job, you will have to create a separate marker layout (assign it in marker config entry) and append your own widget component there
60 //
61 //------------------------------------------------------------------------------------------------
62 override void InitClientSettingsDynamic(notnull SCR_MapMarkerEntity marker, notnull SCR_MapMarkerDynamicWComponent widgetComp)
63 {
64 super.InitClientSettingsDynamic(marker, widgetComp);
65
66 string imgset, icon;
67 m_EntryConfig.GetIconResource(imgset, icon);
68
69 widgetComp.SetImage(imgset, icon);
70 widgetComp.SetColor(m_EntryConfig.GetColor());
71 widgetComp.SetText(m_EntryConfig.GetText());
72 }
73
74 //------------------------------------------------------------------------------------------------
75 //
76 // This serves as entry point and is called automatically by marekr manager when you append this class in the marker config
77 // Logic for creation/removal is setup from here
78 //
79 //------------------------------------------------------------------------------------------------
80 override void InitServerLogic()
81 {
82 super.InitServerLogic();
83
85 if (!gameMode)
86 return;
87
88 gameMode.GetOnPlayerSpawned().Insert(OnPlayerSpawned);
89 gameMode.GetOnPlayerKilled().Insert(OnPlayerKilled);
90 gameMode.GetOnPlayerDeleted().Insert(OnPlayerDeleted);
91 }
92}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_BaseGameMode GetGameMode()
SCR_EMapMarkerType
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerSpawned()
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
Attached to root of marker dynamic base layout.
void SetGlobalVisible(bool state)
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
SCR_BaseGameMode event.
override void InitServerLogic()
override void InitClientSettingsDynamic(notnull SCR_MapMarkerEntity marker, notnull SCR_MapMarkerDynamicWComponent widgetComp)
override SCR_EMapMarkerType GetMarkerType()
ref SCR_MarkerSimpleConfig m_EntryConfig
void OnPlayerSpawned(int playerId, IEntity player)
SCR_BaseGameMode event.
void OnPlayerDeleted(int playerId, IEntity player)
SCR_BaseGameMode event.
Marker dynamic entry base.
SCR_MapMarkerManagerComponent m_MarkerMgr
SCR_FieldOfViewSettings Attribute