LethalCompanyCommunity / LethalAPI.Core

A core modding library for Lethal Company
GNU Lesser General Public License v3.0
24 stars 6 forks source link

Improve Event Transpiler Helpers #15

Closed dhkatz closed 10 months ago

dhkatz commented 10 months ago

Improving the event transpiling/patching system a bit

Fixed the following issues:

Event Example

Given the following handlers:

        Events.Handlers.Player.CriticallyInjure += @event =>
        {
            Log.Info($"Player {@event.Player.playerUsername} is being critically injured.");
            Log.Info($"Health: {@event.Player.health}");
        };
        Events.Handlers.Player.Healing += @event =>
        {
            Log.Info($"Player {@event.Player.playerUsername} is being healed.");
            Log.Info($"Health: {@event.Player.health}");
        };

We see the following output when taking damage which drops health below 10:

[11/18/2023 1:54 AM (08.339s)] [Info] [LethalAPI.Core] Player dhkatz is being critically injured.
[11/18/2023 1:54 AM (08.342s)] [Info] [LethalAPI.Core] Health: 5

After waiting a bit we are healed back up to 20 and are no longer critically injured:

[11/18/2023 1:54 AM (22.575s)] [Info] [LethalAPI.Core] Player dhkatz is being healed.
[11/18/2023 1:54 AM (22.579s)] [Info] [LethalAPI.Core] Health: 20