forked from CS2Surf/Timer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTick.cs
More file actions
95 lines (78 loc) · 3.76 KB
/
Tick.cs
File metadata and controls
95 lines (78 loc) · 3.76 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
using CounterStrikeSharp.API.Modules.Cvars;
using CounterStrikeSharp.API.Modules.Entities.Constants;
namespace SurfTimer;
public partial class SurfTimer
{
public void OnTick()
{
if (CurrentMap == null)
return;
foreach (var player in playerList.Values)
{
player.Timer.Tick();
player.ReplayRecorder.Tick(player);
player.HUD.Display();
if (player.Controller.Collision == null) continue;
if ((CollisionGroup)player.Controller.Collision.CollisionGroup == CollisionGroup.COLLISION_GROUP_DEBRIS) continue;
player.Controller.SetCollisionGroup(CollisionGroup.COLLISION_GROUP_DEBRIS);
}
// Need to disable maps from executing their cfgs. Currently idk how (But seriusly it a security issue)
ConVar? bot_quota = ConVar.Find("bot_quota");
if (bot_quota != null)
{
int cbq = bot_quota.GetPrimitiveValue<int>();
int replaybot_count = 1 +
(CurrentMap.ReplayManager.StageWR != null ? 1 : 0) +
(CurrentMap.ReplayManager.BonusWR != null ? 1 : 0) +
CurrentMap.ReplayManager.CustomReplays.Count;
if (cbq != replaybot_count)
{
bot_quota.SetValue(replaybot_count);
}
}
CurrentMap.ReplayManager.MapWR.Tick();
CurrentMap.ReplayManager.StageWR?.Tick();
CurrentMap.ReplayManager.BonusWR?.Tick();
if (CurrentMap.ReplayManager.MapWR.MapTimeID != -1)
{
CurrentMap.ReplayManager.MapWR.FormatBotName();
}
// Here we will load the NEXT stage replay from AllStageWR
if (CurrentMap.ReplayManager.StageWR?.RepeatCount == 0)
{
int next_stage;
if (CurrentMap.ReplayManager.AllStageWR[(CurrentMap.ReplayManager.StageWR.Stage % CurrentMap.Stages) + 1][0].MapTimeID == -1)
next_stage = 1;
else
next_stage = (CurrentMap.ReplayManager.StageWR.Stage % CurrentMap.Stages) + 1;
CurrentMap.ReplayManager.AllStageWR[next_stage][0].Controller = CurrentMap.ReplayManager.StageWR.Controller;
CurrentMap.ReplayManager.StageWR = CurrentMap.ReplayManager.AllStageWR[next_stage][0];
CurrentMap.ReplayManager.StageWR.LoadReplayData(repeat_count: 3);
CurrentMap.ReplayManager.StageWR.FormatBotName();
CurrentMap.ReplayManager.StageWR.Start();
}
if (CurrentMap.ReplayManager.BonusWR?.RepeatCount == 0)
{
int next_bonus;
if (CurrentMap.ReplayManager.AllBonusWR[(CurrentMap.ReplayManager.BonusWR.Stage % CurrentMap.Bonuses) + 1][0].MapTimeID == -1)
next_bonus = 1;
else
next_bonus = (CurrentMap.ReplayManager.BonusWR.Stage % CurrentMap.Bonuses) + 1;
CurrentMap.ReplayManager.AllBonusWR[next_bonus][0].Controller = CurrentMap.ReplayManager.BonusWR.Controller;
CurrentMap.ReplayManager.BonusWR = CurrentMap.ReplayManager.AllBonusWR[next_bonus][0];
CurrentMap.ReplayManager.BonusWR.LoadReplayData(repeat_count: 3);
CurrentMap.ReplayManager.BonusWR.FormatBotName();
CurrentMap.ReplayManager.BonusWR.Start();
}
for (int i = 0; i < CurrentMap.ReplayManager.CustomReplays.Count; i++)
{
if (CurrentMap.ReplayManager.CustomReplays[i].MapID != CurrentMap.ID)
CurrentMap.ReplayManager.CustomReplays[i].MapID = CurrentMap.ID;
CurrentMap.ReplayManager.CustomReplays[i].Tick();
if (CurrentMap.ReplayManager.CustomReplays[i].RepeatCount == 0)
{
CurrentMap.KickReplayBot(i);
}
}
}
}