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
/
PlayerTools.cs
108 lines (106 loc) · 3.7 KB
/
PlayerTools.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
using HarmonyLib;
using System;
using System.Collections.Generic;
using UnityEngine;
using static Pheonix.PheonixRole;
namespace Pheonix
{
[HarmonyPatch]
public static class PlayerTools
{
public static PlayerControl closestPlayer = null;
public static List<PlayerControl> getCrewMates()
{
List<PlayerControl> CrewmateIds = new List<PlayerControl>();
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
bool isInfected = false;
if (player.Data.IsImpostor)
{
isInfected = true;
break;
}
if (!isInfected)
{
CrewmateIds.Add(player);
}
}
return CrewmateIds;
}
public static PlayerControl getPlayerById(byte id)
{
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
if (player.PlayerId == id)
{
return player;
}
}
return null;
}
public static PlayerControl getClosestPlayer(PlayerControl refplayer)
{
var mindist = 2.5;
PlayerControl closestplayer = null;
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
if (player.Data.IsDead)
continue;
if (player == refplayer)
continue;
var dist = getDistBetweenPlayers(player, refplayer);
if (dist >= mindist)
continue;
mindist = dist;
closestplayer = player;
}
return closestplayer;
}
public static bool ghostInRange = false;
public static bool hasDone = false;
public static bool hasDied = false;
public static bool hasPressedRelive = false;
public static bool hasPressedDroplit = false;
public static bool hasPressedReveal = false;
public static bool hasPressedWrath = false;
public static bool wrathWasActive = false;
public static bool waterPressed = false;
public static PlayerControl getClosestDeadPlayer(PlayerControl refplayer)
{
double mindist = 1.5;
PlayerControl closestplayer = null;
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
{
if (!player.Data.IsDead) continue;
if (player != refplayer)
{
double dist = getDistBetweenPlayers(player, refplayer);
if (dist < mindist)
{
mindist = dist;
closestplayer = player;
ghostInRange = true;
}
else
{
ghostInRange = false;
}
}
}
return closestplayer;
}
public static PlayerControl getPlayerFromId(byte id)
{
foreach (PlayerControl player in PlayerControl.AllPlayerControls)
if (player.PlayerId == id)
return player;
return null;
}
public static double getDistBetweenPlayers(PlayerControl player, PlayerControl refplayer)
{
var refpos = refplayer.GetTruePosition();
var playerpos = player.GetTruePosition();
return Math.Sqrt((refpos[0] - playerpos[0]) * (refpos[0] - playerpos[0]) + (refpos[1] - playerpos[1]) * (refpos[1] - playerpos[1]));
}
}
}