Updated for RGB.NET's changes regarding rotation

This commit is contained in:
SpoinkyNL committed 2019-11-21 08:45:38 +01:00
1 parent 57a2be778d
commit 6cf3344ce7
19 files changed
+175 -88

No files matched your search

+18 -8
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
@@ -21,6 +22,7 @@ namespace Artemis.Core.Services
private readonly IPluginService _pluginService;
private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService;
private List<Module> _modules;
internal CoreService(ILogger logger, IPluginService pluginService, IRgbService rgbService, ISurfaceService surfaceService)
{
@@ -31,6 +33,10 @@ namespace Artemis.Core.Services
_rgbService.Surface.Updating += SurfaceOnUpdating;
_rgbService.Surface.Updated += SurfaceOnUpdated;
_modules = _pluginService.GetPluginsOfType<Module>();
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
_pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
Task.Run(Initialize);
}
@@ -66,11 +72,12 @@ namespace Artemis.Core.Services
{
try
{
var modules = _pluginService.GetPluginsOfType<Module>();
// Update all active modules
foreach (var module in modules)
module.Update(args.DeltaTime);
lock (_modules)
{
// Update all active modules
foreach (var module in _modules)
module.Update(args.DeltaTime);
}
// If there is no graphics decorator, skip the frame
if (_rgbService.GraphicsDecorator == null)
@@ -84,11 +91,14 @@ namespace Artemis.Core.Services
return;
g.Clear(Color.Black);
foreach (var module in modules)
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, g);
lock (_modules)
{
foreach (var module in _modules)
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, g);
}
}
OnFrameRendering(new FrameRenderingEventArgs(modules, _rgbService.GraphicsDecorator.GetBitmap(), args.DeltaTime, _rgbService.Surface));
OnFrameRendering(new FrameRenderingEventArgs(_modules, _rgbService.GraphicsDecorator.GetBitmap(), args.DeltaTime, _rgbService.Surface));
}
catch (Exception e)
{