Skip to content

Commit

Permalink
AuxiliaryObject is now an abstract class inheriting from an IAuxiliar…
Browse files Browse the repository at this point in the history
…yObject interface. Being abstract class in the first place was stupid decision
  • Loading branch information
David Morasz committed Nov 1, 2018
1 parent 3c02d23 commit c052e63
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Notui/Behaviors/MouseWheelScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class BehaviorState : AuxiliaryObject
public Vector2 DeltaPos = Vector2.Zero;

/// <inheritdoc cref="AuxiliaryObject"/>
public override AuxiliaryObject Copy()
public override IAuxiliaryObject Copy()
{
return new BehaviorState
{
Expand All @@ -36,7 +36,7 @@ public override AuxiliaryObject Copy()
}

/// <inheritdoc cref="AuxiliaryObject"/>
public override void UpdateFrom(AuxiliaryObject other)
public override void UpdateFrom(IAuxiliaryObject other)
{
if (!(other is BehaviorState bs)) return;
DeltaPos = bs.DeltaPos;
Expand Down
4 changes: 2 additions & 2 deletions Notui/Behaviors/MoveToTopOnTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public BehaviorState(NotuiElement element)
}

/// <inheritdoc cref="AuxiliaryObject"/>
public override AuxiliaryObject Copy()
public override IAuxiliaryObject Copy()
{
return new BehaviorState(_element);
}

/// <inheritdoc cref="AuxiliaryObject"/>
public override void UpdateFrom(AuxiliaryObject other) { }
public override void UpdateFrom(IAuxiliaryObject other) { }
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Notui/Behaviors/Sliding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class BehaviorState : AuxiliaryObject, IMainlooping
public Delay<Vector4> DelayedDeltas = new Delay<Vector4>(TimeSpan.FromSeconds(1.0));

/// <inheritdoc cref="AuxiliaryObject"/>
public override AuxiliaryObject Copy()
public override IAuxiliaryObject Copy()
{
return new BehaviorState
{
Expand All @@ -69,7 +69,7 @@ public override AuxiliaryObject Copy()
}

/// <inheritdoc cref="AuxiliaryObject"/>
public override void UpdateFrom(AuxiliaryObject other)
public override void UpdateFrom(IAuxiliaryObject other)
{
if (!(other is BehaviorState bs)) return;
DeltaPos = bs.DeltaPos;
Expand Down
4 changes: 2 additions & 2 deletions Notui/Behaviors/ValueSlider2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class ValueSlider2D : InteractionBehavior
public class BehaviorState : AuxiliaryObject
{
/// <inheritdoc cref="AuxiliaryObject"/>
public override AuxiliaryObject Copy()
public override IAuxiliaryObject Copy()
{
return new BehaviorState();
}

/// <inheritdoc cref="AuxiliaryObject"/>
public override void UpdateFrom(AuxiliaryObject other) { }
public override void UpdateFrom(IAuxiliaryObject other) { }
}

/// <summary>
Expand Down
15 changes: 10 additions & 5 deletions Notui/ElementCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@

namespace Notui
{
/// <summary>
/// Base interface for auxiliary attached element object
/// </summary>
public interface IAuxiliaryObject : ICloneable<IAuxiliaryObject>, IUpdateable<IAuxiliaryObject> { }

/// <summary>
/// Base class for auxiliary attached element object
/// </summary>
public abstract class AuxiliaryObject : ICloneable<AuxiliaryObject>, IUpdateable<AuxiliaryObject>
public abstract class AuxiliaryObject : IAuxiliaryObject
{
/// <inheritdoc cref="ICloneable{T}"/>
public abstract AuxiliaryObject Copy();
public abstract IAuxiliaryObject Copy();
/// <inheritdoc cref="IUpdateable{T}"/>
public abstract void UpdateFrom(AuxiliaryObject other);
public abstract void UpdateFrom(IAuxiliaryObject other);
/// <inheritdoc cref="ICloneable"/>
public object Clone() => Copy();
}
Expand All @@ -41,7 +46,7 @@ public class AttachedValues : ICloneable<AttachedValues>, IUpdateable<AttachedVa
/// <summary>
/// Whatever you want as long as it's clonable
/// </summary>
public readonly Dictionary<string, AuxiliaryObject> Auxiliary = new Dictionary<string, AuxiliaryObject>();
public readonly Dictionary<string, IAuxiliaryObject> Auxiliary = new Dictionary<string, IAuxiliaryObject>();

/// <inheritdoc cref="ICloneable{T}"/>
public AttachedValues Copy()
Expand Down Expand Up @@ -151,7 +156,7 @@ public interface IElementCommon
/// <summary>
/// Optional environment specific object for implementations so Value is not polluted
/// </summary>
AuxiliaryObject EnvironmentObject { get; set; }
IAuxiliaryObject EnvironmentObject { get; set; }

/// <summary>
/// Hittest is only successful if parent hittest is also successful
Expand Down
2 changes: 1 addition & 1 deletion Notui/ElementPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static ElementPrototype CreateFromInstance(NotuiElement element, bool new
/// <inheritdoc cref="IElementCommon"/>
public AttachedValues Value { get; set; }
/// <inheritdoc cref="IElementCommon"/>
public AuxiliaryObject EnvironmentObject { get; set; }
public IAuxiliaryObject EnvironmentObject { get; set; }
/// <inheritdoc cref="IElementCommon"/>
public bool OnlyHitIfParentIsHit { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions Notui/InteractionBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract class InteractionBehavior
/// <typeparam name="T">The type of the behavior state</typeparam>
/// <param name="element"></param>
/// <returns></returns>
public T GetState<T>(NotuiElement element) where T : AuxiliaryObject
public T GetState<T>(NotuiElement element) where T : IAuxiliaryObject
{
if (element.Value == null)
element.Value = new AttachedValues();
Expand All @@ -71,7 +71,7 @@ public T GetState<T>(NotuiElement element) where T : AuxiliaryObject
/// <param name="element"></param>
/// <param name="value">The state to be assigned</param>
/// <returns></returns>
public void SetState(NotuiElement element, AuxiliaryObject value)
public void SetState(NotuiElement element, IAuxiliaryObject value)
{
if (element.Value == null)
element.Value = new AttachedValues();
Expand Down
2 changes: 1 addition & 1 deletion Notui/NotuiElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public abstract class NotuiElement : IElementCommon, ICloneable<NotuiElement>, I
/// <inheritdoc />
public AttachedValues Value { get; set; }
/// <inheritdoc />
public AuxiliaryObject EnvironmentObject { get; set; }
public IAuxiliaryObject EnvironmentObject { get; set; }
/// <inheritdoc />
public bool OnlyHitIfParentIsHit { get; set; }

Expand Down

0 comments on commit c052e63

Please sign in to comment.