-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSyndicateComponent.cs
More file actions
145 lines (123 loc) · 5.74 KB
/
Copy pathSyndicateComponent.cs
File metadata and controls
145 lines (123 loc) · 5.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using LiveSplit.Model;
using LiveSplit.TimeFormatters;
using LiveSplit.UI.Components;
using LiveSplit.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml;
using System.Windows.Forms;
using System.Diagnostics;
namespace LiveSplit.Syndicate
{
class SyndicateComponent : LogicComponent
{
public override string ComponentName
{
get { return "Syndicate (2012)"; }
}
public SyndicateSettings Settings { get; set; }
public bool Disposed { get; private set; }
public bool IsLayoutComponent { get; private set; }
private TimerModel _timer;
private GameMemory _gameMemory;
private LiveSplitState _state;
public SyndicateComponent(LiveSplitState state, bool isLayoutComponent)
{
_state = state;
this.IsLayoutComponent = isLayoutComponent;
this.Settings = new SyndicateSettings();
_timer = new TimerModel { CurrentState = state };
_gameMemory = new GameMemory(this.Settings);
_gameMemory.OnFirstLevelLoading += gameMemory_OnFirstLevelLoading;
_gameMemory.OnPlayerGainedControl += gameMemory_OnPlayerGainedControl;
_gameMemory.OnLoadStarted += gameMemory_OnLoadStarted;
_gameMemory.OnLoadFinished += gameMemory_OnLoadFinished;
_gameMemory.OnSplitCompleted += gameMemory_OnSplitCompleted;
state.OnStart += State_OnStart;
_gameMemory.StartMonitoring();
}
public override void Dispose()
{
this.Disposed = true;
_state.OnStart -= State_OnStart;
if (_gameMemory != null)
{
_gameMemory.Stop();
}
}
void State_OnStart(object sender, EventArgs e)
{
_gameMemory.resetSplitStates();
}
void gameMemory_OnFirstLevelLoading(object sender, EventArgs e)
{
if (this.Settings.AutoReset)
{
_timer.Reset();
}
}
void gameMemory_OnPlayerGainedControl(object sender, EventArgs e)
{
if (this.Settings.AutoStart)
{
_timer.Start();
}
}
void gameMemory_OnLoadStarted(object sender, EventArgs e)
{
_state.IsGameTimePaused = true;
}
void gameMemory_OnLoadFinished(object sender, EventArgs e)
{
_state.IsGameTimePaused = false;
}
void gameMemory_OnSplitCompleted(object sender, GameMemory.SplitArea split, uint frame)
{
Debug.WriteLineIf(split != GameMemory.SplitArea.None, String.Format("[NoLoads] Trying to split {0}, State: {1} - {2}", split, _gameMemory.splitStates[(int)split], frame));
if (_state.CurrentPhase == TimerPhase.Running && !_gameMemory.splitStates[(int)split] &&
((split == GameMemory.SplitArea.SC1_WakeUpCall && this.Settings.sC01) ||
(split == GameMemory.SplitArea.SC1_Tutorial1 && this.Settings.sC01_T) ||
(split == GameMemory.SplitArea.SC2_AssaultOnAspari && this.Settings.sC02) ||
(split == GameMemory.SplitArea.SC2_Tutorial2 && this.Settings.sC02_T) ||
(split == GameMemory.SplitArea.SC3_AspariExtraction && this.Settings.sC03) ||
(split == GameMemory.SplitArea.SC4_A_train_to_catch && this.Settings.sC04) ||
(split == GameMemory.SplitArea.SC5_Escape_from_Los_angeles && this.Settings.sC05) ||
(split == GameMemory.SplitArea.SC6_Eurocorp && this.Settings.sC06) ||
(split == GameMemory.SplitArea.SC6_Tutorial3 && this.Settings.sC06_T) ||
(split == GameMemory.SplitArea.SC7_Voyeur_Central && this.Settings.sC07) ||
(split == GameMemory.SplitArea.SC8_Cayman_Global && this.Settings.sC08) ||
(split == GameMemory.SplitArea.SC9_The_Floating_City && this.Settings.sC09) ||
(split == GameMemory.SplitArea.SC10_Behind_the_scenes && this.Settings.sC10) ||
(split == GameMemory.SplitArea.SC11_Ramon && this.Settings.sC11) ||
(split == GameMemory.SplitArea.SC12_Downzone && this.Settings.sC12) ||
(split == GameMemory.SplitArea.SC13_Betrayed && this.Settings.sC13) ||
(split == GameMemory.SplitArea.SC14_The_wall && this.Settings.sC14) ||
(split == GameMemory.SplitArea.SC15_Kris && this.Settings.sC15) ||
(split == GameMemory.SplitArea.SC16_HumanResources && this.Settings.sC16) ||
(split == GameMemory.SplitArea.SC17_CorporateWar && this.Settings.sC17) ||
(split == GameMemory.SplitArea.SC18_SpireAccess && this.Settings.sC18) ||
(split == GameMemory.SplitArea.SC19_BurningTower && this.Settings.sC19) ||
(split == GameMemory.SplitArea.SC20_Jack_Denham && this.Settings.sC20)))
{
Trace.WriteLine(String.Format("[NoLoads] {0} Split - {1}", split, frame));
_timer.Split();
_gameMemory.splitStates[(int)split] = true;
}
}
public override XmlNode GetSettings(XmlDocument document)
{
return this.Settings.GetSettings(document);
}
public override Control GetSettingsControl(LayoutMode mode)
{
return this.Settings;
}
public override void SetSettings(XmlNode settings)
{
this.Settings.SetSettings(settings);
}
public override void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { }
//public override void RenameComparison(string oldName, string newName) { }
}
}