26 lines
874 B
C#
26 lines
874 B
C#
namespace Harmony.BlockDamagePatches
|
|
{
|
|
[HarmonyPatch(typeof(BlockDamage))]
|
|
[HarmonyPatch("OnEntityCollidedWithBlock")]
|
|
public class OnEntityCollidedWithBlockPatch
|
|
{
|
|
public static bool Prefix(BlockDamage __instance, ref bool __result, WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Entity _targetEntity)
|
|
{
|
|
if (_targetEntity is EntityNPCRebirth)
|
|
{
|
|
if (_targetEntity.EntityClass.Properties.Values.ContainsKey("PreventTrapDamage"))
|
|
{
|
|
string preventTrapDamage = _targetEntity.EntityClass.Properties.Values["PreventTrapDamage"];
|
|
|
|
if (preventTrapDamage == "true")
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|