-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoMapService.Input.cs
More file actions
104 lines (93 loc) · 3.36 KB
/
AutoMapService.Input.cs
File metadata and controls
104 lines (93 loc) · 3.36 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
96
97
98
99
100
101
102
103
104
using Timberborn.Automation;
using UnityEngine;
namespace Calloatti.AutoTools
{
public partial class AutoMapService
{
public void ToggleAutoMap()
{
// 1. The hotkey is the ONLY thing that changes the state
switch (_currentState)
{
case MapDisplayState.Hidden:
_currentState = MapDisplayState.Global;
_notificationService.SendNotification(_loc.T("Calloatti.AutoTools.MapState.Global"));
break;
case MapDisplayState.Global:
_currentState = MapDisplayState.Single; // This is the Partition mode
_notificationService.SendNotification(_loc.T("Calloatti.AutoTools.MapState.Partition"));
break;
case MapDisplayState.Single:
_currentState = MapDisplayState.Hidden;
_notificationService.SendNotification(_loc.T("Calloatti.AutoTools.MapState.Off"));
break;
}
// 2. Redraw the map, but SUPPRESS the partition info so the mode notification stays visible
RefreshVisuals(suppressInfoNotification: true);
}
// 3. Added a default parameter so Events.cs can still call RefreshVisuals() normally
public void RefreshVisuals(bool suppressInfoNotification = false)
{
if (_currentState == MapDisplayState.Hidden)
{
SetVisibility(false);
_singleVisualizedAutomator = null;
_lastActivePartitionId = -1;
}
else if (_currentState == MapDisplayState.Global)
{
if (_isDirty)
{
RebuildAllLines();
_isDirty = false;
}
_singleVisualizedAutomator = null;
_lastActivePartitionId = -1; // Reset so the notification works if we switch back to Single
SetAllPartitionsActive(true);
SetVisibility(true);
}
else if (_currentState == MapDisplayState.Single) // Partition mode
{
if (_isDirty)
{
RebuildAllLines();
_isDirty = false;
}
Automator selectedAutomator = null;
if (_selectionService.IsAnythingSelected)
{
selectedAutomator = _selectionService.SelectedObject.GetComponent<Automator>();
}
_singleVisualizedAutomator = selectedAutomator;
if (selectedAutomator != null)
{
GameObject activeContainer = ShowOnlyPartition(selectedAutomator);
SetVisibility(true);
int currentId = -1;
int currentCount = 0;
// Extract the cached ID and count for the currently active container
if (activeContainer != null && _networkInfo.TryGetValue(activeContainer, out var info))
{
currentId = info.id;
currentCount = info.count;
}
// Only notify if we are looking at a DIFFERENT partition ID than before
if (currentId != _lastActivePartitionId)
{
_lastActivePartitionId = currentId;
// Don't overwrite the notification if we just pressed the mode toggle hotkey
if (!suppressInfoNotification && currentId != -1)
{
_notificationService.SendNotification(_loc.T("Calloatti.AutoTools.PartitionInfo", currentId.ToString(), currentCount.ToString()));
}
}
}
else
{
SetVisibility(false); // Hide lines until a building is selected
_lastActivePartitionId = -1;
}
}
}
}
}