-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupCountController.cs
More file actions
71 lines (63 loc) · 2.52 KB
/
GroupCountController.cs
File metadata and controls
71 lines (63 loc) · 2.52 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
using Kitchen;
using KitchenCustomDifficulty.Patches;
using System;
using System.Reflection;
using Unity.Entities;
namespace KitchenCustomDifficulty
{
[UpdateAfter(typeof(StartNewDay))]
[UpdateInGroup(typeof(TimeManagementGroup))]
internal class GroupCountController : RestaurantSystem
{
private struct CustomerSettings
{
public int Enabled;
public int BaseMultiplier;
public int PerPlayerMultiplier;
public int MinGroupSize;
public int MaxGroupSize;
public int CustomerChangePerPoint;
public bool HasChanged(CustomerSettings other)
{
return
Enabled != other.Enabled ||
BaseMultiplier != other.BaseMultiplier ||
PerPlayerMultiplier != other.BaseMultiplier ||
MinGroupSize != other.MinGroupSize ||
MaxGroupSize != other.MaxGroupSize ||
CustomerChangePerPoint != other.CustomerChangePerPoint;
}
}
private CustomerSettings prevSettings;
private static Type sCacheHashType = typeof(CreateCustomerSchedule).GetNestedType("SCacheHash", BindingFlags.NonPublic);
EntityQuery sCacheHashQuery;
protected override void Initialise()
{
base.Initialise();
sCacheHashQuery = GetEntityQuery(sCacheHashType);
prevSettings = default;
}
protected override void OnUpdate()
{
if (!Has<SIsNightTime>())
{
prevSettings = default;
return;
}
CustomerSettings customerSettings = new CustomerSettings
{
Enabled = Main.PrefSysManager.Get<int>(Main.PLAYER_CUSTOMERS_ENABLED_ID),
BaseMultiplier = Main.PrefSysManager.Get<int>(Main.BASE_PLAYER_CUSTOMERS_ID),
PerPlayerMultiplier = Main.PrefSysManager.Get<int>(Main.CUSTOMERS_PER_PLAYER_ID),
MinGroupSize = Main.PrefSysManager.Get<int>(Main.CUSTOMERS_MIN_GROUP_SIZE_ID),
MaxGroupSize = Main.PrefSysManager.Get<int>(Main.CUSTOMERS_MAX_GROUP_SIZE_ID),
CustomerChangePerPoint = Main.PrefSysManager.Get<int>(Main.CARD_CUSTOMER_CHANGE_PER_POINT_ID)
};
if (prevSettings.HasChanged(customerSettings))
{
EntityManager.DestroyEntity(sCacheHashQuery);
prevSettings = customerSettings;
}
}
}
}