Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DataCollectorCommunicationComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/DataCollection/", description: "Component used to send data to specific clients.")]
5
6class SCR_DataCollectorCommunicationComponent : ScriptComponent
7{
9
10 //------------------------------------------------------------------------------------------------
18
19 //------------------------------------------------------------------------------------------------
25 void SendData(notnull SCR_PlayerData playerData, notnull array<FactionKey> factionKeys, notnull array<float> values, int valuesSize)
26 {
27 Rpc(Rpc_DoSendData, playerData.GetStats(), playerData.GetPreviousStats(), factionKeys, values, valuesSize);
28 }
29
30 //------------------------------------------------------------------------------------------------
37 [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
38 void Rpc_DoSendData(notnull array<float> stats, notnull array<float> previousStats, notnull array<FactionKey> factionKeys, notnull array<float> values, int valuesSize)
39 {
40 foreach (float stat : stats)
41 {
42 Print(stat, LogLevel.DEBUG);
43 }
44
45 foreach (float stat : previousStats)
46 {
47 Print(stat, LogLevel.DEBUG);
48 }
49
50 BaseGameMode gameMode = GetGame().GetGameMode();
51 if (!gameMode)
52 return;
53
54 SCR_DataCollectorComponent dataCollector = GetGame().GetDataCollector();
55 if (!dataCollector)
56 return;
57
58 for (int i = 0, factionsCount = factionKeys.Count(); i < factionsCount; i++)
59 {
60 array<float> valuesForFaction = {};
61 for (int j = 0; j < valuesSize; j++)
62 {
63 valuesForFaction.Insert(values[i * valuesSize + j]);
64 }
65
66 dataCollector.AddStatsToFaction(factionKeys[i], valuesForFaction);
67 }
68
69 SCR_PlayerData playerData = dataCollector.GetPlayerData(0, true, false); // Use 0 as ID for local player, as this is always on the client
70 playerData.SetStats(stats);
71 playerData.SetPreviousStats(previousStats);
72
74 m_OnDataReceived.Invoke(playerData);
75 }
76}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SendData(notnull SCR_PlayerData playerData, notnull array< FactionKey > factionKeys, notnull array< float > values, int valuesSize)
void Rpc_DoSendData(notnull array< float > stats, notnull array< float > previousStats, notnull array< FactionKey > factionKeys, notnull array< float > values, int valuesSize)
notnull ScriptInvoker GetOnDataReceived()
SCR_DataCollectorCommunicationComponentClass m_OnDataReceived
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
void SetStats(array< float > stats)
void SetPreviousStats(array< float > previousStats)
static SCR_PlayerData GetPlayerData(int playerID)
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
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
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134