Skip to content

Commit ef0e45a

Browse files
committed
Stop custom axis at the end of simulation.
1 parent 20a38ee commit ef0e45a

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

AdvancedControlsMod/Axes/CustomAxis.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public CustomAxis(string name) : base(name)
8484
GlobalScope = false;
8585
Running = false;
8686
editor = new UI.CustomAxisEditor(this);
87+
88+
Game.OnSimulationToggle += (bool value) => { if (!value) { Stop(); } };
8789
}
8890

8991
/// <summary>
@@ -108,9 +110,8 @@ protected override void Update()
108110
{
109111
if (!PythonEnvironment.Loaded) return;
110112
if (!Running && initialised)
111-
{ // Stops running if not initialised
112-
initialised = false;
113-
Running = false;
113+
{
114+
Stop();
114115
}
115116
if (!Running) return;
116117
if (initialised)
@@ -137,8 +138,7 @@ protected override void Update()
137138
{ // On raised exception, it displays it and stops execution.
138139
if (e.InnerException != null) e = e.InnerException;
139140
Error = PythonEnvironment.FormatException(e);
140-
Running = false;
141-
initialised = false;
141+
Stop();
142142
}
143143
}
144144
else
@@ -193,6 +193,12 @@ protected override void Initialise()
193193
initialised = true;
194194
}
195195

196+
private void Stop()
197+
{
198+
Running = false;
199+
initialised = false;
200+
}
201+
196202
/// <summary>
197203
/// Goes through all global names in scope and checks if they represent an InputAxis object.
198204
/// </summary>

AdvancedControlsMod/Mod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override Version Version
2929
}
3030

3131
public override string VersionExtra { get; } = "";
32-
public override string BesiegeVersion { get; } = "v0.32";
32+
public override string BesiegeVersion { get; } = "v0.35";
3333
public override bool CanBeUnloaded { get; } = true;
3434
public override bool Preload { get; } = false;
3535
#pragma warning restore CS1591

0 commit comments

Comments
 (0)