-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatches.cs
39 lines (35 loc) · 1.56 KB
/
Patches.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
using HarmonyLib;
using UnityEngine;
namespace PowerupDrop
{
public class MuckPatch
{
[HarmonyPostfix, HarmonyPatch(typeof(Server), nameof(Server.InitializeServerPackets))]
public static void InitializeServerPackets()
{
Server.PacketHandlers.Add(203, new Server.PacketHandler(Packets.ServerHandleCanPowerupDrop));
Server.PacketHandlers.Add(204, new Server.PacketHandler(Packets.ServerHandlePowerupDrop));
}
[HarmonyPostfix, HarmonyPatch(typeof(LocalClient), nameof(LocalClient.InitializeClientData))]
public static void InitializeClientData()
{
LocalClient.packetHandlers.Add(205, new LocalClient.PacketHandler(Packets.ClientHandlePowerupDrop));
}
[HarmonyPostfix, HarmonyPatch(typeof(GameManager), nameof(GameManager.StartGame))]
public static void OnStartGame()
{
Packets.ClientSendCanPowerupDrop();
}
[HarmonyPostfix, HarmonyPatch(typeof(PowerupUI), nameof(PowerupUI.AddPowerup))]
public static void OnAddPowerup(ref int powerupId)
{
if (PowerupUI.Instance.powerups[powerupId].GetComponent<ClickablePowerupInfo>() == null)
{
GameObject powerup = PowerupUI.Instance.powerups[powerupId];
Object.Destroy(powerup.GetComponent<PowerupInfo>());
ClickablePowerupInfo powerupInfo = powerup.AddComponent<ClickablePowerupInfo>();
powerupInfo.powerup = ItemManager.Instance.allPowerups[powerupId];
}
}
}
}