Repository navigation
Expand file tree
/
Copy pathPreferenceActionController.cs
More file actions
69 lines (59 loc) · 2.72 KB
/
Copy pathPreferenceActionController.cs
File metadata and controls
69 lines (59 loc) · 2.72 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
using Kitchen;
using Kitchen.Layouts;
using KitchenData;
using KitchenMods;
using Unity.Collections;
using Unity.Entities;
namespace KitchenAutomationPlus
{
public struct SMakeSpaceOutside : IComponentData, IModComponent { }
public class PreferenceActionController : GameSystemBase, IModSystem
{
EntityQuery AppliancesOutsideQuery;
EntityQuery BlueprintsQuery;
EntityQuery SingletonEntitiesQuery;
static PreferenceActionController _instance;
protected override void Initialise()
{
base.Initialise();
_instance = this;
AppliancesOutsideQuery = GetEntityQuery(new QueryHelper()
.All(typeof(CDestroyApplianceAtDay))
.None(typeof(CTriggerPracticeMode), typeof(CRerollShopAfterDuration), typeof(CApplianceBlueprint), typeof(CLetterBlueprint), typeof(CLetterAppliance), typeof(CLetterIngredient)));
BlueprintsQuery = GetEntityQuery(new QueryHelper()
.All(typeof(CApplianceBlueprint), typeof(CPosition)));
SingletonEntitiesQuery = GetEntityQuery(new QueryHelper()
.Any(typeof(SMakeSpaceOutside)));
}
protected override void OnUpdate()
{
if (GameInfo.CurrentScene == SceneType.Kitchen && Has<SIsNightTime>())
{
if (Has<SMakeSpaceOutside>())
{
EntityManager.DestroyEntity(AppliancesOutsideQuery);
NativeArray<Entity> blueprintEntities = BlueprintsQuery.ToEntityArray(Allocator.Temp);
NativeArray<CPosition> blueprintPositions = BlueprintsQuery.ToComponentDataArray<CPosition>(Allocator.Temp);
CPosition newBlueprintPosition = GetFrontDoor(true);
for (int i = 0; i < blueprintEntities.Length; i++)
{
Entity blueprintEntity = blueprintEntities[i];
CPosition oldBlueprintPosition = blueprintPositions[i];
if (!LayoutHelpers.IsOutsidePlayable(TileManager.GetTile(oldBlueprintPosition).Type))
{
continue;
}
Set(blueprintEntity, newBlueprintPosition);
TileManager.SetOccupant(oldBlueprintPosition, default(Entity), OccupancyLayer.Default);
TileManager.SetOccupant(newBlueprintPosition, blueprintEntity, OccupancyLayer.Default);
}
}
}
EntityManager.DestroyEntity(SingletonEntitiesQuery);
}
public static void MakeSpaceOutside()
{
_instance?.Set<SMakeSpaceOutside>();
}
}
}