Files
zzz_REBIRTH__Utils/Harmony/Harmony_NetPackageEntityRagdoll.cs
2025-06-04 16:44:53 +09:30

58 lines
1.7 KiB
C#

using HarmonyLib;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Harmony.NetPackageEntityRagdollPatches
{
[HarmonyPatch(typeof(NetPackageEntityRagdoll))]
[HarmonyPatch("ProcessPackage")]
public class ProcessPackagePatches
{
public static bool Prefix(NetPackageEntityRagdoll __instance, World _world, GameManager _callbacks,
int ___entityId,
float ___duration,
sbyte ___state,
Vector3 ___hipPos,
Vector3 ___forceWorldPos,
Vector3 ___forceVec,
EnumBodyPartHit ___bodyPart
)
{
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage START");
if (_world == null)
{
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 1");
return false;
}
global::EntityAlive entityAlive = _world.GetEntity(___entityId) as global::EntityAlive;
if (entityAlive == null)
{
Log.Out("Discarding " + __instance.GetType().Name + " for entity Id=" + ___entityId.ToString());
return false;
}
if (___state < 0)
{
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 2");
if (entityAlive.EntityClass.HasRagdoll)
{
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 4");
entityAlive.emodel.DoRagdoll(___duration, ___bodyPart, ___forceVec, ___forceWorldPos, true);
}
else
{
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 5");
entityAlive.PhysicsPush(___forceVec, ___forceWorldPos);
}
return false;
}
entityAlive.emodel.SetRagdollState((int)___state);
//Log.Out("NetPackageEntityRagdollPatches-ProcessPackage 6");
return false;
}
}
}