Skip to content

Commit

Permalink
Work in progress on v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Jul 9, 2024
1 parent 0e34a29 commit f017052
Show file tree
Hide file tree
Showing 22 changed files with 2,951 additions and 986 deletions.
7 changes: 4 additions & 3 deletions Art/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "Coroner",
"version_number": "1.6.2",
"version_number": "2.0.0",
"website_url": "https://github.com/EliteMasterEric/Coroner",
"description": "Rework the Performance Report with new info, including cause of death.",
"description": "Add Cause of Death to the performance report, rebuilt and better than ever.",
"dependencies": [
"BepInEx-BepInExPack-5.4.2100"
"BepInEx-BepInExPack-5.4.2100",
"xilophor-StaticNetcodeLib-1.1.1"
]
}
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# Changelog

# 2.0.0
This update represents a major refactor of Coroner's codebase.
## Added
- Added new causes of death for version 50.
- Added new causes of death for version 55/56.
- Added a cause of death specifically for dying of falling in pits in the facility.
- Split up causes of death for coworkers murdering with different weapons into different types (for example, Stop Signs vs Knives).
- Added a documented `Coroner.API` class to make it easy for mods to add their own integrations.
- NOTE: This feature is not currently 100% complete as mods cannot display their own custom causes of death right now.
## Changed
- Replaced `LC_API` with `StaticNetcodeLib` for more reliable, less bloated networking that doesn't depend on an outdated library.
## Removed
- Removed all languages except for English, due to the other languages now having missing causes of death. A long-term solution for this problem will come later.
## Fixed
- Fixed a bug where leaving the game before the Performance Report and then joining a new lobby would not clear causes of death, resulting in incorrect causes of death being displayed later.

# 1.6.2
# Fixed
## Fixed
- Fixed an issue where Coroner fails to detect the config folder (even when it is in the proper location).

# 1.6.1
# Fixed
## Fixed
- Improved the clarity of the error messages for when people install the mod incorrectly (you won't get this error if you use R2Modman!).

# 1.6.0
Expand Down
95 changes: 95 additions & 0 deletions Coroner/API.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using GameNetcodeStuff;

#nullable enable

namespace Coroner
{
public class API
{
/// <summary>
/// Sets the cause of death for a player object.
/// You can set this to a default one (see `Coroner.AdvancedCauseOfDeath`) or a custom one (see `Register()`).
/// </summary>
/// <param name="player">The player to set the cause of death for.</param>
/// <param name="causeOfDeath">The cause of death to use. Set to `null` to clear.</param>
/// <example> SetCauseOfDeath(player, AdvancedCauseOfDeath.Enemy_ForestGiant); </example>
public static void SetCauseOfDeath(PlayerControllerB player, AdvancedCauseOfDeath? causeOfDeath)
{
// Call the proper internal method.
AdvancedDeathTracker.SetCauseOfDeath(player, causeOfDeath);
}

/// <summary>
/// Sets the cause of death for a player with the given ID.
/// You can set this to a default one (see `Coroner.AdvancedCauseOfDeath`) or a custom one (see `Register()`).
/// </summary>
/// <param name="playerId">The ID of the player.</param>
/// <param name="causeOfDeath">The cause of death to use. Set to `null` to clear.</param>
/// <example> SetCauseOfDeath(0, AdvancedCauseOfDeath.Enemy_ForestGiant); </example>
public static void SetCauseOfDeath(int playerId, AdvancedCauseOfDeath? causeOfDeath)
{
// Call the proper internal method.
AdvancedDeathTracker.SetCauseOfDeath(playerId, causeOfDeath);
}

/// <summary>
/// Gets the cause of death for a player object.
/// </summary>
/// <param name="player">The player to get the cause of death for.</param>
/// <returns>The cause of death for the player. May be null if none is set, or a custom value provided by a mod.</returns>
/// <example> GetCauseOfDeath(player); </example>
public static AdvancedCauseOfDeath? GetCauseOfDeath(PlayerControllerB player)
{
// Call the proper internal method.
return AdvancedDeathTracker.GetCauseOfDeath(player);
}

/// <summary>
/// Gets the cause of death for a player with the given ID.
/// </summary>
/// <param name="playerId">The ID of the player.</param>
/// <returns>The cause of death for the player.</returns>
/// <example> GetCauseOfDeath(0); </example>
public static AdvancedCauseOfDeath? GetCauseOfDeath(int playerId)
{
// Call the proper internal method.
return AdvancedDeathTracker.GetCauseOfDeath(playerId);
}

/// <summary>
/// Register a new cause of death. Useful for mods.
/// Choose one that is unique to your mod, and store the value statically for reuse.
/// Then, call SetCauseOfDeath(player, customCauseOfDeath) to use it.
/// </summary>
/// <param name="key">The language key to use for the cause of death.</param>
/// <returns>The newly registered cause of death.</returns>
public static AdvancedCauseOfDeath Register(string key)
{
// Call the proper internal method.
return AdvancedCauseOfDeath.Build(key);
}

// <summary>
// Determine whether a cause of death is registered.
// </summary>
// <param name="key">The language key to use for the cause of death.</param>
// <returns>Whether that cause of death is already registered.</returns>
public static bool IsRegistered(string key)
{
return AdvancedCauseOfDeath.IsTagRegistered(key);
}

/// <summary>
/// Convert a cause of death to a language string as used in-game.
/// </summary>
/// <param name="causeOfDeath">The cause of death to convert.</param>
/// <param name="random">Optionally specify a random number generator to use. If you seed this the same between clients, they'll produce the same value.</param>
/// <returns>One of the available language strings for that cause of death.</returns>
public static string StringifyCauseOfDeath(AdvancedCauseOfDeath causeOfDeath, Random? random)
{
// Call the proper internal method.
return AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath, random != null ? random : Plugin.RANDOM);
}
}
}
Loading

0 comments on commit f017052

Please sign in to comment.