-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
60 lines (49 loc) · 1.98 KB
/
Copy pathPlugin.cs
File metadata and controls
60 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using System.IO;
using System.Reflection;
using UnityEngine;
namespace BarberMaterialTweaks
{
[BepInPlugin(PLUGIN_GUID, PLUGIN_NAME, PLUGIN_VERSION)]
[BepInIncompatibility("dopadream.lethalcompany.ClaySurgeonMod")]
public class Plugin : BaseUnityPlugin
{
const string PLUGIN_GUID = "dopadream.lethalcompany.BarberMaterialTweaks", PLUGIN_NAME = "BarberMaterialTweaks", PLUGIN_VERSION = "1.1.1";
internal static new ManualLogSource Logger;
internal static Material clayTex;
void Awake()
{
Logger = base.Logger;
//Credits to ButteryStancakes for asset loading code!
try
{
AssetBundle barberBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BarberMaterialTweaks"));
clayTex = barberBundle.LoadAsset("ScissorGuyTex 1", typeof(Material)) as Material;
barberBundle.Unload(false);
}
catch
{
Logger.LogError("Encountered some error loading asset bundle. Did you install the plugin correctly?");
return;
}
new Harmony(PLUGIN_GUID).PatchAll();
Logger.LogInfo($"{PLUGIN_NAME} v{PLUGIN_VERSION} loaded");
}
[HarmonyPatch]
class BarberMaterialTweaksPatches
{
[HarmonyReversePatch]
[HarmonyPatch(typeof(ClaySurgeonAI), "Awake")]
[HarmonyPostfix]
static void ClaySurgeonAIPostStart(ClaySurgeonAI __instance,ref Material ___thisMaterial)
{
___thisMaterial = Instantiate(Plugin.clayTex);
__instance.scissorBlades[0].sharedMaterial = ___thisMaterial;
__instance.scissorBlades[1].sharedMaterial = ___thisMaterial;
__instance.skin.sharedMaterial = ___thisMaterial;
}
}
}
}