Add basic point wrapper types (HP, MP, EP, O2P, SP)
This commit is contained in:
parent
a49f31df6e
commit
45e5465a08
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Seraphina.Core
|
||||||
|
{
|
||||||
|
public struct EnergyPoint : IEquatable<EnergyPoint>, IComparable<EnergyPoint>
|
||||||
|
{
|
||||||
|
public int Value { get; set; }
|
||||||
|
|
||||||
|
public EnergyPoint(int v) => Value = v;
|
||||||
|
|
||||||
|
public int CompareTo(EnergyPoint other) => Value.CompareTo(other.Value);
|
||||||
|
public override bool Equals(object? obj) => obj is EnergyPoint point && Equals(point);
|
||||||
|
public bool Equals(EnergyPoint other) => Value.Equals(other.Value);
|
||||||
|
public override int GetHashCode() => Value.GetHashCode();
|
||||||
|
public override string ToString() => Value.ToString();
|
||||||
|
|
||||||
|
#region Operator overloads
|
||||||
|
|
||||||
|
public static implicit operator EnergyPoint(int input) => new EnergyPoint(input);
|
||||||
|
public static bool operator ==(EnergyPoint left, EnergyPoint right) => left.Equals(right);
|
||||||
|
public static bool operator !=(EnergyPoint left, EnergyPoint right) => !(left == right);
|
||||||
|
public static bool operator >(EnergyPoint left, EnergyPoint right) => left.Value > right.Value;
|
||||||
|
public static bool operator <(EnergyPoint left, EnergyPoint right) => left.Value < right.Value;
|
||||||
|
public static bool operator >=(EnergyPoint left, EnergyPoint right) => !(left < right);
|
||||||
|
public static bool operator <=(EnergyPoint left, EnergyPoint right) => !(left > right);
|
||||||
|
|
||||||
|
public static EnergyPoint operator +(EnergyPoint left, EnergyPoint right) => new EnergyPoint(left.Value + right.Value);
|
||||||
|
public static EnergyPoint operator -(EnergyPoint left, EnergyPoint right) => new EnergyPoint(left.Value - right.Value);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Seraphina.Core
|
||||||
|
{
|
||||||
|
public struct HitPoint : IEquatable<HitPoint>, IComparable<HitPoint>
|
||||||
|
{
|
||||||
|
public int Value { get; set; }
|
||||||
|
|
||||||
|
public HitPoint(int v) => Value = v;
|
||||||
|
|
||||||
|
public int CompareTo(HitPoint other) => Value.CompareTo(other.Value);
|
||||||
|
public override bool Equals(object? obj) => obj is HitPoint hp && Equals(hp);
|
||||||
|
public bool Equals(HitPoint other) => Value.Equals(other.Value);
|
||||||
|
public override int GetHashCode() => Value.GetHashCode();
|
||||||
|
public override string ToString() => Value.ToString();
|
||||||
|
|
||||||
|
#region Operator overloads
|
||||||
|
|
||||||
|
public static implicit operator HitPoint(int input) => new HitPoint(input);
|
||||||
|
public static bool operator ==(HitPoint left, HitPoint right) => left.Equals(right);
|
||||||
|
public static bool operator !=(HitPoint left, HitPoint right) => !(left == right);
|
||||||
|
public static bool operator >(HitPoint left, HitPoint right) => left.Value > right.Value;
|
||||||
|
public static bool operator <(HitPoint left, HitPoint right) => left.Value < right.Value;
|
||||||
|
public static bool operator >=(HitPoint left, HitPoint right) => !(left < right);
|
||||||
|
public static bool operator <=(HitPoint left, HitPoint right) => !(left > right);
|
||||||
|
|
||||||
|
public static HitPoint operator +(HitPoint left, HitPoint right) => new HitPoint(left.Value + right.Value);
|
||||||
|
public static HitPoint operator -(HitPoint left, HitPoint right) => new HitPoint(left.Value - right.Value);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Seraphina.Core
|
||||||
|
{
|
||||||
|
public struct ManaPoint : IEquatable<ManaPoint>, IComparable<ManaPoint>
|
||||||
|
{
|
||||||
|
public int Value { get; set; }
|
||||||
|
|
||||||
|
public ManaPoint(int v) => Value = v;
|
||||||
|
|
||||||
|
public int CompareTo(ManaPoint other) => Value.CompareTo(other.Value);
|
||||||
|
public override bool Equals(object? obj) => obj is ManaPoint MP ? Equals(MP) : false;
|
||||||
|
public bool Equals(ManaPoint other) => Value.Equals(other.Value);
|
||||||
|
public override int GetHashCode() => Value.GetHashCode();
|
||||||
|
public override string ToString() => Value.ToString();
|
||||||
|
|
||||||
|
#region Operator overloads
|
||||||
|
|
||||||
|
public static implicit operator ManaPoint(int input) => new ManaPoint(input);
|
||||||
|
public static bool operator ==(ManaPoint left, ManaPoint right) => left.Equals(right);
|
||||||
|
public static bool operator !=(ManaPoint left, ManaPoint right) => !(left == right);
|
||||||
|
public static bool operator >(ManaPoint left, ManaPoint right) => left.Value > right.Value;
|
||||||
|
public static bool operator <(ManaPoint left, ManaPoint right) => left.Value < right.Value;
|
||||||
|
public static bool operator >=(ManaPoint left, ManaPoint right) => !(left < right);
|
||||||
|
public static bool operator <=(ManaPoint left, ManaPoint right) => !(left > right);
|
||||||
|
|
||||||
|
public static ManaPoint operator +(ManaPoint left, ManaPoint right) => new ManaPoint(left.Value + right.Value);
|
||||||
|
public static ManaPoint operator -(ManaPoint left, ManaPoint right) => new ManaPoint(left.Value - right.Value);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Seraphina.Core
|
||||||
|
{
|
||||||
|
public struct OxygenPoint : IEquatable<OxygenPoint>, IComparable<OxygenPoint>
|
||||||
|
{
|
||||||
|
public int Value { get; set; }
|
||||||
|
|
||||||
|
public OxygenPoint(int v) => Value = v;
|
||||||
|
|
||||||
|
public int CompareTo(OxygenPoint other) => Value.CompareTo(other.Value);
|
||||||
|
public override bool Equals(object? obj) => obj is OxygenPoint other && Equals(other);
|
||||||
|
public bool Equals(OxygenPoint other) => Value.Equals(other.Value);
|
||||||
|
public override int GetHashCode() => Value.GetHashCode();
|
||||||
|
public override string ToString() => Value.ToString();
|
||||||
|
|
||||||
|
#region Operator overloads
|
||||||
|
|
||||||
|
public static implicit operator OxygenPoint(int input) => new OxygenPoint(input);
|
||||||
|
public static bool operator ==(OxygenPoint left, OxygenPoint right) => left.Equals(right);
|
||||||
|
public static bool operator !=(OxygenPoint left, OxygenPoint right) => !(left == right);
|
||||||
|
public static bool operator >(OxygenPoint left, OxygenPoint right) => left.Value > right.Value;
|
||||||
|
public static bool operator <(OxygenPoint left, OxygenPoint right) => left.Value < right.Value;
|
||||||
|
public static bool operator >=(OxygenPoint left, OxygenPoint right) => !(left < right);
|
||||||
|
public static bool operator <=(OxygenPoint left, OxygenPoint right) => !(left > right);
|
||||||
|
|
||||||
|
public static OxygenPoint operator +(OxygenPoint left, OxygenPoint right) => new OxygenPoint(left.Value + right.Value);
|
||||||
|
public static OxygenPoint operator -(OxygenPoint left, OxygenPoint right) => new OxygenPoint(left.Value - right.Value);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Seraphina.Core
|
||||||
|
{
|
||||||
|
public struct SkillPoint : IEquatable<SkillPoint>, IComparable<SkillPoint>
|
||||||
|
{
|
||||||
|
public int Value { get; }
|
||||||
|
|
||||||
|
public SkillPoint(int v) => Value = v;
|
||||||
|
|
||||||
|
public int CompareTo(SkillPoint other) => Value.CompareTo(other.Value);
|
||||||
|
public override bool Equals(object? obj) => obj is SkillPoint other && Equals(other);
|
||||||
|
public bool Equals(SkillPoint other) => Value.Equals(other.Value);
|
||||||
|
public override int GetHashCode() => Value.GetHashCode();
|
||||||
|
public override string ToString() => Value.ToString();
|
||||||
|
|
||||||
|
#region Operator overloads
|
||||||
|
|
||||||
|
public static implicit operator SkillPoint(int input) => new SkillPoint(input);
|
||||||
|
public static explicit operator int(SkillPoint input) => input.Value;
|
||||||
|
public static bool operator ==(SkillPoint left, SkillPoint right) => left.Equals(right);
|
||||||
|
public static bool operator !=(SkillPoint left, SkillPoint right) => !(left == right);
|
||||||
|
public static bool operator >(SkillPoint left, SkillPoint right) => left.Value > right.Value;
|
||||||
|
public static bool operator <(SkillPoint left, SkillPoint right) => left.Value < right.Value;
|
||||||
|
public static bool operator >=(SkillPoint left, SkillPoint right) => !(left < right);
|
||||||
|
public static bool operator <=(SkillPoint left, SkillPoint right) => !(left > right);
|
||||||
|
|
||||||
|
public static SkillPoint operator +(SkillPoint left, SkillPoint right) => new SkillPoint(left.Value + right.Value);
|
||||||
|
public static SkillPoint operator -(SkillPoint left, SkillPoint right) => new SkillPoint(left.Value - right.Value);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue