This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPC.cs
154 lines (153 loc) · 6.31 KB
/
RPC.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using Hazel;
using System.Collections.Generic;
using System.Linq;
using static Pheonix.PheonixRole;
using HarmonyLib;
using UnityEngine;
using Reactor.Extensions;
using System.Reflection;
using System.IO;
using Reactor.Unstrip;
namespace Pheonix
{
enum RPC
{
PlayAnimation = 0,
CompleteTask = 1,
SyncSettings = 2,
SetInfected = 3,
Exiled = 4,
CheckName = 5,
SetName = 6,
CheckColor = 7,
SetColor = 8,
SetHat = 9,
SetSkin = 10,
ReportDeadBody = 11,
MurderPlayer = 12,
SendChat = 13,
StartMeeting = 14,
SetScanner = 15,
SendChatNote = 16,
SetPet = 17,
SetStartCounter = 18,
EnterVent = 19,
ExitVent = 20,
SnapTo = 21,
Close = 22,
VotingComplete = 23,
CastVote = 24,
ClearVote = 25,
AddVote = 26,
CloseDoorsOfType = 27,
RepairSystem = 28,
SetTasks = 29,
UpdateGameData = 30,
}
enum CustomRPC
{
SetPheonix = 53,
SetLocalPlayers = 54,
ResetVariiables = 55,
ReviveAbility = 56,
FlashAbility = 57,
WrathAbility = 58,
ExtinguishAbility = 59,
RotateAbility = 60,
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.HandleRpc))]
class HandleRpcPatch
{
static void Postfix(byte HKHMBLJFLMC, MessageReader ALMCIJKELCP)
{
byte packetId = HKHMBLJFLMC;
MessageReader reader = ALMCIJKELCP;
switch (packetId)
{
case (byte)CustomRPC.SetPheonix:
byte bobux = ALMCIJKELCP.ReadByte();
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (player.PlayerId == bobux)
player.getModdedControl().Role = "Pheonix";
break;
case (byte)CustomRPC.SetLocalPlayers:
localPlayers.Clear();
localPlayer = PlayerControl.LocalPlayer;
var localPlayerBytes = ALMCIJKELCP.ReadBytesAndSize();
foreach (byte id in localPlayerBytes)
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (player.PlayerId == id)
localPlayers.Add(player);
break;
case (byte)CustomRPC.ResetVariiables:
Main.Config.SetConfigSettings();
Main.Logic.AllModPlayerControl.Clear();
killedPlayers.Clear();
#region reset pheonix stuff
PlayerTools.hasDied = false;
PlayerTools.hasDone = false;
PlayerTools.hasPressedDroplit = false;
PlayerTools.hasPressedRelive = false;
PlayerTools.hasPressedReveal = false;
PlayerTools.hasPressedWrath = false;
PlayerTools.waterPressed = false;
#endregion
List<PlayerControl> crewmates = PlayerControl.AllPlayerControls.ToArray().ToList();
foreach (PlayerControl plr in crewmates)
Main.Logic.AllModPlayerControl.Add(new ModPlayerControl { PlayerControl = plr, Role = "Impostor", UsedAbility = false, LastAbilityTime = null, Immortal = false });
crewmates.RemoveAll(x => x.Data.IsImpostor);
foreach (PlayerControl plr in crewmates)
plr.getModdedControl().Role = "Crewmate";
break;
case (byte)CustomRPC.ReviveAbility:
byte revivedId = ALMCIJKELCP.ReadByte();
PlayerControl revive = PlayerTools.getPlayerFromId(revivedId);
revive.Revive();
switch (PlayerControl.GameOptions.MapId)
{
case 0:
revive.transform.position = new Vector3(-7.25f, -4.85f, revive.transform.position.z);
break;
case 1:
revive.transform.position = new Vector3(16.26f, 0.54f, revive.transform.position.z);
break;
case 2:
revive.transform.position = new Vector3(40.39f, -6.74f, revive.transform.position.z);
break;
}
break;
case (byte)CustomRPC.FlashAbility:
byte pheonixid = ALMCIJKELCP.ReadByte();
bool activated = ALMCIJKELCP.ReadBoolean();
PlayerControl pheonix = PlayerTools.getPlayerById(pheonixid);
if (activated)
pheonix.nameText.Color = Main.Palette.pheonixColor;
else
pheonix.nameText.Color = Color.white;
break;
case (byte)CustomRPC.WrathAbility:
byte targetid = ALMCIJKELCP.ReadByte();
byte killerid = ALMCIJKELCP.ReadByte();
PlayerControl target = PlayerTools.getPlayerFromId(targetid);
PlayerControl killer = PlayerTools.getPlayerFromId(killerid);
killer.Data.IsImpostor = true;
killer.MurderPlayer(target);
killer.Data.IsImpostor = false;
break;
case (byte)CustomRPC.ExtinguishAbility:
byte targetid2 = ALMCIJKELCP.ReadByte();
PlayerControl target2 = PlayerTools.getPlayerById(targetid2);
//target2.getModdedControl().Role = "Crewmate";
target2.getModdedControl().Role = "Crewmate";
if (PlayerControl.LocalPlayer == target2)
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
player.GetComponent<SpriteRenderer>().material.SetFloat("_Outline", 0f);
player.GetComponent<SpriteRenderer>().material.SetColor("_OutlineColor", Color.clear);
}
break;
}
}
}
}