public static void Unassign(PlayerShim shim) { OnHaveStamina -= shim.CheckStamina; BeforeUseStamina -= shim.GetNewStaminaUsage; BeforeDestroy -= shim.Destroy; if (Config.ParryRefundEnable.Value) { BeforeBlockAttack -= shim.UpdateParry; OnBlockAttack -= shim.UpdateParryRefund; } if (Config.ExhaustionEnable.Value) { OnUseStamina -= shim.CheckAndAddExhaustion; OnUpdateStats -= shim.CheckAndRemoveExhaustion; } if (Config.EncumberanceAltEnable.Value) { OnIsEncumbered -= shim.CheckEncumbered; } if (Config.BaseHealthStaminaEnable.Value) { OnGetBaseFoodHP -= shim.GetBaseHp; } }
static void Postfix(Player __instance) { //Prevent NREs from main menu fake player //TODO: Find a better solution, this function seems unreliable as it just returns "..." for any Player object *except* the main menu player if (string.IsNullOrEmpty(__instance.GetPlayerName())) { return; } if (!__instance.IsOwner()) { return; } Log.LogInfo($"Creating new shim for player with ID: {__instance.GetZDOID()}"); var shim = new PlayerShim(__instance); OnHaveStamina += shim.CheckStamina; BeforeUseStamina += shim.GetNewStaminaUsage; BeforeDestroy += shim.Destroy; if (Config.ParryRefundEnable.Value) { Log.LogInfo("*Parry modifications enabled"); BeforeBlockAttack += shim.UpdateParry; OnBlockAttack += shim.UpdateParryRefund; } if (Config.ExhaustionEnable.Value) { Log.LogInfo("*Exhaustion modifications enabled"); OnUseStamina += shim.CheckAndAddExhaustion; OnUpdateStats += shim.CheckAndRemoveExhaustion; } if (Config.EncumberanceAltEnable.Value) { Log.LogInfo("*Encumbrance modifications enabled"); OnIsEncumbered += shim.CheckEncumbered; } if (Config.BaseHealthStaminaEnable.Value) { Log.LogInfo("*Health/Stamina modifications enabled"); OnGetBaseFoodHP += shim.GetBaseHp; } var seman = __instance.GetSEMan(); if (Config.EncumberanceAltEnable.Value && !seman.HaveStatusEffect("Encumbrance")) { seman.AddStatusEffect("Encumbrance"); Log.LogInfo("*Applied encumbrance status effect"); } }