-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlugin.cs
92 lines (79 loc) · 3.47 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
82
83
84
85
86
87
88
89
90
91
92
using BepInEx;
using UnboundLib.Cards;
using UnboundLib;
using BepInEx.Logging;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine.UI;
using UnboundLib.Utils.UI;
using UnityEngine;
using TMPro;
using Photon.Pun;
using UnboundLib.Networking;
namespace SelectAnyNumberRounds
{
[BepInDependency("com.willis.rounds.unbound")]
[BepInDependency("io.olavim.rounds.rwf")]
[BepInDependency("com.willuwontu.rounds.rwfsettingsui")]
[BepInDependency("pykess.rounds.plugins.pickncards")]
[BepInPlugin(pluginId, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
[BepInProcess("Rounds.exe")]
public class Plugin : BaseUnityPlugin
{
public const string pluginId = "com.pandapip1.rounds.selectanynumberrounds";
public static Plugin instance;
public static new ManualLogSource Logger => Plugin.instance.GetLogger();
public static ConfigEntry<int> configPickNumber;
public static ConfigEntry<bool> enableContinueCard;
private void Awake()
{
instance = this;
// Config
SettingsUI.RWFSettingsUI.RegisterMenu(PluginInfo.PLUGIN_GUID, NewGUI);
configPickNumber = Config.Bind(PluginInfo.PLUGIN_GUID, "Picks", 20, "The number of cards you can pick from each hand.");
enableContinueCard = Config.Bind(PluginInfo.PLUGIN_GUID, "Enable Continue Card", true, "Whether or not to enable the continue card.");
// Sync
Unbound.RegisterHandshake(PluginInfo.PLUGIN_GUID, this.OnHandShakeCompleted);
// Plugin startup logic
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
// Load credits
Unbound.RegisterCredits("Pick Any Number", new string[] { "Pandapip1 (@Pandapip1)" }, "Pandapip1.com", "https://pandapip1.com/");
// Load custom cards
CustomCard.BuildCard<Cards.ContinueCard>((card) => {
// Save the CardInfo instance for later use
Cards.ContinueCard.cardInfoInstance = card;
});
// Harmony patching: all patches in the same assembly as this class will be applied
Harmony harmony = new Harmony(PluginInfo.PLUGIN_GUID);
harmony.PatchAll();
}
internal ManualLogSource GetLogger()
{
return base.Logger;
}
internal static void NewGUI(GameObject menu)
{
MenuHandler.CreateText(PluginInfo.PLUGIN_NAME + " Options", menu, out TextMeshProUGUI _, 60);
MenuHandler.CreateText(" ", menu, out TextMeshProUGUI _, 30);
MenuHandler.CreateSlider("Picks", menu, 30, 1f, 20f, 1f, newValue => configPickNumber.Value = (int)newValue, out Slider _, true);
MenuHandler.CreateToggle(enableContinueCard.Value, "Enable Continue Card", menu, newValue => enableContinueCard.Value = newValue);
}
private void OnHandShakeCompleted()
{
if (PhotonNetwork.IsMasterClient)
{
UnityEngine.Debug.Log("Sending Handshake RPC");
NetworkingManager.RPC(typeof(Plugin), nameof(SyncSettings), new object[] {
configPickNumber.Value,
enableContinueCard.Value
});
}
}
[UnboundRPC]
private static void SyncSettings(int draws, bool enableContinue)
{
configPickNumber.Value = draws;
enableContinueCard.Value = enableContinue;
}
}
}