This repository was archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAPI.cs
More file actions
175 lines (153 loc) · 4.71 KB
/
API.cs
File metadata and controls
175 lines (153 loc) · 4.71 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using Exiled.API.Features;
using Exiled.Loader;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Subclass
{
/*
I get this looks weird because I'm making lists and dictionaries out of lists and dictionaries,
but I'm looking into ways to make it read only without creating new instaces of each thing.
*/
public static class API
{
public static bool GiveClass(Player p, SubClass subClass, bool lite = false)
{
if (PlayerHasSubclass(p) || !subClass.AffectsRoles.Contains(p.Role)) return false;
if (Subclass.Instance.Scp035Enabled)
{
Player scp035 = (Player)Loader.Plugins.First(pl => pl.Name == "scp035").Assembly.GetType("scp035.API.Scp035Data").GetMethod("GetScp035", BindingFlags.Public | BindingFlags.Static).Invoke(null, null);
TrackingAndMethods.AddClass(p, subClass, Subclass.Instance.Scp035Enabled && scp035?.Id == p.Id, lite);
return true;
}
TrackingAndMethods.AddClass(p, subClass, false, lite);
return true;
}
public static bool RemoveClass(Player p)
{
if (!PlayerHasSubclass(p)) return false;
TrackingAndMethods.RemoveAndAddRoles(p, true);
return true;
}
public static Dictionary<string, SubClass> GetClasses()
{
return Subclass.Instance.Classes.ToDictionary(x => x.Key, x => new SubClass(x.Value));
}
public static void EnableAllClasses()
{
foreach (var subClass in Subclass.Instance.Classes) subClass.Value.BoolOptions["Enabled"] = true;
}
public static void DisableAllClasses()
{
foreach (var subClass in Subclass.Instance.Classes) subClass.Value.BoolOptions["Enabled"] = false;
}
public static bool EnableClass(SubClass sc)
{
try
{
Subclass.Instance.Classes[sc.Name].BoolOptions["Enabled"] = true;
return true;
}
catch
{
return false;
}
}
public static bool EnableClass(string sc)
{
try
{
Subclass.Instance.Classes[sc].BoolOptions["Enabled"] = true;
return true;
}
catch
{
return false;
}
}
public static bool DisableClass(SubClass sc)
{
try
{
Subclass.Instance.Classes[sc.Name].BoolOptions["Enabled"] = false;
return true;
}
catch
{
return false;
}
}
public static bool DisableClass(string sc)
{
try
{
Subclass.Instance.Classes[sc].BoolOptions["Enabled"] = false;
return true;
}
catch
{
return false;
}
}
public static Dictionary<Player, SubClass> GetPlayersWithSubclasses()
{
return TrackingAndMethods.PlayersWithSubclasses.ToDictionary(x => x.Key, x => x.Value);
}
public static SubClass GetPlayersSubclass(Player p)
{
if (!PlayerHasSubclass(p)) return null;
return new SubClass(TrackingAndMethods.PlayersWithSubclasses[p]);
}
public static bool PlayerHasSubclass(Player p)
{
return TrackingAndMethods.PlayersWithSubclasses.ContainsKey(p);
}
public static void PreventPlayerFromGettingClass(Player p, float duration)
{
if (!TrackingAndMethods.PlayersThatJustGotAClass.ContainsKey(p)) TrackingAndMethods.PlayersThatJustGotAClass.Add(p, Time.time + duration);
else TrackingAndMethods.PlayersThatJustGotAClass[p] = Time.time + duration;
}
public static bool PlayerHasZombies(Player p)
{
return TrackingAndMethods.PlayersWithZombies.ContainsKey(p);
}
public static bool PlayerHadZombies(Player p)
{
return TrackingAndMethods.PlayersThatHadZombies.ContainsKey(p);
}
public static List<Player> PlayersZombies(Player p)
{
if (PlayerHasZombies(p)) return new List<Player>(TrackingAndMethods.PlayersWithZombies[p]);
return null;
}
public static List<Player> PlayersZombiesOld(Player p)
{
if (PlayerHadZombies(p)) return new List<Player>(TrackingAndMethods.PlayersThatHadZombies[p]);
return null;
}
public static List<Player> RevivedZombies()
{
List<Player> zombies = TrackingAndMethods.PlayersWithZombies.SelectMany(e => e.Value).ToList();
zombies.AddRange(TrackingAndMethods.PlayersThatHadZombies.SelectMany(e => e.Value));
return zombies;
}
public static bool AbilityOnCooldown(Player p, AbilityType ability)
{
if (!PlayerHasSubclass(p)) return false;
return TrackingAndMethods.OnCooldown(p, ability, TrackingAndMethods.PlayersWithSubclasses[p]);
}
public static float TimeLeftOnCooldown(Player p, AbilityType ability)
{
if (!PlayerHasSubclass(p)) return 0;
return TrackingAndMethods.TimeLeftOnCooldown(p, ability, TrackingAndMethods.PlayersWithSubclasses[p], Time.time);
}
public static void RegisterCustomWeaponGetter(MethodInfo findWeapon, MethodInfo weaponObtained)
{
TrackingAndMethods.CustomWeaponGetters.Add(new Tuple<MethodInfo, MethodInfo>(findWeapon, weaponObtained));
}
}
}