|
@@ -13,16 +13,18 @@ namespace KairoEngine.SteamIntegration
|
|
|
public string statisticsBroadcastEvent = "SetStatisticData";
|
|
|
public bool listenForStatisticsEvents = true;
|
|
|
public string statisticsEvent = "StatisticDataChanged";
|
|
|
+ public bool debug = false;
|
|
|
|
|
|
[InlineEditor(InlineEditorObjectFieldModes.Boxed), PropertySpace(4,0)]
|
|
|
public SteamworksStatLibrary steamStats;
|
|
|
|
|
|
- public void Start(SteamworksStatLibrary steamStatsLibrary)
|
|
|
+ public void Start(SteamworksStatLibrary steamStatsLibrary, bool debug = false)
|
|
|
{
|
|
|
+ this.debug = debug;
|
|
|
if(steamStats == null) steamStats = steamStatsLibrary;
|
|
|
+ if(broadcastStatsOnStart) BroadcastStats();
|
|
|
Timer.ExecuteRealTimeNotDisposable(2000, () =>
|
|
|
{
|
|
|
- if(broadcastStatsOnStart) BroadcastStats();
|
|
|
if(listenForStatisticsEvents)
|
|
|
{
|
|
|
for (int i = 0; i < steamStats.library.Count; i++)
|
|
@@ -96,18 +98,28 @@ namespace KairoEngine.SteamIntegration
|
|
|
|
|
|
public void BroadcastStats()
|
|
|
{
|
|
|
+ if(debug) Debug.Log($"Broadcasting Steam Stats ({steamStats.library.Count})");
|
|
|
for (int i = 0; i < steamStats.library.Count; i++)
|
|
|
{
|
|
|
var stat = steamStats.library[i];
|
|
|
if(stat.statType == SteamStatType.Integer)
|
|
|
{
|
|
|
- int value = Steamworks.SteamUserStats.GetStatInt(stat.name);
|
|
|
- if(value != 0) GenericEvents.Trigger(statisticsBroadcastEvent, stat.name, value);
|
|
|
+ int value = Steamworks.SteamUserStats.GetStatInt(stat.statName);
|
|
|
+ if(value != 0)
|
|
|
+ {
|
|
|
+ if(debug) Debug.Log($"Broadcasting Steam stat event \"{stat.name}\" = {value}");
|
|
|
+ GenericEvents.Trigger(statisticsBroadcastEvent, stat.name, value);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
else if(stat.statType == SteamStatType.Float)
|
|
|
{
|
|
|
- float value = Steamworks.SteamUserStats.GetStatFloat(stat.name);
|
|
|
- if(value != 0) GenericEvents.Trigger(statisticsBroadcastEvent, stat.name, value);
|
|
|
+ float value = Steamworks.SteamUserStats.GetStatFloat(stat.statName);
|
|
|
+ if(value != 0)
|
|
|
+ {
|
|
|
+ if(debug) Debug.Log($"Broadcasting Steam stat event \"{stat.name}\" = {value}");
|
|
|
+ GenericEvents.Trigger(statisticsBroadcastEvent, stat.name, value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|