unity-atoms/Packages/Core/Runtime/References/EquatableAtomReference.cs
Casey Hofland 21a588b6a4
Add OnCollisionHook and OnCollision2DHook (#221)
* Add OnCollisionHook and OnCollision2DHook

* refactor hooks

Naming shouldn't be trigger, get outa heeeeere!

* Implement ValueEquals + simplify already implemented ValueEquals

* Fix generator for Collisions + Add missing generated conditions + support OR:ed conditions in templates

Co-authored-by: Adam Ramberg <adam@mambojambostudios.com>
2020-12-30 00:01:42 +01:00

35 lines
1.5 KiB
C#

using System;
namespace UnityAtoms
{
/// <summary>
/// Atom Reference that where the value is implementing `IEquatable`.
/// </summary>
/// <typeparam name="T">The type of the variable.</typeparam>
/// <typeparam name="P">IPair of type `T`.</typeparam>
/// <typeparam name="C">Constant of type `T`.</typeparam>
/// <typeparam name="V">Variable of type `T`.</typeparam>
/// <typeparam name="E1">Event of type `T`.</typeparam>
/// <typeparam name="E2">Event of type `IPair&lt;T&gt;`.</typeparam>
/// <typeparam name="F">Function of type `T => T`.</typeparam>
/// <typeparam name="VI">Variable Instancer of type `T`.</typeparam>
public abstract class EquatableAtomReference<T, P, C, V, E1, E2, F, VI> : AtomReference<T, P, C, V, E1, E2, F, VI>, IEquatable<EquatableAtomReference<T, P, C, V, E1, E2, F, VI>>
where P : struct, IPair<T>
where C : AtomBaseVariable<T>
where V : AtomVariable<T, P, E1, E2, F>
where E1 : AtomEvent<T>
where E2 : AtomEvent<P>
where F : AtomFunction<T, T>
where VI : AtomVariableInstancer<V, P, T, E1, E2, F>
{
public EquatableAtomReference() : base() { }
public EquatableAtomReference(T value) : base(value) { }
public bool Equals(EquatableAtomReference<T, P, C, V, E1, E2, F, VI> other) { return base.Equals(other); }
protected override bool ValueEquals(T other)
{
return Value?.Equals(other) == true;
}
}
}