Added method to check if an effect can be applied to a specific target

This commit is contained in:
DarthAffe committed 2016-09-11 09:44:05 +02:00
1 parent 8b87270b69
commit 5c6dba769b
4 files changed
+31

No files matched your search

+10
View File
@@ -31,6 +31,16 @@ namespace CUE.NET.Effects
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
public abstract void Update(float deltaTime);
/// <summary>
/// Checks if the effect can be applied to the target object.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
/// <returns><c>true</c> if the effect can be attached; otherwise, <c>false</c>.</returns>
public virtual bool CanBeAppliedTo(IBrush target)
{
return true;
}
/// <summary>
/// Hook which is called when the effect is attached to a device.
/// </summary>
+4
View File
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CUE.NET.Exceptions;
namespace CUE.NET.Effects
{
@@ -70,6 +71,9 @@ namespace CUE.NET.Effects
{
if (EffectTimes.Any(x => x.Effect == effect)) return;
if (!effect.CanBeAppliedTo(EffectTarget))
throw new WrapperException($"Failed to add effect.\r\nThe effect of type '{effect.GetType()}' can't be applied to the target of type '{EffectTarget.GetType()}'.");
effect.OnAttach(EffectTarget);
EffectTimes.Add(new EffectTimeContainer(effect, -1));
}
+10
View File
@@ -33,6 +33,16 @@ namespace CUE.NET.Effects
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
public abstract void Update(float deltaTime);
/// <summary>
/// Checks if the effect can be applied to the target object.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
/// <returns><c>true</c> if the effect can be attached; otherwise, <c>false</c>.</returns>
public virtual bool CanBeAppliedTo(ILedGroup target)
{
return true;
}
/// <summary>
/// Hook which is called when the effect is attached to a device.
/// </summary>
+7
View File
@@ -38,6 +38,13 @@ namespace CUE.NET.Effects
{
#region Methods
/// <summary>
/// Checks if the effect can be applied to the target object.
/// </summary>
/// <param name="target">The <see cref="IEffectTarget{T}"/> this effect is attached to.</param>
/// <returns><c>true</c> if the effect can be attached; otherwise, <c>false</c>.</returns>
bool CanBeAppliedTo(T target);
/// <summary>
/// Hook which is called when the effect is attached to a device.
/// </summary>