-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
81 lines (70 loc) · 3.56 KB
/
Plugin.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using BepInEx;
using HarmonyLib;
using UnityEngine;
using System.Reflection;
using ModelReplacement;
using BepInEx.Configuration;
using System;
using System.Xml.Linq;
namespace LethalWicker
{
[BepInPlugin("Froze.LethalWicker", "Lethal Wicker", "2.0.1")]
[BepInDependency("meow.ModelReplacementAPI", BepInDependency.DependencyFlags.HardDependency)]
[BepInDependency("x753.More_Suits", BepInDependency.DependencyFlags.HardDependency)]
public class Plugin : BaseUnityPlugin
{
public static ConfigFile config;
public static ConfigEntry<bool> enableModelForAllSuits { get; private set; }
public static ConfigEntry<bool> enableModelAsDefault { get; private set; }
public static ConfigEntry<string> suitNamesToEnableModel { get; private set; }
private static void InitConfig()
{
enableModelForAllSuits = config.Bind<bool>("Suits to Replace Settings", "Enable Red Wicker for all Suits", false, "Enable to model replace every suit. Set to false to specify suits");
enableModelAsDefault = config.Bind<bool>("Suits to Replace Settings", "Enable Red Wicker as default", false, "Enable to model replace every suit that hasn't been otherwise registered.");
suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for Red Wicker", "SuitNameExample", "Enter a comma separated list of suit names.(Additionally, [Green suit,Pajama suit,Hazard suit])");
}
private void Awake()
{
config = base.Config;
InitConfig();
Assets.PopulateAssets();
if (enableModelForAllSuits.Value)
{
ModelReplacementAPI.RegisterModelReplacementOverride(typeof(MRLETHALWICKERRED));
}
if (enableModelAsDefault.Value)
{
ModelReplacementAPI.RegisterModelReplacementDefault(typeof(MRLETHALWICKERRED));
}
var commaSepList = suitNamesToEnableModel.Value.Split(',');
foreach (var item in commaSepList)
{
ModelReplacementAPI.RegisterSuitModelReplacement(item, typeof(MRLETHALWICKERRED));
}
ModelReplacementAPI.RegisterSuitModelReplacement("Red Wicker", typeof(MRLETHALWICKERRED));
ModelReplacementAPI.RegisterSuitModelReplacement("Blue Wicker", typeof(MRLETHALWICKERBLUE));
ModelReplacementAPI.RegisterSuitModelReplacement("Green Wicker", typeof(MRLETHALWICKERGREEN));
Harmony harmony = new Harmony("Froze.LethalWicker");
harmony.PatchAll();
Logger.LogInfo($"Plugin {"Froze.LethalWicker"} is loaded!");
}
}
public static class Assets
{
// Replace mbundle with the Asset Bundle Name from your unity project
public static string mainAssetBundleName = "LethalWicker";
public static AssetBundle MainAssetBundle = null;
private static string GetAssemblyName() => Assembly.GetExecutingAssembly().GetName().Name.Replace(" ","_");
public static void PopulateAssets()
{
if (MainAssetBundle == null)
{
Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
using (var assetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName))
{
MainAssetBundle = AssetBundle.LoadFromStream(assetStream);
}
}
}
}
}