diff --git a/Source/MDK/MDKPackage.GeneratedInfo.cs b/Source/MDK/MDKPackage.GeneratedInfo.cs
index fb80e32..abb4ad5 100644
--- a/Source/MDK/MDKPackage.GeneratedInfo.cs
+++ b/Source/MDK/MDKPackage.GeneratedInfo.cs
@@ -8,7 +8,7 @@ public partial class MDKPackage
///
/// The current package version
///
- public static readonly Version Version = new Version("1.1.29");
+ public static readonly Version Version = new Version("1.1.30");
///
/// The required IDE version
diff --git a/Source/MDK/source.extension.vsixmanifest b/Source/MDK/source.extension.vsixmanifest
index d7e906e..c02e998 100644
--- a/Source/MDK/source.extension.vsixmanifest
+++ b/Source/MDK/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
MDK/SE
A toolkit to help with ingame script (programmable block) development for Keen Software House's space sandbox Space Engineers.
diff --git a/Source/MDKAnalyzer/whitelist.cache b/Source/MDKAnalyzer/whitelist.cache
index e03d85f..d482de3 100644
--- a/Source/MDKAnalyzer/whitelist.cache
+++ b/Source/MDKAnalyzer/whitelist.cache
@@ -1,13 +1,109 @@
System.Collections.*, mscorlib
-System.Collections.Generic.*, mscorlib
System.Collections.Generic.*, System.Core
System.Collections.Generic.*, System
-System.Collections.Concurrent.*, mscorlib
-System.Collections.Concurrent.*, System
-System.Linq.*, System.Core
+System.Collections.Generic.*, mscorlib
System.Text.*, mscorlib
System.Text.RegularExpressions.*, System
System.Globalization.*, mscorlib
+System.Linq.IQueryable+*, System.Core
+System.Linq.IQueryable+*, System.Core
+System.Linq.IQueryProvider+*, System.Core
+System.Linq.IOrderedQueryable+*, System.Core
+System.Linq.IOrderedQueryable+*, System.Core
+System.Linq.Queryable+*, System.Core
+System.Linq.Enumerable+*, System.Core
+System.Linq.EmptyEnumerable+*, System.Core
+System.Linq.IdentityFunction+*, System.Core
+System.Linq.IOrderedEnumerable+*, System.Core
+System.Linq.IGrouping+*, System.Core
+System.Linq.ILookup+*, System.Core
+System.Linq.Lookup+*, System.Core
+System.Linq.Set+*, System.Core
+System.Linq.GroupedEnumerable+*, System.Core
+System.Linq.GroupedEnumerable+*, System.Core
+System.Linq.OrderedEnumerable+*, System.Core
+System.Linq.OrderedEnumerable+*, System.Core
+System.Linq.EnumerableSorter+*, System.Core
+System.Linq.EnumerableSorter+*, System.Core
+System.Linq.Buffer+*, System.Core
+System.Linq.SystemCore_EnumerableDebugView+*, System.Core
+System.Linq.SystemCore_EnumerableDebugViewEmptyException+*, System.Core
+System.Linq.SystemCore_EnumerableDebugView+*, System.Core
+System.Linq.IIListProvider+*, System.Core
+System.Linq.SingleLinkedNode+*, System.Core
+System.Linq.EnumerableQuery+*, System.Core
+System.Linq.EnumerableQuery+*, System.Core
+System.Linq.EnumerableExecutor+*, System.Core
+System.Linq.EnumerableExecutor+*, System.Core
+System.Linq.EnumerableRewriter+*, System.Core
+System.Linq.TypeHelper+*, System.Core
+System.Linq.Strings+*, System.Core
+System.Linq.Error+*, System.Core
+System.Linq.AggregationMinMaxHelpers+*, System.Core
+System.Linq.SRDescriptionAttribute+*, System.Core
+System.Linq.SRCategoryAttribute+*, System.Core
+System.Linq.SR+*, System.Core
+System.Linq.Enumerable.Iterator+*, System.Core
+System.Linq.Enumerable.WhereEnumerableIterator+*, System.Core
+System.Linq.Enumerable.WhereArrayIterator+*, System.Core
+System.Linq.Enumerable.WhereListIterator+*, System.Core
+System.Linq.Enumerable.SelectEnumerableIterator+*, System.Core
+System.Linq.Enumerable.WhereSelectEnumerableIterator+*, System.Core
+System.Linq.Enumerable.WhereSelectArrayIterator+*, System.Core
+System.Linq.Enumerable.WhereSelectListIterator+*, System.Core
+System.Linq.Enumerable.AppendPrependIterator+*, System.Core
+System.Linq.Enumerable.AppendPrepend1Iterator+*, System.Core
+System.Linq.Enumerable.AppendPrependN+*, System.Core
+System.Linq.Enumerable.d__2+*, System.Core
+System.Linq.Enumerable.d__5+*, System.Core
+System.Linq.Enumerable.<>c__DisplayClass6_0+*, System.Core
+System.Linq.Enumerable.<>c__DisplayClass7_0+*, System.Core
+System.Linq.Enumerable.d__17+*, System.Core
+System.Linq.Enumerable.d__19+*, System.Core
+System.Linq.Enumerable.d__21+*, System.Core
+System.Linq.Enumerable.d__23+*, System.Core
+System.Linq.Enumerable.d__25+*, System.Core
+System.Linq.Enumerable.d__27+*, System.Core
+System.Linq.Enumerable.d__29+*, System.Core
+System.Linq.Enumerable.d__31+*, System.Core
+System.Linq.Enumerable.d__33+*, System.Core
+System.Linq.Enumerable.d__35+*, System.Core
+System.Linq.Enumerable.d__38+*, System.Core
+System.Linq.Enumerable.d__41+*, System.Core
+System.Linq.Enumerable.d__59+*, System.Core
+System.Linq.Enumerable.d__61+*, System.Core
+System.Linq.Enumerable.d__64+*, System.Core
+System.Linq.Enumerable.d__67+*, System.Core
+System.Linq.Enumerable.d__70+*, System.Core
+System.Linq.Enumerable.d__73+*, System.Core
+System.Linq.Enumerable.d__75+*, System.Core
+System.Linq.Enumerable.d__93+*, System.Core
+System.Linq.Enumerable.d__95+*, System.Core
+System.Linq.Enumerable.d__97+*, System.Core
+System.Linq.Enumerable.d__113+*, System.Core
+System.Linq.Enumerable.d__115+*, System.Core
+System.Linq.IdentityFunction.<>c+*, System.Core
+System.Linq.Lookup.Grouping+*, System.Core
+System.Linq.Lookup.d__12+*, System.Core
+System.Linq.Lookup.d__13+*, System.Core
+System.Linq.Set.Slot+*, System.Core
+System.Linq.OrderedEnumerable.d__1+*, System.Core
+System.Linq.EnumerableRewriter.<>c__DisplayClass9_0+*, System.Core
+System.Linq.EnumerableRewriter.<>c+*, System.Core
+System.Linq.EnumerableRewriter.<>c__DisplayClass10_0+*, System.Core
+System.Linq.ParallelEnumerable.<>c__10+*, System.Core
+System.Linq.ParallelEnumerable.<>c__DisplayClass47_0+*, System.Core
+System.Linq.ParallelEnumerable.<>c__DisplayClass48_0+*, System.Core
+System.Linq.ParallelEnumerable.<>c__DisplayClass49_0+*, System.Core
+System.Linq.ParallelEnumerable.<>c__DisplayClass50_0+*, System.Core
+System.Linq.ParallelEnumerable.<>c__51+*, System.Core
+System.Linq.ParallelEnumerable.<>c__149+*, System.Core
+System.Linq.AggregationMinMaxHelpers.<>c__DisplayClass3_0+*, System.Core
+System.Linq.AggregationMinMaxHelpers.<>c__DisplayClass4_0+*, System.Core
+System.Linq.AggregationMinMaxHelpers.<>c+*, System.Core
+System.Linq.ParallelQuery.<>c__1+*, System.Core
+System.Linq.ParallelQuery.<>c__2+*, System.Core
+System.Linq.Lookup.Grouping.d__7+*, System.Core
object+*, mscorlib
System.IDisposable+*, mscorlib
string+*, mscorlib
@@ -51,9 +147,6 @@ System.Xml.Serialization.XmlRootAttribute+*, System.Xml
System.Xml.Serialization.XmlTextAttribute+*, System.Xml
System.Xml.Serialization.XmlTypeAttribute+*, System.Xml
System.Runtime.CompilerServices.RuntimeHelpers+*, mscorlib
-System.IO.Stream+*, mscorlib
-System.IO.TextWriter+*, mscorlib
-System.IO.TextReader+*, mscorlib
System.IO.BinaryReader+*, mscorlib
System.IO.BinaryWriter+*, mscorlib
System.NullReferenceException+*, mscorlib
@@ -163,6 +256,7 @@ Sandbox.ModAPI.Interfaces.ITerminalProperty+*, Sandbox.Common
Sandbox.ModAPI.Interfaces.ITerminalProperty+*, Sandbox.Common
Sandbox.ModAPI.Interfaces.TerminalPropertyExtensions+*, Sandbox.Common
Sandbox.Game.Localization.MySpaceTexts+*, Sandbox.Game
+System.Text.StringBuilderExtensions_Format+*, VRage.Library
VRage.MyFixedPoint+*, VRage.Library
VRage.MyTuple+*, VRage.Library
VRage.MyTuple+*, VRage.Library
@@ -179,6 +273,7 @@ VRage.MyTexts.GetString(VRage.Utils.MyStringId), VRage
VRage.MyTexts.Exists(VRage.Utils.MyStringId), VRage
VRage.MyTexts.Get(VRage.Utils.MyStringId), VRage
VRage.MyTexts.AppendFormat(System.Text.StringBuilder, VRage.Utils.MyStringId, object), VRage
+VRage.MyTexts.AppendFormat(System.Text.StringBuilder, VRage.Utils.MyStringId, VRage.Utils.MyStringId), VRage
VRage.MyTexts.Languages, VRage
VRage.MyTexts.LanguageDescription+*, VRage
VRage.MyLanguagesEnum+*, VRage
@@ -193,9 +288,11 @@ VRage.Game.MyRelationsBetweenPlayerAndBlock+*, VRage.Game
VRage.Game.MyRelationsBetweenPlayerAndBlockExtensions+*, VRage.Game
VRage.Game.Components.MyResourceSourceComponentBase+*, VRage.Game
VRage.Game.ObjectBuilders.Definitions.MyObjectBuilder_GasProperties+*, VRage.Game
-VRage.Game.Components.MyComponentBase+*, VRage.Game
VRage.ObjectBuilders.SerializableDefinitionId+*, VRage.Game
VRage.Game.MyCubeSize+*, VRage.Game
+VRage.Game.Components.MyComponentBase, VRage.Game
+VRage.Game.Components.MyComponentBase.GetAs(), VRage.Game
+VRage.Game.Components.MyComponentBase.ContainerBase, VRage.Game
VRage.ObjectBuilders.MyObjectBuilder_Base, VRage.Game
VRage.ObjectBuilders.MyObjectBuilder_Base.TypeId, VRage.Game
VRage.ObjectBuilders.MyObjectBuilder_Base.SubtypeId, VRage.Game
@@ -206,6 +303,7 @@ Sandbox.Game.EntityComponents.MyResourceSourceComponent.DefinedOutput, Sandbox.G
Sandbox.Game.EntityComponents.MyResourceSourceComponent.ProductionEnabled, Sandbox.Game
Sandbox.Game.EntityComponents.MyResourceSourceComponent.RemainingCapacity, Sandbox.Game
Sandbox.Game.EntityComponents.MyResourceSourceComponent.HasCapacityRemaining, Sandbox.Game
+Sandbox.Game.EntityComponents.MyResourceSourceComponent.ResourceTypes, Sandbox.Game
Sandbox.Game.EntityComponents.MyResourceSinkComponent, Sandbox.Game
Sandbox.Game.EntityComponents.MyResourceSinkComponent.AcceptedResources, Sandbox.Game
Sandbox.Game.EntityComponents.MyResourceSinkComponent.RequiredInput, Sandbox.Game
@@ -221,4 +319,6 @@ VRage.Game.Components.MyResourceSinkComponentBase.MaxRequiredInputByType(VRage.G
VRage.Game.Components.MyResourceSinkComponentBase.RequiredInputByType(VRage.Game.MyDefinitionId), VRage.Game
VRage.Game.Components.MyResourceSinkComponentBase.SuppliedRatioByType(VRage.Game.MyDefinitionId), VRage.Game
System.ArrayExtensions, VRage.Library
-System.ArrayExtensions.Contains(T[], T), VRage.Library
\ No newline at end of file
+System.ArrayExtensions.Contains(T[], T), VRage.Library
+VRage.Game.ModAPI.Ingame.MyPhysicalInventoryItemExtensions_ModAPI+*, Sandbox.Game
+System.Collections.Immutable.*, System.Collections.Immutable
\ No newline at end of file
diff --git a/Source/MDKListenerPlugin/Base/SpaceEngineersPlugin.cs b/Source/MDKListenerPlugin/Base/SpaceEngineersPlugin.cs
new file mode 100644
index 0000000..04f9ecf
--- /dev/null
+++ b/Source/MDKListenerPlugin/Base/SpaceEngineersPlugin.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Diagnostics;
+using Sandbox.Game.World;
+using SpaceEngineers.Game;
+
+namespace MDKListenerPlugin.Base
+{
+ public abstract class SpaceEngineersPlugin
+ {
+ bool _isInitialized;
+ bool _isConnectedToSession;
+
+ public SpaceEngineersGame Game { get; private set; }
+
+ ~SpaceEngineersPlugin()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (MySession.Static != null)
+ MySession.Static.OnReady -= OnSessionReady;
+ MySession.OnLoading -= OnSessionLoading;
+ MySession.AfterLoading -= OnSessionAfterLoading;
+ MySession.OnUnloading -= OnSessionUnloading;
+ MySession.OnUnloaded -= OnSessionUnloaded;
+ }
+ }
+
+ public void Init(object gameInstance)
+ {
+ Debugger.Launch();
+ Game = (SpaceEngineersGame)gameInstance;
+ OnStarting();
+ }
+
+ protected virtual void OnStarting()
+ { }
+
+ protected virtual void OnSessionUnloaded()
+ { }
+
+ protected virtual void OnSessionUnloading()
+ { }
+
+ protected virtual void OnSessionAfterLoading()
+ { }
+
+ protected virtual void OnSessionLoading()
+ {
+ if (!_isConnectedToSession)
+ {
+ _isConnectedToSession = true;
+ MySession.Static.OnReady += OnSessionReady;
+ }
+ }
+
+ protected virtual void OnSessionReady()
+ { }
+
+ public void Update()
+ {
+ if (!_isInitialized)
+ {
+ _isInitialized = true;
+ OnInitialize();
+ }
+
+ if (MySession.Static == null)
+ return;
+ OnUpdate();
+ }
+
+ protected virtual void OnInitialize()
+ {
+ MySession.OnLoading += OnSessionLoading;
+ MySession.AfterLoading += OnSessionAfterLoading;
+ MySession.OnUnloading += OnSessionUnloading;
+ MySession.OnUnloaded += OnSessionUnloaded;
+ }
+
+ protected virtual void OnUpdate()
+ { }
+ }
+}
\ No newline at end of file
diff --git a/Source/MDKListenerPlugin/Base/SpaceEngineersSynchronizationContext.cs b/Source/MDKListenerPlugin/Base/SpaceEngineersSynchronizationContext.cs
new file mode 100644
index 0000000..94678ea
--- /dev/null
+++ b/Source/MDKListenerPlugin/Base/SpaceEngineersSynchronizationContext.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Sandbox;
+
+namespace MDKListenerPlugin.Base
+{
+ public class SpaceEngineersSynchronizationContext : SynchronizationContext
+ {
+ readonly string _invocationId;
+
+ public SpaceEngineersSynchronizationContext(string invocationId)
+ {
+ _invocationId = invocationId;
+ }
+
+ public override void Post(SendOrPostCallback d, object state)
+ {
+ void invoke() => d(state);
+ MySandboxGame.Static.Invoke(invoke, _invocationId);
+ }
+
+ public override void Send(SendOrPostCallback d, object state)
+ {
+ var tcs = new TaskCompletionSource