mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 08:48:30 +00:00
Added method to check if an effect can be applied to a specific target
This commit is contained in:
parent
8b87270b69
commit
5c6dba769b
@ -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>
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user