Repository navigation
Expand file tree
/
Copy pathUpdateTimerDuration.cs
More file actions
68 lines (56 loc) · 1.74 KB
/
Copy pathUpdateTimerDuration.cs
File metadata and controls
68 lines (56 loc) · 1.74 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
using Kitchen;
using KitchenMods;
using Unity.Entities;
namespace KitchenInGameTimer
{
public struct STimer : IComponentData, IModComponent
{
public float Seconds;
public bool RunDay;
public bool RunNight;
public bool ResetStartOfDay;
public bool ResetStartOfNight;
public bool RunWhenPaused;
}
[UpdateInGroup(typeof(TimeManagementGroup))]
public class UpdateTimerDuration : RestaurantSystem, IModSystem
{
private EntityQuery Popups;
protected override void Initialise()
{
base.Initialise();
Popups = GetEntityQuery(typeof(CPopup));
RequireSingletonForUpdate<STimer>();
}
protected override void OnUpdate()
{
STimer timer = GetSingleton<STimer>();
if (Main.RequestReset)
{
timer.Seconds = 0;
Main.RequestReset = false;
}
if (Has<SIsNightFirstUpdate>())
{
if (timer.ResetStartOfNight)
timer.Seconds = 0;
}
if (Has<SIsDayFirstUpdate>())
{
if (timer.ResetStartOfDay)
timer.Seconds = 0;
}
if (!Has<SGameOver>()
&& (!base.Time.IsPaused || timer.RunWhenPaused)
&& (Popups.IsEmpty || timer.RunWhenPaused))
{
if (((Has<SIsNightTime>() || Has<SPracticeMode>()) == timer.RunNight) ||
((Has<SIsDayTime>() && !Has<SPracticeMode>()) == timer.RunDay))
{
timer.Seconds += base.Time.RealDeltaTime;
}
}
Set(timer);
}
}
}