-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoMapService.Events.cs
More file actions
57 lines (51 loc) · 1.33 KB
/
AutoMapService.Events.cs
File metadata and controls
57 lines (51 loc) · 1.33 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
using System;
using Timberborn.Automation;
using Timberborn.EntitySystem;
using Timberborn.RelationSystem;
using Timberborn.SelectionSystem;
using Timberborn.SingletonSystem;
namespace Calloatti.AutoTools
{
public partial class AutoMapService
{
[OnEvent]
public void OnEntityInitialized(EntityInitializedEvent e)
{
if (e.Entity.TryGetComponent(out Automator automator))
{
((IRelationOwner)automator).RelationsChanged += OnRelationsChanged;
MarkDirty();
}
}
[OnEvent]
public void OnEntityDeleted(EntityDeletedEvent e)
{
if (e.Entity.TryGetComponent(out Automator automator))
{
((IRelationOwner)automator).RelationsChanged -= OnRelationsChanged;
MarkDirty();
}
}
[OnEvent]
public void OnSelectableObjectSelected(SelectableObjectSelectedEvent e)
{
// Re-trigger visual logic so Partition mode knows which lines to show
RefreshVisuals();
}
[OnEvent]
public void OnSelectableObjectUnselected(SelectableObjectUnselectedEvent e)
{
// Re-trigger visual logic so lines hide when nothing is selected
RefreshVisuals();
}
private void OnRelationsChanged(object sender, EventArgs e)
{
MarkDirty();
}
private void MarkDirty()
{
_isDirty = true;
RefreshVisuals();
}
}
}