mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Profile editor - Removed delay in module override
Modules - Streamline update rules and properly honor them in timed updates
This commit is contained in:
1 parent
2eb4d615ae
commit
447a497945
7 files changed
+127
-79
No files matched your search
@@ -91,13 +91,13 @@ namespace Artemis.Core.Modules
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this module's activation was due to an override, can only be true if <see cref="IsActivated" /> is
|
||||
/// true
|
||||
/// <see langword="true" />
|
||||
/// </summary>
|
||||
public bool IsActivatedOverride { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this module should update if <see cref="IsActivatedOverride" /> is true
|
||||
/// <para>Defaults to <c>true</c></para>
|
||||
/// Gets whether this module should update if <see cref="IsActivatedOverride" /> is <see langword="true" />
|
||||
/// <para>Defaults to <see langword="true" /></para>
|
||||
/// </summary>
|
||||
public bool UpdateDuringActivationOverride { get; protected set; } = true;
|
||||
|
||||
@@ -138,6 +138,11 @@ namespace Artemis.Core.Modules
|
||||
/// </summary>
|
||||
public IEnumerable<ModuleTab> ModuleTabs { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether updating this module is currently allowed
|
||||
/// </summary>
|
||||
public bool IsUpdateAllowed => IsActivated && (UpdateDuringActivationOverride || !IsActivatedOverride);
|
||||
|
||||
/// <summary>
|
||||
/// Called each frame when the module must update
|
||||
/// </summary>
|
||||
@@ -189,7 +194,7 @@ namespace Artemis.Core.Modules
|
||||
|
||||
internal virtual void InternalUpdate(double deltaTime)
|
||||
{
|
||||
if (!IsActivatedOverride || UpdateDuringActivationOverride)
|
||||
if (IsUpdateAllowed)
|
||||
Update(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Artemis.Core.Modules
|
||||
|
||||
internal override void InternalUpdate(double deltaTime)
|
||||
{
|
||||
if (!IsActivatedOverride || UpdateDuringActivationOverride)
|
||||
if (IsUpdateAllowed)
|
||||
Update(deltaTime);
|
||||
|
||||
lock (this)
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace Artemis.Core
|
||||
|
||||
PluginInfo.Instance.PluginEnabled += InstanceOnPluginEnabled;
|
||||
PluginInfo.Instance.PluginDisabled += InstanceOnPluginDisabled;
|
||||
|
||||
if (PluginInfo.Instance.Enabled)
|
||||
Start();
|
||||
}
|
||||
@@ -54,13 +53,6 @@ namespace Artemis.Core
|
||||
if (_timer != null)
|
||||
return;
|
||||
|
||||
// Don't update during override if that is disabled on the module
|
||||
if (PluginInfo.Instance is Module module)
|
||||
{
|
||||
if (module.IsActivatedOverride && !module.UpdateDuringActivationOverride)
|
||||
return;
|
||||
}
|
||||
|
||||
_lastEvent = DateTime.Now;
|
||||
_timer = new Timer(Interval.TotalMilliseconds);
|
||||
_timer.Elapsed += TimerOnElapsed;
|
||||
@@ -94,6 +86,10 @@ namespace Artemis.Core
|
||||
var interval = DateTime.Now - _lastEvent;
|
||||
_lastEvent = DateTime.Now;
|
||||
|
||||
// Modules don't always want to update, honor that
|
||||
if (PluginInfo.Instance is Module module && !module.IsUpdateAllowed)
|
||||
return;
|
||||
|
||||
Action(interval.TotalSeconds);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user