Release 1.9.7.0 - Summer Update 2025
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Extensions;
|
||||
|
||||
@@ -9,18 +10,9 @@ public static class EnumerableExtensionsCore
|
||||
public static ImmutableDictionary<TKey, TValue> ToImmutableDictionary<TKey, TValue>(this IEnumerable<(TKey, TValue)> enumerable)
|
||||
where TKey : notnull
|
||||
{
|
||||
return enumerable.ToDictionary().ToImmutableDictionary();
|
||||
}
|
||||
|
||||
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<(TKey, TValue)> enumerable)
|
||||
where TKey : notnull
|
||||
{
|
||||
var dictionary = new Dictionary<TKey, TValue>();
|
||||
foreach (var (k,v) in enumerable)
|
||||
{
|
||||
dictionary.Add(k, v);
|
||||
}
|
||||
return dictionary;
|
||||
return enumerable
|
||||
.ToDictionary(static pair => pair.Item1, static pair => pair.Item2)
|
||||
.ToImmutableDictionary();
|
||||
}
|
||||
|
||||
[return: NotNullIfNotNull("immutableDictionary")]
|
||||
|
||||
@@ -66,6 +66,15 @@ namespace Barotrauma.Extensions
|
||||
value.Top > bottom && rect.Top > otherBottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the y-coordinate of the rectangle so that up is greater and down is lower
|
||||
/// (i.e. so the Location of the rectangle is at the top-left corner in world coordinates).
|
||||
/// </summary>
|
||||
public static Rectangle ToWorldRect(this Rectangle rect)
|
||||
{
|
||||
return new Rectangle(rect.X, rect.Y - rect.Height, rect.Size.X, rect.Size.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Like the XNA method, but treats the y-coordinate so that up is greater and down is lower.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user