

Initially developed as a part of CybergrindDeathcam, this library allows to track which enemy has dealt the damage once the player is hurt.
Please note that despite that mod supports (almost) every enemy currently present in the game it only applies to spawnable enemies, i.e. those enemies you can spawn in the Sandbox. Therefore, as an example Earthmover's brain projectiles damage won't register.
Currently, Big Johninator is also unsupported.
Simply subscribe to OnPlayerHurt event of EnemyIdentifierManager instance in order to receive an info regarding who hurt the player, how many damage it inflicted and whether it's killed the player or not.
Like this:
EnemyIdentifierManager.Instance.OnPlayerHurt += hurtEvent =>
{
if (hurtEvent.EnemyId != null)
Debug.Log($"Player got hurt by {hurtEvent.EnemyId.GetEnemyName()}");
Debug.Log($"Inflicted damage: {hurtEvent.Damage}");
if (hurtEvent.PlayerIsKilled)
Debug.Log("Player is killed");
};
Example output of a snippet above with player getting lynched by Stray, Swordsmachine and a Virtue
You can also retrieve all sorts of information regarding an enemy using EnemyId field (vanilla EnemyIdentifier type encapsulates lots of info, including enemy type, its GameObject, health etc)
It's worth noticing though that EnemyId.enemyType field is often unreliable when it comes to necessity of figuring out enemy type (for instance, Mysterious Druid Knight has a Drone enemy type). In order to serialize enemy type properly, use GetEnemyName() function.
EnemyIdentifierManager.Instance.OnPlayerHurt += hurtEvent =>
{
Debug.Log($"Player got hurt by {hurtEvent.EnemyId.GetEnemyName()}");
};
Notice how EnemyId is a nullable value. When it's null, there are 3 possible options here: