-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fba8488
commit 7187bf6
Showing
9 changed files
with
709 additions
and
359 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
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,38 @@ | ||
// DO NOT LOAD THIS CLASS UNLESS LC_API IS PRESENT! | ||
|
||
namespace Coroner.LCAPI { | ||
class DeathBroadcasterLCAPI { | ||
const string SIGNATURE_DEATH = PluginInfo.PLUGIN_GUID + ".death"; | ||
|
||
public static void Initialize() { | ||
Plugin.Instance.PluginLogger.LogInfo("Initializing DeathBroadcaster..."); | ||
if (Plugin.Instance.IsLCAPIPresent) { | ||
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Registering signature..."); | ||
LC_API.ServerAPI.Networking.GetString += OnBroadcastString; | ||
} else { | ||
Plugin.Instance.PluginLogger.LogError("LC_API is not present! Why did you try to register the DeathBroadcaster?"); | ||
} | ||
} | ||
|
||
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 AttemptBroadcast(string data, string signature) { | ||
if (Plugin.Instance.IsLCAPIPresent) { | ||
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..."); | ||
} | ||
} | ||
} | ||
} |
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,3 @@ | ||
# Coroner/LCAPI | ||
|
||
Do NOT invoke any clases in this namespace unless `LC_API` is detected and present in the current installation. |
Oops, something went wrong.