-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.1.0 with fixes and LC_API broadcast
- Loading branch information
1 parent
532e759
commit b3493a9
Showing
10 changed files
with
387 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"name": "Coroner", | ||
"version_number": "1.0.0", | ||
"version_number": "1.1.0", | ||
"website_url": "https://github.com/EliteMasterEric/Coroner", | ||
"description": "Rework the Performance Report with new info, including cause of death.", | ||
"dependencies": [] | ||
"dependencies": [ | ||
"BepInEx-BepInExPack-5.4.2100", | ||
"2018-LC_API-2.1.1" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace Coroner { | ||
class DeathBroadcaster { | ||
const string SIGNATURE_DEATH = PluginInfo.PLUGIN_GUID + ".death"; | ||
|
||
public static void Initialize() { | ||
Plugin.Instance.PluginLogger.LogInfo("Initializing DeathBroadcaster..."); | ||
if (Plugin.Instance.IsLC_APIPresent) { | ||
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Registering signature..."); | ||
LC_API.ServerAPI.Networking.GetString += OnBroadcastString; | ||
} else { | ||
Plugin.Instance.PluginLogger.LogInfo("LC_API is not present! Skipping registration..."); | ||
} | ||
} | ||
|
||
static void OnBroadcastString(string data, string signature) { | ||
if (signature == SIGNATURE_DEATH) { | ||
Plugin.Instance.PluginLogger.LogInfo("Broadcast has been received from LC_API!"); | ||
string[] split = data.Split('|'); | ||
int playerId = int.Parse(split[0]); | ||
int causeOfDeathInt = int.Parse(split[1]); | ||
AdvancedCauseOfDeath causeOfDeath = (AdvancedCauseOfDeath) causeOfDeathInt; | ||
Plugin.Instance.PluginLogger.LogInfo("Player " + playerId + " died of " + AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath)); | ||
AdvancedDeathTracker.SetCauseOfDeath(playerId, causeOfDeath, false); | ||
} | ||
} | ||
|
||
public static void BroadcastCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) { | ||
AttemptBroadcast(BuildData(playerId, causeOfDeath), SIGNATURE_DEATH); | ||
} | ||
|
||
static string BuildData(int playerId, AdvancedCauseOfDeath causeOfDeath) { | ||
return playerId + "|" + ((int) causeOfDeath); | ||
} | ||
|
||
static void AttemptBroadcast(string data, string signature) { | ||
if (Plugin.Instance.IsLC_APIPresent) { | ||
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Broadcasting..."); | ||
LC_API.ServerAPI.Networking.Broadcast(data, signature); | ||
} else { | ||
Plugin.Instance.PluginLogger.LogInfo("LC_API is not present! Skipping broadcast..."); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.