Skip to content

Commit

Permalink
Fixing compatibility with Unity 2019
Browse files Browse the repository at this point in the history
Removing some features that are only in C# 8.0+
  • Loading branch information
Cory Leach committed Sep 19, 2022
1 parent 43924b0 commit 3071cf0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Runtime/IReadOnlyStatSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Gameframe.StatSheet
{
public interface IReadOnlyStatSet<TKey> : IEnumerable<IStatValue<TKey>>
{
public float this[TKey statKey] { get; }
float this[TKey statKey] { get; }
}
}
2 changes: 1 addition & 1 deletion Runtime/IStatSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Gameframe.StatSheet
{
public interface IStatSet<TKey> : IEnumerable<IStatValue<TKey>>, IReadOnlyStatSet<TKey>
{
public new float this[TKey statKey] { get; set; }
new float this[TKey statKey] { get; set; }
}
}
39 changes: 20 additions & 19 deletions Runtime/IStatValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ public interface IStatValue<TKey>
TKey StatType { get; }
float Value { get; }

public static IStatValue<TKey> operator +(IStatValue<TKey> lhs, IStatValue<TKey> rhs)
{
Debug.Assert(lhs.StatType.Equals(rhs.StatType), "stat types do not match");
return new StatValue<TKey>
{
StatType = lhs.StatType,
Value = (lhs.Value + rhs.Value)
};
}

public static IStatValue<TKey> operator -(IStatValue<TKey> lhs, IStatValue<TKey> rhs)
{
Debug.Assert(lhs.StatType.Equals(rhs.StatType), "stat types do not match");
return new StatValue<TKey>
{
StatType = lhs.StatType,
Value = (lhs.Value - rhs.Value)
};
}
// Operators in interfaces not available until C# 8.0+
// public static IStatValue<TKey> operator +(IStatValue<TKey> lhs, IStatValue<TKey> rhs)
// {
// Debug.Assert(lhs.StatType.Equals(rhs.StatType), "stat types do not match");
// return new StatValue<TKey>
// {
// StatType = lhs.StatType,
// Value = (lhs.Value + rhs.Value)
// };
// }
//
// public static IStatValue<TKey> operator -(IStatValue<TKey> lhs, IStatValue<TKey> rhs)
// {
// Debug.Assert(lhs.StatType.Equals(rhs.StatType), "stat types do not match");
// return new StatValue<TKey>
// {
// StatType = lhs.StatType,
// Value = (lhs.Value - rhs.Value)
// };
// }
}
}

0 comments on commit 3071cf0

Please sign in to comment.