-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.cs
More file actions
109 lines (93 loc) · 3.59 KB
/
Plugin.cs
File metadata and controls
109 lines (93 loc) · 3.59 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using REPOLib;
using UnityEngine;
namespace PocketCartPlus
{
[BepInDependency(MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInAutoPlugin]
public partial class Plugin : BaseUnityPlugin
{
internal static Plugin instance = null!;
internal static ManualLogSource Log = null!;
internal static bool BundleLoaded = false;
internal static System.Random Rand = new();
internal static AssetBundle Bundle = null!;
internal static AssetBundle PocketDimensionBundle = null!;
internal static GameObject PocketDimension = null!;
internal static GameObject HintPrefab = null!;
private void Awake()
{
instance = this;
Log = base.Logger;
Log.LogInfo($"{Name} is loading with version {Version}!");
Log.LogInfo($"This version of the mod has been compiled for REPO version 0.3.1 :)");
ModConfig.Init();
string pluginFolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string assetBundleFilePath = Path.Combine(pluginFolderPath, "upgrade_cartitems");
string pocketDimension = Path.Combine(pluginFolderPath, "pocketdimension");
//string hintUI = Path.Combine(pluginFolderPath, "hintui");
//REPOLib.BundleLoader.LoadBundle(hintUI, BundleLoader, false);
REPOLib.BundleLoader.LoadBundle(pocketDimension, BundleLoader, false);
REPOLib.BundleLoader.LoadBundle(assetBundleFilePath, BundleLoader, true);
Config.ConfigReloaded += OnConfigReloaded;
Config.SettingChanged += OnSettingChanged;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
Log.LogInfo($"{Name} load complete!");
}
public void OnConfigReloaded(object sender, EventArgs e)
{
Log.LogDebug("Config has been reloaded!");
if(PhotonNetwork.MasterClient != null)
HostValues.StartGame();
}
public void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
{
if (settingChangedArg.ChangedSetting == null)
return;
HostValues.UpdateValue(settingChangedArg.ChangedSetting);
}
private static IEnumerator BundleLoader(AssetBundle mybundle)
{
if(mybundle.name == "upgrade_cartitems")
{
Bundle = mybundle;
yield return null;
Spam("Asset bundle has been loaded");
BundleLoaded = true;
}
else if(mybundle.name == "pocketdimension")
{
PocketDimensionBundle = mybundle;
PocketDimension = PocketDimensionBundle.LoadAsset<GameObject>("PocketDimension");
Spam("PocketDimension bundle loaded!");
}
}
internal static void Message(string message)
{
Log.LogMessage(message);
}
internal static void Spam(string message)
{
if (ModConfig.DeveloperLogging.Value)
Log.LogDebug(message);
else
return;
}
internal static void ERROR(string message)
{
Log.LogError(message);
}
internal static void WARNING(string message)
{
Log.LogWarning(message);
}
}
}