Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2025-06-17 15:45:16 -03:00
298 changed files with 7347 additions and 2422 deletions
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Barotrauma</RootNamespace>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -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>
@@ -69,6 +69,10 @@ public static class IEnumerableExtensionsCore
}
}
// Upgrading to .NET 8 seems to have caused a false positive on this line, disabled the warning for now.
// See https://github.com/dotnet/roslyn-analyzers/pull/7488
#pragma warning disable CA2021
public static IEnumerable<TSuccess> Successes<TSuccess, TFailure>(
this IEnumerable<Result<TSuccess, TFailure>> source)
where TSuccess : notnull
@@ -84,4 +88,7 @@ public static class IEnumerableExtensionsCore
=> source
.OfType<Failure<TSuccess, TFailure>>()
.Select(f => f.Error);
#pragma warning disable 2021
}
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Barotrauma</RootNamespace>
@@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>EosInterface.Implementation.Linux</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>EosInterfacePrivate</RootNamespace>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
@@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>EosInterface.Implementation.MacOS</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>EosInterfacePrivate</RootNamespace>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
@@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>EosInterface.Implementation.Win64</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>EosInterfacePrivate</RootNamespace>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
@@ -12,7 +12,7 @@ namespace EosInterfacePrivate;
static class LoginPrivate
{
private const string EosLoginSteamIdentity = "BarotraumaEosLogin";
private static Option<Steamworks.AuthTicketForWebApi> steamworksAuthTicket;
private static Option<Steamworks.AuthTicket> steamworksAuthTicket;
private static Option<ulong> eosConnectExpirationNotifyId, eosConnectStatusChangedNotifyId;
private static Option<ulong> egsAuthExpirationNotifyId;
@@ -65,7 +65,7 @@ static class LoginPrivate
{
if (!Steamworks.SteamClient.IsValid || !Steamworks.SteamClient.IsLoggedOn) { return Result.Failure(EosInterface.Login.LoginError.SteamNotLoggedIn); }
if (steamworksAuthTicket.TryUnwrap(out var oldTicket)) { oldTicket.Cancel(); }
var newTicketNullable = await Steamworks.SteamUser.GetAuthTicketForWebApi(EosLoginSteamIdentity);
var newTicketNullable = await Steamworks.SteamUser.GetAuthTicketForWebApiAsync(EosLoginSteamIdentity);
if (newTicketNullable is not { Data: not null } ticket)
{
return Result.Failure(EosInterface.Login.LoginError.FailedToGetSteamSessionTicket);
@@ -195,7 +195,7 @@ static class LoginPrivate
public static async Task<Result<OneOf<EosInterface.ProductUserId, EosInterface.EosConnectContinuanceToken, EosInterface.EgsAuthContinuanceToken>, EosInterface.Login.LoginError>> LoginEpicWithLinkedSteamAccount(EosInterface.Login.LoginEpicFlags flags)
{
if (steamworksAuthTicket.TryUnwrap(out var oldTicket)) { oldTicket.Cancel(); }
var newTicketNullable = await Steamworks.SteamUser.GetAuthTicketForWebApi(EosLoginSteamIdentity);
var newTicketNullable = await Steamworks.SteamUser.GetAuthTicketForWebApiAsync(EosLoginSteamIdentity);
if (newTicketNullable is not { Data: not null } ticket)
{
return Result.Failure(EosInterface.Login.LoginError.FailedToGetSteamSessionTicket);
@@ -8,7 +8,7 @@ public static class ResultExtension
{
public static T FailAndLogUnhandledError<T>(this Epic.OnlineServices.Result result, T unknown, [CallerMemberName] string caller = null)
{
DebugConsoleCore.NewMessage($"Result \"{result}\" was not handled by \"{caller}\".", Color.Red);
DebugConsoleCore.NewMessage($"Epic Online Services Result \"{result}\" was not handled by \"{caller}\".", Color.Red);
return unknown;
}
}