From 66fff6939611983a2171240f65855f5fdb643a4f Mon Sep 17 00:00:00 2001 From: annabunches Date: Tue, 11 Feb 2025 14:36:24 -0500 Subject: [PATCH] Don't actually use the IConsoleProgram interface in code since it would require a huge number of casts and everything is inside Program anyway. --- AirMonitor/AirZone.cs | 8 ++++---- AirMonitor/Program.cs | 2 +- Airlock/Airlock.cs | 2 +- Mixins/Console/Console.cs | 3 +++ Mixins/Sequencer/Sequencer.cs | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/AirMonitor/AirZone.cs b/AirMonitor/AirZone.cs index cf88a24..6bd4942 100644 --- a/AirMonitor/AirZone.cs +++ b/AirMonitor/AirZone.cs @@ -14,7 +14,7 @@ namespace IngameScript public bool Triggered { get; private set; } = false; public List Vents { get; } = new List(); - private IConsoleProgram _program; + private Program _program; private List _doors = new List(); private List _displays = new List(); private List _lights = new List(); @@ -23,12 +23,12 @@ namespace IngameScript private const float TriggerLevel = 0.75F; - public AirZone(string zoneName, IConsoleProgram program) + public AirZone(Program program, string zoneName) { Name = zoneName; _program = program; - _console = new PrefixedConsole(program.Console, zoneName); - _sequencer = new Sequencer(program, zoneName); + _console = new PrefixedConsole(_program.Console, Name); + _sequencer = new Sequencer(_program, Name); } public void AddBlock(IMyTerminalBlock block) diff --git a/AirMonitor/Program.cs b/AirMonitor/Program.cs index 848c709..757fd59 100644 --- a/AirMonitor/Program.cs +++ b/AirMonitor/Program.cs @@ -72,7 +72,7 @@ namespace IngameScript { if (!_zones.ContainsKey(zone)) { - _zones[zone] = new AirZone(zone, this); + _zones[zone] = new AirZone(this, zone); } _zones[zone].AddBlock(block); } diff --git a/Airlock/Airlock.cs b/Airlock/Airlock.cs index 48ce888..9db601d 100644 --- a/Airlock/Airlock.cs +++ b/Airlock/Airlock.cs @@ -86,7 +86,7 @@ namespace IngameScript private const int CooldownTicks = 120; private const int SealTimeoutTicks = 30; - public Airlock(string name, IConsoleProgram _program) + public Airlock(string name, Program _program) { _ini = _program.Ini; _name = name; diff --git a/Mixins/Console/Console.cs b/Mixins/Console/Console.cs index 4cf1c39..d3a1456 100644 --- a/Mixins/Console/Console.cs +++ b/Mixins/Console/Console.cs @@ -11,6 +11,9 @@ namespace IngameScript { // A Program that supports consoles by initializing a MyIni instance // and providing a public console for member objects to refer back to. + // If you're using this library it is highly advised that you implement this interface + // for a clean, consistent way to avoid errors. + // // (It is probably an anti-pattern that this lives outside of the Program class, // but we can't find a cleaner way to implement this.) public interface IConsoleProgram diff --git a/Mixins/Sequencer/Sequencer.cs b/Mixins/Sequencer/Sequencer.cs index 29847d8..b2a3cee 100644 --- a/Mixins/Sequencer/Sequencer.cs +++ b/Mixins/Sequencer/Sequencer.cs @@ -18,7 +18,7 @@ namespace IngameScript private SortedDictionary> _sequence = new SortedDictionary>(); - public Sequencer(IConsoleProgram program, string name) + public Sequencer(Program program, string name) { Name = name; _console = new PrefixedConsole(program.Console, Name);