Skip to content

Commit

Permalink
revert adding plugins to MyPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Rynchodon committed Jan 6, 2017
1 parent b6df03b commit e32675f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Injector/Injector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\global.config" />
<PropertyGroup>
<PostBuildEvent>start cmd.exe /C ""$(ReferencePath)\LoadArms.exe" --author=Rynchodon --repo=Load-ARMS LoadARMS.exe LoadArms.dll "..\..\..\..\Load-ARMS Readme.txt""</PostBuildEvent>
<PostBuildEvent>start cmd.exe /C ""$(ReferencePath)\LoadArms.exe" --author=Rynchodon --repo=Load-ARMS --allBuilds LoadARMS.exe LoadArms.dll "..\..\..\..\Load-ARMS Readme.txt""</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>
Expand Down
2 changes: 1 addition & 1 deletion Load-ARMS Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Modders
=======
Load-ARMS has command line options for adding locally compiled mods and publishing them to GitHub, this is the easiest way to make sure Load-ARMS can download them and load them into Space Engineers.

Load-ARMS loads mods as plugins, so make sure you have at least one class that implements VRage.Plugins.IPlugin.
Load-ARMS will call Init and Update on every class that implements VRage.Plugins.IPlugin in loaded mods. Any other registrations need to be handled by the loaded mod.

To publish a mod, you will need a public repository on GitHub and a personal access token with the scope public_repo. See https://help.github.com/articles/creating-an-access-token-for-command-line-use/

Expand Down
22 changes: 10 additions & 12 deletions Loader/LoadArms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ private struct Data
private Data _data;
private ParallelTasks.Task _task;
private DownloadProgress.Stats _downProgress = new DownloadProgress.Stats();
private bool _startedRobocopy, _loadedPlugins;
private List<IPlugin> _plugins;
private bool _startedRobocopy;

/// <summary>
/// Creates an instance of LoadArms and starts the updating process.
Expand Down Expand Up @@ -245,11 +246,16 @@ void IPlugin.Update()
if (_instance != this)
return;

if (!_loadedPlugins && _task.IsComplete)
if (_plugins != null)
{
foreach (IPlugin plugin in _plugins)
plugin.Update();
}
else if (_task.IsComplete)
{
Logger.WriteLine("Finished task, loading plugins");
_loadedPlugins = true;
foreach (IPlugin plugin in LoadPlugins())
_plugins = LoadPlugins();
foreach (IPlugin plugin in _plugins)
plugin.Init(MySandboxGame.Static);

_directory = null;
Expand Down Expand Up @@ -386,14 +392,6 @@ private List<IPlugin> LoadPlugins()
foreach (ModVersion mod in _data.ModsCurrentVersions.Values)
LoadPlugins(chainedPlugins, mod, loadedMods);

Logger.WriteLine("Adding plugins to MyPlugins");

FieldInfo MyPlugins__m_plugins = typeof(MyPlugins).GetField("m_plugins", BindingFlags.Static | BindingFlags.NonPublic);
List<IPlugin> allPlugins = (List<IPlugin>)MyPlugins__m_plugins.GetValue(null);
allPlugins = new List<IPlugin>(allPlugins);
allPlugins.AddList(chainedPlugins);
MyPlugins__m_plugins.SetValue(null, allPlugins);

return chainedPlugins;
}

Expand Down
3 changes: 2 additions & 1 deletion Loader/Loader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
</PropertyGroup>
<Import Project="../packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets" Condition="Exists('../packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets')" />
<PropertyGroup>
<PreBuildEvent>start cmd.exe /C "$(SolutionDir)\ResolveDependencies.exe"</PreBuildEvent>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit e32675f

Please sign in to comment.