-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoftAutoModerationEntryCar.cs
More file actions
53 lines (42 loc) · 1.49 KB
/
SoftAutoModerationEntryCar.cs
File metadata and controls
53 lines (42 loc) · 1.49 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
using System;
using AssettoServer.Server;
using AssettoServer.Server.Ai.Splines;
using SoftAutoModerationPlugin.Packets;
namespace SoftAutoModerationPlugin;
public class SoftAutoModerationEntryCar
{
public EntryCar EntryCar { get; }
public int CurrentSplinePointId { get; private set; } = -1;
public float CurrentSplinePointDistanceSquared { get; private set; }
public int NoLightSeconds { get; set; }
public bool HasSentNoLightWarning { get; set; }
public int WrongWaySeconds { get; set; }
public bool HasSentWrongWayWarning { get; set; }
public int BlockingRoadSeconds { get; set; }
public bool HasSentBlockingRoadWarning { get; set; }
public Flags CurrentFlags { get; set; }
private readonly AiSpline? _aiSpline;
public SoftAutoModerationEntryCar(EntryCar entryCar, AiSpline? aiSpline = null)
{
EntryCar = entryCar;
EntryCar.ResetInvoked += OnResetInvoked;
_aiSpline = aiSpline;
}
private void OnResetInvoked(EntryCar sender, EventArgs args)
{
NoLightSeconds = 0;
HasSentNoLightWarning = false;
WrongWaySeconds = 0;
HasSentNoLightWarning = false;
BlockingRoadSeconds = 0;
HasSentBlockingRoadWarning = false;
CurrentFlags = 0;
}
public void UpdateSplinePoint()
{
if (_aiSpline != null)
{
(CurrentSplinePointId, CurrentSplinePointDistanceSquared) = _aiSpline.WorldToSpline(EntryCar.Status.Position);
}
}
}