Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SpawnPointSpawnRequestComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Respawn/PlayerController")]
5
6class SCR_SpawnPointRespawnRequestComponent : SCR_SpawnRequestComponent
7{
8 //------------------------------------------------------------------------------------------------
9 override typename GetHandlerType()
10 {
11 return SCR_SpawnPointSpawnHandlerComponent;
12 }
13
14 //------------------------------------------------------------------------------------------------
15 override typename GetDataType()
16 {
18 }
19
20 //------------------------------------------------------------------------------------------------
22 {
23 #ifdef _ENABLE_RESPAWN_LOGS
24 Print(string.Format("%1::DoCanRequestRespawn(playerId: %2, data: %3)", Type().ToString(),
26 #endif
27
29 if (!spawnPointData)
30 return false;
31
32 Rpc(Rpc_CanRequestRespawn_S, spawnPointData.GetRplId(), spawnPointData.GetPrefab());
33 return true;
34 }
35
36 //------------------------------------------------------------------------------------------------
37 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
38 private void Rpc_CanRequestRespawn_S(int spawnPointId, ResourceName prefab)
39 {
40 #ifdef _ENABLE_RESPAWN_LOGS
41 Print(string.Format("%1::Rpc_CanRequestRespawn_S(playerId: %2, spawnPointId: %3, pref: %4)", Type().ToString(),
43 spawnPointId,
44 prefab), LogLevel.NORMAL);
45 #endif
46
47 // Prepare data for handler
48 SCR_SpawnPointSpawnData data = new SCR_SpawnPointSpawnData(prefab, spawnPointId);
50 }
51
52 //------------------------------------------------------------------------------------------------
53 override bool DoRequestRespawn(SCR_SpawnData data)
54 {
55 #ifdef _ENABLE_RESPAWN_LOGS
56 Print(string.Format("%1::DoRequestRespawn(playerId: %2, data: %3)", Type().ToString(),
58 #endif
59
60 SCR_SpawnPointSpawnData spawnPointData = SCR_SpawnPointSpawnData.Cast(data);
61 if (!spawnPointData)
62 return false;
63
64 Rpc(Rpc_RequestRespawn_S, spawnPointData.GetRplId(), spawnPointData.GetPrefab());
65 return true;
66 }
67
68 //------------------------------------------------------------------------------------------------
69 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
70 private void Rpc_RequestRespawn_S(int spawnPointId, ResourceName prefab)
71 {
72 #ifdef _ENABLE_RESPAWN_LOGS
73 Print(string.Format("%1::Rpc_RequestRespawn_S(playerId: %2, spawnPointId: %3, pref: %4)", Type().ToString(),
75 spawnPointId,
76 prefab), LogLevel.NORMAL);
77 #endif
78
79 // Prepare data for handler
80 SCR_SpawnPointSpawnData data = new SCR_SpawnPointSpawnData(prefab, spawnPointId);
82 }
83
84 #ifdef ENABLE_DIAG
85 //------------------------------------------------------------------------------------------------
86 override SCR_BaseRespawnDiag CreateDiag()
87 {
88 return new SCR_SpawnPointRespawnDiag();
89 }
90 #endif
91}
92
93#ifdef ENABLE_DIAG
94class SCR_SpawnPointRespawnDiag : SCR_RespawnDiag<SCR_SpawnPointRespawnRequestComponent>
95{
96 protected string m_Prefab = "{7A9EE19AB67B298B}Prefabs/Characters/Factions/INDFOR/FIA/Character_FIA_base.et";
97 protected RplId m_RplId;
98
99 override void DrawContent()
100 {
101 super.DrawContent();
102 DbgUI.InputText("Prefab: ", m_Prefab);
103 DbgUI.InputInt("RplId: ", m_RplId);
104
105 DbgUI.Spacer(32);
106 DbgUI.Text("======== UTILITY ========");
107 int index;
108 DbgUI.InputInt("Index2Id: ", index);
109 SCR_SpawnPoint point = SCR_SpawnPoint.GetSpawnPointByIndex(index);
110 if (point)
111 {
112 string strRplId = point.GetRplId().ToString();
113 DbgUI.Text(string.Format("Point index: %1\n\tRplId: %2\n\tFaction: %3\n\tType: %4",
114 index, strRplId, point.GetFactionKey(), point.Type().ToString()));
115
116 SCR_PlayerSpawnPoint psp = SCR_PlayerSpawnPoint.Cast(point);
117 if (psp)
118 {
119 int pid = psp.GetPlayerID();
120 string pnam = GetGame().GetPlayerManager().GetPlayerName(pid);
121 DbgUI.Text(string.Format(" playerId: %1\n playerName: %2", pid, pnam));
122 }
123
124 DbgUI.Text(string.Format("IsActive: %1", point.IsSpawnPointActive()));
125
126 if (DbgUI.Button("Copy RplId to clipboard"))
127 System.ExportToClipboard(strRplId);
128 }
129 else
130 {
131 DbgUI.Text(string.Format("No spawn point at index: %1", index));
132 }
133 }
134
135 //------------------------------------------------------------------------------------------------
136 protected override SCR_SpawnData CreateData()
137 {
138 return new SCR_SpawnPointSpawnData(m_Prefab, m_RplId);
139 }
140}
141#endif
ResourceName m_Prefab
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Get all prefabs that have the spawner data
SCR_FreeSpawnRequestComponentClass SCR_SpawnRequestComponentClass GetHandlerType()
override GetDataType()
bool DoRequestRespawn(SCR_SpawnData data)
void ProcessRequest_S(SCR_SpawnData data)
void ProcessCanRequest_S(SCR_SpawnData data)
bool DoCanRequestRespawn(SCR_SpawnData data)
int Type
string GetFactionKey()
bool IsSpawnPointActive()
override ResourceName GetPrefab()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto external PlayerController GetPlayerController()
proto external int GetPlayerId()
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
int RplId
Definition EnNetwork.c:33
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.