2024-04-28 14:41:33 -07:00

29 lines
888 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using HarmonyLib;
namespace ScarletMansion.GamePatch {
public class ShovelPatch {
[HarmonyPatch(typeof(Shovel), "HitShovel")]
[HarmonyPostfix]
public static void HitShovelPatch(ref Shovel __instance, bool cancel){
var prev = __instance.previousPlayerHeldBy;
if (prev == null || cancel) return;
var prevTransform = prev.gameplayCamera.transform;
var position = prevTransform.position + prevTransform.right * -0.35f;
var forward = prevTransform.forward;
if (Components.ScarletDoorLock.ScarletDoorRaycast(__instance, position, forward, 1.5f + 0.8f, out var door)){
var damage = PluginConfig.Instance.shovelDamageValue;
door.ApplyDamageServerRpc(forward, damage);
}
}
}
}