v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -1,11 +1,9 @@
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
using Barotrauma.Extensions;
namespace Barotrauma
{
@@ -55,18 +53,19 @@ namespace Barotrauma
return;
}
if (AfflictionPrefab.Prefabs.ContainsKey(identifier))
if (AfflictionPrefab.Prefabs.TryGet(identifier, out var existingAffliction))
{
if (overriding)
{
DebugConsole.NewMessage(
$"Overriding an affliction or a buff with the identifier '{identifier}' using the file '{Path}'",
$"Overriding an affliction or a buff with the identifier '{identifier}' using the version in '{element.ContentPackage.Name}'",
Color.MediumPurple);
}
else
{
DebugConsole.ThrowError(
$"Duplicate affliction: '{identifier}' defined in {elementName} of '{Path}'",
$"Duplicate affliction: '{identifier}' defined in {element.ContentPackage.Name} is already defined in the previously loaded content package {existingAffliction.ContentPackage.Name}."+
$" You may need to adjust the mod load order to make sure {element.ContentPackage.Name} is loaded first.",
contentPackage: element?.ContentPackage);
return;
}
@@ -1,4 +1,4 @@
using Barotrauma.Extensions;
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -86,23 +86,27 @@ namespace Barotrauma
if (ragdollParams != null)
{
HashSet<string> texturePaths = new HashSet<string>
{
ContentPath.FromRaw(CharacterPrefab.Prefabs[speciesName].ContentPackage, ragdollParams.Texture).Value
};
HashSet<ContentPath> texturePaths = new HashSet<ContentPath>();
AddTexturePath(ragdollParams.Texture);
foreach (RagdollParams.LimbParams limb in ragdollParams.Limbs)
{
if (!string.IsNullOrEmpty(limb.normalSpriteParams?.Texture)) { texturePaths.Add(limb.normalSpriteParams.Texture); }
if (!string.IsNullOrEmpty(limb.deformSpriteParams?.Texture)) { texturePaths.Add(limb.deformSpriteParams.Texture); }
if (!string.IsNullOrEmpty(limb.damagedSpriteParams?.Texture)) { texturePaths.Add(limb.damagedSpriteParams.Texture); }
AddTexturePath(limb.normalSpriteParams?.Texture);
AddTexturePath(limb.deformSpriteParams?.Texture);
AddTexturePath(limb.damagedSpriteParams?.Texture);
foreach (var decorativeSprite in limb.decorativeSpriteParams)
{
if (!string.IsNullOrEmpty(decorativeSprite.Texture)) { texturePaths.Add(decorativeSprite.Texture); }
AddTexturePath(decorativeSprite.Texture);
}
}
foreach (string texturePath in texturePaths)
foreach (ContentPath texturePath in texturePaths)
{
addPreloadedSprite(new Sprite(texturePath, Vector2.Zero));
addPreloadedSprite(new Sprite(texturePath.Value, Vector2.Zero));
}
void AddTexturePath(string path)
{
if (string.IsNullOrEmpty(path)) { return; }
texturePaths.Add(ContentPath.FromRaw(characterPrefab.ContentPackage, ragdollParams.Texture));
}
}
#endif
@@ -0,0 +1,17 @@
using System.Xml.Linq;
namespace Barotrauma
{
internal sealed class DisembarkPerkFile : GenericPrefabFile<DisembarkPerkPrefab>
{
public DisembarkPerkFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
protected override bool MatchesSingular(Identifier identifier) => identifier == "disembarkperk";
protected override bool MatchesPlural(Identifier identifier) => identifier == "disembarkperks";
protected override PrefabCollection<DisembarkPerkPrefab> Prefabs => DisembarkPerkPrefab.Prefabs;
protected override DisembarkPerkPrefab CreatePrefab(ContentXElement element)
{
return new DisembarkPerkPrefab(element, this);
}
}
}
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using Barotrauma.Extensions;
using Barotrauma.Steam;
using System;
@@ -9,6 +9,8 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml;
using Barotrauma.IO;
namespace Barotrauma
{
@@ -34,9 +36,9 @@ namespace Barotrauma
public const string FileListFileName = "filelist.xml";
public const string DefaultModVersion = "1.0.0";
public readonly string Name;
public string Name { get; private set; }
public readonly ImmutableArray<string> AltNames;
public readonly string Path;
public string Path { get; private set; }
public string Dir => Barotrauma.IO.Path.GetDirectoryName(Path) ?? "";
public readonly Option<ContentPackageId> UgcId;
@@ -265,7 +267,7 @@ namespace Barotrauma
//The game should be able to work just fine with a completely arbitrary file load order.
//To make sure we don't mess this up, debug builds randomize it so it has a higher chance
//of breaking anything that's not implemented correctly.
.Randomize()
.Randomize(Rand.RandSync.Unsynced)
#endif
;
@@ -397,5 +399,51 @@ namespace Barotrauma
static string errorToStr(LoadError error)
=> error.ToString();
}
public bool TryRenameLocal(string newName)
{
if (!ContentPackageManager.LocalPackages.Contains(this)) { return false; }
if (newName.IsNullOrWhiteSpace())
{
DebugConsole.ThrowError($"New name is blank!");
return false;
}
string newDir = IO.Path.Combine(IO.Path.GetFullPath(LocalModsDir), File.SanitizeName(newName));
if (ContentPackageManager.LocalPackages.Any(lp => lp.NameMatches(newName)) || Directory.Exists(newDir))
{
DebugConsole.ThrowError($"A local package with the name or directory \"{newName}\" already exists!");
return false;
}
XDocument doc = XMLExtensions.TryLoadXml(Path);
doc.Root!.SetAttributeValue("name", newName);
using (IO.XmlWriter writer = IO.XmlWriter.Create(Path, new XmlWriterSettings { Indent = true }))
{
doc.WriteTo(writer);
writer.Flush();
}
Directory.Move(Dir, newDir);
return true;
}
public bool TryDeleteLocal() => ContentPackageManager.LocalPackages.Contains(this) && Directory.TryDelete(Dir);
public bool TryCreateLocalFromWorkshop()
{
if (!ContentPackageManager.WorkshopPackages.Contains(this)) { return false; }
string newDir = IO.Path.Combine(IO.Path.GetFullPath(LocalModsDir), File.SanitizeName(Name));
if (ContentPackageManager.LocalPackages.Any(lp => lp.NameMatches(Name)) || Directory.Exists(newDir))
{
DebugConsole.ThrowError($"A local package with the name or directory \"{Name}\" already exists!");
return false;
}
Directory.Copy(Dir, newDir);
return true;
}
}
}
@@ -93,6 +93,7 @@ namespace Barotrauma
public Rectangle GetAttributeRect(string key, in Rectangle def) => Element.GetAttributeRect(key, def);
public Version GetAttributeVersion(string key, Version def) => Element.GetAttributeVersion(key, def);
public T GetAttributeEnum<T>(string key, in T def) where T : struct, Enum => Element.GetAttributeEnum(key, def);
public T[] GetAttributeEnumArray<T>(string key, T[] def) where T : struct, Enum => Element.GetAttributeEnumArray(key, def);
public (T1, T2) GetAttributeTuple<T1, T2>(string key, in (T1, T2) def) => Element.GetAttributeTuple(key, def);
public (T1, T2)[] GetAttributeTupleArray<T1, T2>(string key, in (T1, T2)[] def) => Element.GetAttributeTupleArray(key, def);
public Range<int> GetAttributeRange(string key, in Range<int> def) => Element.GetAttributeRange(key, def);