mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
Code cleanup
This commit is contained in:
parent
8390c7da68
commit
2b314091eb
@ -43,6 +43,11 @@ namespace CUE.NET.Brushes
|
||||
/// </summary>
|
||||
public Dictionary<BrushRenderTarget, Color> RenderedTargets { get; } = new Dictionary<BrushRenderTarget, Color>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CUE.NET.Brushes
|
||||
@ -40,11 +41,6 @@ namespace CUE.NET.Brushes
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image drawn by the brush. If null it will default to full transparent.
|
||||
/// </summary>
|
||||
@ -63,7 +59,7 @@ namespace CUE.NET.Brushes
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
||||
/// </summary>
|
||||
|
||||
@ -17,12 +17,7 @@ namespace CUE.NET.Brushes
|
||||
public class LinearGradientBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0f, 0.5f)
|
||||
/// </summary>
|
||||
|
||||
@ -11,12 +11,7 @@ namespace CUE.NET.Brushes
|
||||
public class ProfileBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
|
||||
private Dictionary<CorsairLedId, Color> _colors;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -16,11 +16,6 @@ namespace CUE.NET.Brushes
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the center point (as percentage in the range [0..1]) around which the brush should be drawn.
|
||||
/// </summary>
|
||||
|
||||
@ -14,12 +14,7 @@ namespace CUE.NET.Brushes
|
||||
public class RandomColorBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
|
||||
private Random _random = new Random();
|
||||
|
||||
#endregion
|
||||
|
||||
@ -11,12 +11,7 @@ namespace CUE.NET.Brushes
|
||||
public class SolidColorBrush : AbstractBrush
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
/// </summary>
|
||||
protected override IBrush EffectTarget => this;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color drawn by the brush.
|
||||
/// </summary>
|
||||
|
||||
@ -19,7 +19,7 @@ namespace CUE.NET.Effects
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IBrush"/> this effect is targeting.
|
||||
/// </summary>
|
||||
protected IBrush Brush { get; private set; }
|
||||
protected IBrush Brush { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -15,12 +15,12 @@ namespace CUE.NET.Effects
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private IList<EffectTimeContainer> _effectTimes = new List<EffectTimeContainer>();
|
||||
protected IList<EffectTimeContainer> EffectTimes = new List<EffectTimeContainer>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all <see cref="IEffect{T}" /> attached to this target.
|
||||
/// </summary>
|
||||
protected IList<IEffect<T>> Effects => _effectTimes.Select(x => x.Effect).Cast<IEffect<T>>().ToList();
|
||||
protected IList<IEffect<T>> Effects => EffectTimes.Select(x => x.Effect).Cast<IEffect<T>>().ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strongly-typed target used for the effect.
|
||||
@ -34,13 +34,13 @@ namespace CUE.NET.Effects
|
||||
/// <summary>
|
||||
/// Updates all effects added to this target.
|
||||
/// </summary>
|
||||
public void UpdateEffects()
|
||||
public virtual void UpdateEffects()
|
||||
{
|
||||
lock (Effects)
|
||||
{
|
||||
for (int i = _effectTimes.Count - 1; i >= 0; i--)
|
||||
for (int i = EffectTimes.Count - 1; i >= 0; i--)
|
||||
{
|
||||
EffectTimeContainer effectTime = _effectTimes[i];
|
||||
EffectTimeContainer effectTime = EffectTimes[i];
|
||||
long currentTicks = DateTime.Now.Ticks;
|
||||
|
||||
float deltaTime;
|
||||
@ -57,7 +57,7 @@ namespace CUE.NET.Effects
|
||||
|
||||
|
||||
if (effectTime.Effect.IsDone)
|
||||
_effectTimes.RemoveAt(i);
|
||||
EffectTimes.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,25 +66,25 @@ namespace CUE.NET.Effects
|
||||
/// Adds an affect.
|
||||
/// </summary>
|
||||
/// <param name="effect">The effect to add.</param>
|
||||
public void AddEffect(IEffect<T> effect)
|
||||
public virtual void AddEffect(IEffect<T> effect)
|
||||
{
|
||||
if (_effectTimes.Any(x => x.Effect == effect)) return;
|
||||
if (EffectTimes.Any(x => x.Effect == effect)) return;
|
||||
|
||||
effect.OnAttach(EffectTarget);
|
||||
_effectTimes.Add(new EffectTimeContainer(effect, -1));
|
||||
EffectTimes.Add(new EffectTimeContainer(effect, -1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an effect
|
||||
/// </summary>
|
||||
/// <param name="effect">The effect to remove.</param>
|
||||
public void RemoveEffect(IEffect<T> effect)
|
||||
public virtual void RemoveEffect(IEffect<T> effect)
|
||||
{
|
||||
EffectTimeContainer effectTimeToRemove = _effectTimes.FirstOrDefault(x => x.Effect == effect);
|
||||
EffectTimeContainer effectTimeToRemove = EffectTimes.FirstOrDefault(x => x.Effect == effect);
|
||||
if (effectTimeToRemove == null) return;
|
||||
|
||||
effect.OnDetach(EffectTarget);
|
||||
_effectTimes.Remove(effectTimeToRemove);
|
||||
EffectTimes.Remove(effectTimeToRemove);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -21,7 +21,7 @@ namespace CUE.NET.Effects
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ILedGroup"/> this effect is targeting.
|
||||
/// </summary>
|
||||
protected ILedGroup LedGroup { get; private set; }
|
||||
protected ILedGroup LedGroup { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user