Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
29  {
30  SCR_MapMarkerEntity markerEnt = m_MarkerMgr.GetDynamicMarkerByTarget(GetMarkerType(), playerEntity);
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  //------------------------------------------------------------------------------------------------
50  override SCR_EMapMarkerType GetMarkerType()
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 }
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_MapMarkerDynamicWComponent
Attached to root of marker dynamic base layout.
Definition: SCR_MapMarkerDynamicWComponent.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_MapMarkerTitle
Definition: SCR_MapMarkerEntryPlaced.c:189
SCR_MapMarkerEntryDynamic
Marker dynamic entry base.
Definition: SCR_MapMarkerEntryDynamic.c:4
Instigator
Definition: Instigator.c:6
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_MapMarkerEntity
Definition: SCR_MapMarkerEntity.c:10
SCR_EMapMarkerType
SCR_EMapMarkerType
Definition: SCR_MapMarkerConfig.c:5
SCR_MapMarkerEntryDynamicExample
Definition: SCR_MapMarkerEntryDynamicExample.c:5
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468