Build 0.18.7.0
This commit is contained in:
@@ -399,6 +399,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
new XAttribute("pos", XMLExtensions.Vector2ToString(branch.Position)),
|
||||
new XAttribute("ID", branch.ID),
|
||||
new XAttribute("isroot", branch.IsRoot),
|
||||
new XAttribute("isrootgrowth", branch.IsRootGrowth),
|
||||
new XAttribute("health", branch.Health.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("maxhealth", branch.MaxHealth.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("sides", (int)branch.Sides),
|
||||
@@ -457,9 +458,16 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
|
||||
foreach ((BallastFloraBranch branch, int parentBranchId) in branches)
|
||||
{
|
||||
if (parentBranchId > -1 && parentBranchId < Branches.Count)
|
||||
if (parentBranchId > -1)
|
||||
{
|
||||
branch.ParentBranch = Branches[parentBranchId];
|
||||
if (parentBranchId < Branches.Count)
|
||||
{
|
||||
branch.ParentBranch = Branches[parentBranchId];
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.AddWarning($"Error while loading ballast flora: parent branch ID {parentBranchId} out of range (total {Branches.Count} branches)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,6 +484,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
{
|
||||
Vector2 pos = branchElement.GetAttributeVector2("pos", Vector2.Zero);
|
||||
bool isRoot = branchElement.GetAttributeBool("isroot", false);
|
||||
bool isRootGrowth = branchElement.GetAttributeBool("isrootgrowth", false);
|
||||
int flowerConfig = getInt("flowerconfig");
|
||||
int leafconfig = getInt("leafconfig");
|
||||
int id = getInt("ID");
|
||||
@@ -493,7 +502,8 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
MaxHealth = maxhealth,
|
||||
Sides = (TileSide) sides,
|
||||
BlockedSides = (TileSide) blockedSides,
|
||||
IsRoot = isRoot
|
||||
IsRoot = isRoot,
|
||||
IsRootGrowth = isRootGrowth
|
||||
};
|
||||
branches.Add((newBranch, parentBranchId));
|
||||
|
||||
@@ -658,11 +668,14 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
toBeRemoved.Clear();
|
||||
foreach (BallastFloraBranch branch in Branches)
|
||||
{
|
||||
if (branch.ParentBranch == null || branch.ParentBranch.DisconnectedFromRoot || branch.ParentBranch.Health <= 0.0f)
|
||||
if (!branch.IsRoot)
|
||||
{
|
||||
float parentHealth = branch.ParentBranch == null ? 0.0f : branch.ParentBranch.Health / branch.ParentBranch.MaxHealth;
|
||||
float speed = MathHelper.Lerp(5.0f, 0.1f, parentHealth);
|
||||
DamageBranch(branch, speed * speed * deltaTime, AttackType.CutFromRoot);
|
||||
if (branch.ParentBranch == null || branch.ParentBranch.DisconnectedFromRoot || branch.ParentBranch.Health <= 0.0f)
|
||||
{
|
||||
float parentHealth = branch.ParentBranch == null ? 0.0f : branch.ParentBranch.Health / branch.ParentBranch.MaxHealth;
|
||||
float speed = MathHelper.Lerp(5.0f, 0.1f, parentHealth);
|
||||
DamageBranch(branch, speed * speed * deltaTime, AttackType.CutFromRoot);
|
||||
}
|
||||
}
|
||||
if (branch.Health <= 0.0f)
|
||||
{
|
||||
@@ -1197,7 +1210,10 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
}
|
||||
});
|
||||
#if SERVER
|
||||
CreateNetworkMessage(new InfectEventData(item, InfectEventData.InfectState.No, null));
|
||||
if (!item.Removed && Parent != null && !Parent.Removed)
|
||||
{
|
||||
CreateNetworkMessage(new InfectEventData(item, InfectEventData.InfectState.No, null));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -215,16 +215,19 @@ namespace Barotrauma
|
||||
saveElement = element
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(levelSeed) && levelData != null &&
|
||||
levelData.Seed != levelSeed && !linkedSub.purchasedLostShuttles)
|
||||
{
|
||||
linkedSub.loadSub = false;
|
||||
}
|
||||
else
|
||||
bool levelMatches = string.IsNullOrWhiteSpace(levelSeed) || levelData == null || levelData.Seed == levelSeed;
|
||||
|
||||
//don't load a sub that was left in this level if we have a submarine switch pending
|
||||
//to make sure it gets ignored during the submarine switch and item transfer (reloading and saving it during the switch makes it not considered "left behind")
|
||||
if ((levelMatches || linkedSub.purchasedLostShuttles) && GameMain.GameSession?.Campaign?.PendingSubmarineSwitch == null)
|
||||
{
|
||||
linkedSub.loadSub = true;
|
||||
linkedSub.rect.Location = MathUtils.ToPoint(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedSub.loadSub = false;
|
||||
}
|
||||
}
|
||||
|
||||
#warning TODO: revise
|
||||
@@ -279,14 +282,14 @@ namespace Barotrauma
|
||||
if (worldPos != Vector2.Zero)
|
||||
{
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.MirrorLevel)
|
||||
{
|
||||
{
|
||||
worldPos.X = GameMain.GameSession.LevelData.Size.X - worldPos.X;
|
||||
}
|
||||
sub.SetPosition(worldPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
sub.SetPosition(WorldPosition);
|
||||
sub.SetPosition(WorldPosition);
|
||||
}
|
||||
|
||||
DockingPort linkedPort = null;
|
||||
@@ -308,8 +311,17 @@ namespace Barotrauma
|
||||
{
|
||||
linkedPort = (FindEntityByID(originalLinkedToID) as Item)?.GetComponent<DockingPort>();
|
||||
}
|
||||
if (linkedPort == null) { return; }
|
||||
}
|
||||
|
||||
if (linkedPort == null)
|
||||
{
|
||||
if (worldPos == Vector2.Zero)
|
||||
{
|
||||
DebugConsole.ThrowError("Something went wrong when loading a linked submarine - the save didn't include either a world position or a linked port for the submarine.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
originalLinkedPort = linkedPort;
|
||||
|
||||
ushort originalMyId = childRemap.GetOffsetId(originalMyPortID);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -98,9 +96,29 @@ namespace Barotrauma
|
||||
[Serialize("", IsPropertySaveable.Yes), Editable]
|
||||
public string ReplaceInRadiation { get; set; }
|
||||
|
||||
private readonly Dictionary<Identifier, int> moduleCounts = new Dictionary<Identifier, int>();
|
||||
public class ModuleCount
|
||||
{
|
||||
public Identifier Identifier;
|
||||
public int Count;
|
||||
public int Order;
|
||||
|
||||
public IReadOnlyDictionary<Identifier, int> ModuleCounts
|
||||
public ModuleCount(ContentXElement element)
|
||||
{
|
||||
Identifier = element.GetAttributeIdentifier("flag", element.GetAttributeIdentifier("moduletype", ""));
|
||||
Count = element.GetAttributeInt("count", 0);
|
||||
Order = element.GetAttributeInt("order", 0);
|
||||
}
|
||||
|
||||
public ModuleCount(Identifier id, int count)
|
||||
{
|
||||
Identifier = id;
|
||||
Count = count;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<ModuleCount> moduleCounts = new List<ModuleCount>();
|
||||
|
||||
public IReadOnlyList<ModuleCount> ModuleCounts
|
||||
{
|
||||
get { return moduleCounts; }
|
||||
}
|
||||
@@ -171,8 +189,7 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "modulecount":
|
||||
Identifier moduleFlag = subElement.GetAttributeIdentifier("flag", subElement.GetAttributeIdentifier("moduletype", ""));
|
||||
moduleCounts[moduleFlag] = subElement.GetAttributeInt("count", 0);
|
||||
moduleCounts.Add(new ModuleCount(subElement));
|
||||
break;
|
||||
case "npcs":
|
||||
var newCollection = new NpcCollection();
|
||||
@@ -200,7 +217,7 @@ namespace Barotrauma
|
||||
public int GetModuleCount(Identifier moduleFlag)
|
||||
{
|
||||
if (moduleFlag == Identifier.Empty || moduleFlag == "none") { return int.MaxValue; }
|
||||
return moduleCounts.ContainsKey(moduleFlag) ? moduleCounts[moduleFlag] : 0;
|
||||
return moduleCounts.FirstOrDefault(m => m.Identifier == moduleFlag)?.Count ?? 0;
|
||||
}
|
||||
|
||||
public void SetModuleCount(Identifier moduleFlag, int count)
|
||||
@@ -208,11 +225,19 @@ namespace Barotrauma
|
||||
if (moduleFlag == Identifier.Empty || moduleFlag == "none") { return; }
|
||||
if (count <= 0)
|
||||
{
|
||||
moduleCounts.Remove(moduleFlag);
|
||||
moduleCounts.RemoveAll(m => m.Identifier == moduleFlag);
|
||||
}
|
||||
else
|
||||
{
|
||||
moduleCounts[moduleFlag] = count;
|
||||
var moduleCount = moduleCounts.FirstOrDefault(m => m.Identifier == moduleFlag);
|
||||
if (moduleCount == null)
|
||||
{
|
||||
moduleCounts.Add(new ModuleCount(moduleFlag, count));
|
||||
}
|
||||
else
|
||||
{
|
||||
moduleCount.Count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
{
|
||||
//if the module doesn't have the ruin flag or any other flag used in the generation params, don't use it in ruins
|
||||
if (!subInfo.OutpostModuleInfo.ModuleFlags.Contains("ruin".ToIdentifier()) &&
|
||||
!generationParams.ModuleCounts.Any(m => subInfo.OutpostModuleInfo.ModuleFlags.Contains(m.Key)))
|
||||
!generationParams.ModuleCounts.Any(m => subInfo.OutpostModuleInfo.ModuleFlags.Contains(m.Identifier)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -141,16 +141,11 @@ namespace Barotrauma
|
||||
|
||||
selectedModules.Clear();
|
||||
//select which module types the outpost should consist of
|
||||
List<Identifier> pendingModuleFlags;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
#warning TODO: cursed
|
||||
pendingModuleFlags = onlyEntrance
|
||||
? generationParams.ModuleCounts
|
||||
.Keys.OrderBy(k => ToolBox.IdentifierToUint32Hash(k, md5))
|
||||
.First().ToEnumerable().ToList()
|
||||
: SelectModules(outpostModules, generationParams);
|
||||
}
|
||||
List<Identifier> pendingModuleFlags =
|
||||
onlyEntrance ?
|
||||
generationParams.ModuleCounts.First().Identifier.ToEnumerable().ToList() :
|
||||
SelectModules(outpostModules, generationParams);
|
||||
|
||||
foreach (Identifier flag in pendingModuleFlags)
|
||||
{
|
||||
if (flag == "none") { continue; }
|
||||
@@ -437,31 +432,27 @@ namespace Barotrauma
|
||||
var pendingModuleFlags = new List<Identifier>();
|
||||
bool availableModulesFound = true;
|
||||
|
||||
Identifier initialModuleFlag = generationParams.ModuleCounts.FirstOrDefault().Key;
|
||||
Identifier initialModuleFlag = generationParams.ModuleCounts.FirstOrDefault().Identifier;
|
||||
pendingModuleFlags.Add(initialModuleFlag);
|
||||
while (pendingModuleFlags.Count < totalModuleCount && availableModulesFound)
|
||||
{
|
||||
availableModulesFound = false;
|
||||
foreach (var moduleFlag in generationParams.ModuleCounts)
|
||||
{
|
||||
if (pendingModuleFlags.Count(m => m == moduleFlag.Key) >= generationParams.GetModuleCount(moduleFlag.Key))
|
||||
if (pendingModuleFlags.Count(m => m == moduleFlag.Identifier) >= generationParams.GetModuleCount(moduleFlag.Identifier))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!modules.Any(m => m.OutpostModuleInfo.ModuleFlags.Contains(moduleFlag.Key)))
|
||||
if (!modules.Any(m => m.OutpostModuleInfo.ModuleFlags.Contains(moduleFlag.Identifier)))
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to add a module to the outpost (no modules with the flag \"{moduleFlag.Key}\" found).");
|
||||
DebugConsole.ThrowError($"Failed to add a module to the outpost (no modules with the flag \"{moduleFlag.Identifier}\" found).");
|
||||
continue;
|
||||
}
|
||||
availableModulesFound = true;
|
||||
pendingModuleFlags.Add(moduleFlag.Key);
|
||||
pendingModuleFlags.Add(moduleFlag.Identifier);
|
||||
}
|
||||
}
|
||||
using (MD5 md5 = MD5.Create())
|
||||
{
|
||||
pendingModuleFlags.Sort((i1, i2) => (int)ToolBox.StringToUInt32Hash(i1.Value.ToLowerInvariant(), md5) - (int)ToolBox.StringToUInt32Hash(i2.Value.ToLowerInvariant(), md5));
|
||||
}
|
||||
pendingModuleFlags.Shuffle(Rand.RandSync.ServerAndClient);
|
||||
pendingModuleFlags.OrderBy(f => generationParams.ModuleCounts.First(m => m.Identifier == f)).ThenBy(f => Rand.Value(Rand.RandSync.ServerAndClient));
|
||||
while (pendingModuleFlags.Count < totalModuleCount)
|
||||
{
|
||||
//don't place "none" modules at the end because
|
||||
@@ -610,7 +601,7 @@ namespace Barotrauma
|
||||
|
||||
Identifier flagToPlace = "none".ToIdentifier();
|
||||
SubmarineInfo nextModule = null;
|
||||
foreach (Identifier moduleFlag in pendingModuleFlags)
|
||||
foreach (Identifier moduleFlag in pendingModuleFlags.OrderByDescending(f => currentModule?.Info?.OutpostModuleInfo.AllowAttachToModules.Contains(f) ?? false))
|
||||
{
|
||||
flagToPlace = moduleFlag;
|
||||
nextModule = GetRandomModule(currentModule?.Info?.OutpostModuleInfo, availableModules, flagToPlace, gapPosition, locationType, allowDifferentLocationType);
|
||||
@@ -1048,6 +1039,17 @@ namespace Barotrauma
|
||||
module.ThisGapPosition == OutpostModuleInfo.GapPosition.Left ||
|
||||
module.ThisGapPosition == OutpostModuleInfo.GapPosition.Right;
|
||||
|
||||
if (!module.ThisGap.linkedTo.Any())
|
||||
{
|
||||
DebugConsole.ThrowError($"Error during outpost generation: {module.ThisGapPosition} gap in module \"{module.Info.Name}\" was not linked to any hulls.");
|
||||
continue;
|
||||
}
|
||||
if (!module.PreviousGap.linkedTo.Any())
|
||||
{
|
||||
DebugConsole.ThrowError($"Error during outpost generation: {GetOpposingGapPosition(module.ThisGapPosition)} gap in module \"{module.PreviousModule.Info.Name}\" was not linked to any hulls.");
|
||||
continue;
|
||||
}
|
||||
|
||||
MapEntity leftHull = module.ThisGap.Position.X < module.PreviousGap.Position.X ? module.ThisGap.linkedTo[0] : module.PreviousGap.linkedTo[0];
|
||||
MapEntity rightHull = module.ThisGap.Position.X > module.PreviousGap.Position.X ?
|
||||
module.ThisGap.linkedTo.Count == 1 ? module.ThisGap.linkedTo[0] : module.ThisGap.linkedTo[1] :
|
||||
|
||||
@@ -109,6 +109,8 @@ namespace Barotrauma
|
||||
public bool IsCampaignCompatible => IsPlayer && !HasTag(SubmarineTag.Shuttle) && !HasTag(SubmarineTag.HideInMenus) && SubmarineClass != SubmarineClass.Undefined;
|
||||
public bool IsCampaignCompatibleIgnoreClass => IsPlayer && !HasTag(SubmarineTag.Shuttle) && !HasTag(SubmarineTag.HideInMenus);
|
||||
|
||||
public bool AllowPreviewImage => Type == SubmarineType.Player;
|
||||
|
||||
public Md5Hash MD5Hash
|
||||
{
|
||||
get
|
||||
@@ -556,7 +558,7 @@ namespace Barotrauma
|
||||
XDocument doc = new XDocument(newElement);
|
||||
|
||||
doc.Root.Add(new XAttribute("name", Name));
|
||||
if (previewImage != null)
|
||||
if (previewImage != null && AllowPreviewImage)
|
||||
{
|
||||
doc.Root.Add(new XAttribute("previewimage", Convert.ToBase64String(previewImage.ToArray())));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user