Unstable 0.1500.5.0 (almost forgor edition 💀)
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<OutpostGenerationParams> Params { get; private set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
public virtual string Name { get; private set; }
|
||||
|
||||
public string Identifier { get; private set; }
|
||||
|
||||
@@ -67,6 +67,34 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, isSaveable: true), Editable]
|
||||
public bool LockUnusedDoors
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, isSaveable: true), Editable]
|
||||
public bool RemoveUnusedGaps
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(0.0f, isSaveable: true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
|
||||
public float MinWaterPercentage
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(0.0f, isSaveable: true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
|
||||
public float MaxWaterPercentage
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("", isSaveable: true), Editable]
|
||||
public string ReplaceInRadiation { get; set; }
|
||||
|
||||
@@ -81,12 +109,14 @@ namespace Barotrauma
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties { get; private set; }
|
||||
|
||||
private OutpostGenerationParams(XElement element, string filePath)
|
||||
protected OutpostGenerationParams(XElement element, string filePath)
|
||||
{
|
||||
Identifier = element.GetAttributeString("identifier", "");
|
||||
Name = element.GetAttributeString("name", Identifier);
|
||||
allowedLocationTypes = element.GetAttributeStringArray("allowedlocationtypes", Array.Empty<string>()).ToList();
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
if (element == null) { return; }
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace Barotrauma
|
||||
var subInfo = new SubmarineInfo(outpostModuleFile.Path);
|
||||
if (subInfo.OutpostModuleInfo != null)
|
||||
{
|
||||
if (subInfo.OutpostModuleInfo.ModuleFlags.Contains("ruin") != generationParams is RuinGeneration.RuinGenerationParams) { continue; }
|
||||
outpostModules.Add(subInfo);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +163,7 @@ namespace Barotrauma
|
||||
|
||||
selectedModules.Add(new PlacedModule(initialModule, null, OutpostModuleInfo.GapPosition.None));
|
||||
selectedModules.Last().FulfilledModuleTypes.Add(initialModuleFlag);
|
||||
AppendToModule(selectedModules.Last(), outpostModules.ToList(), pendingModuleFlags, selectedModules, locationType);
|
||||
AppendToModule(selectedModules.Last(), outpostModules.ToList(), pendingModuleFlags, selectedModules, locationType, allowExtendBelowInitialModule: generationParams is RuinGeneration.RuinGenerationParams);
|
||||
if (pendingModuleFlags.Any(flag => !flag.Equals("none", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
remainingTries--;
|
||||
@@ -233,17 +234,23 @@ namespace Barotrauma
|
||||
var selectedModule = selectedModules[i];
|
||||
sub.Info.GameVersion = selectedModule.Info.GameVersion;
|
||||
var moduleEntities = MapEntity.LoadAll(sub, selectedModule.Info.SubmarineElement, selectedModule.Info.FilePath, idOffset);
|
||||
idOffset = moduleEntities.Max(e => e.ID);
|
||||
|
||||
MapEntity.InitializeLoadedLinks(moduleEntities);
|
||||
|
||||
foreach (MapEntity entity in moduleEntities)
|
||||
foreach (MapEntity entity in moduleEntities.ToList())
|
||||
{
|
||||
entity.OriginalModuleIndex = i;
|
||||
if (!(entity is Item item)) { continue; }
|
||||
item.GetComponent<Door>()?.RefreshLinkedGap();
|
||||
var door = item.GetComponent<Door>();
|
||||
if (door != null)
|
||||
{
|
||||
door.RefreshLinkedGap();
|
||||
if (!moduleEntities.Contains(door.LinkedGap)) { moduleEntities.Add(door.LinkedGap); }
|
||||
}
|
||||
item.GetComponent<ConnectionPanel>()?.InitializeLinks();
|
||||
item.GetComponent<ItemContainer>()?.OnMapLoaded();
|
||||
}
|
||||
idOffset = moduleEntities.Max(e => e.ID);
|
||||
|
||||
var wallEntities = moduleEntities.Where(e => e is Structure).Cast<Structure>();
|
||||
var hullEntities = moduleEntities.Where(e => e is Hull).Cast<Hull>();
|
||||
@@ -345,11 +352,33 @@ namespace Barotrauma
|
||||
Submarine.RepositionEntities(module.Offset + sub.HiddenSubPosition, entities[module]);
|
||||
}
|
||||
Gap.UpdateHulls();
|
||||
allEntities.AddRange(GenerateHallways(sub, locationType, selectedModules, outpostModules, entities));
|
||||
allEntities.AddRange(GenerateHallways(sub, locationType, selectedModules, outpostModules, entities, generationParams is RuinGeneration.RuinGenerationParams));
|
||||
LinkOxygenGenerators(allEntities);
|
||||
LockUnusedDoors(selectedModules, entities);
|
||||
if (generationParams.LockUnusedDoors)
|
||||
{
|
||||
LockUnusedDoors(selectedModules, entities, generationParams.RemoveUnusedGaps);
|
||||
}
|
||||
AlignLadders(selectedModules, entities);
|
||||
PowerUpOutpost(entities.SelectMany(e => e.Value));
|
||||
if (generationParams.MaxWaterPercentage > 0.0f)
|
||||
{
|
||||
foreach (var entity in allEntities)
|
||||
{
|
||||
if (entity is Hull hull)
|
||||
{
|
||||
float diff = generationParams.MaxWaterPercentage - generationParams.MinWaterPercentage;
|
||||
if (diff < 0.01f)
|
||||
{
|
||||
// Overfill the hulls to get rid of air pockets in the vertical hallways. Airpockets make it impossible to swim up the hallways.
|
||||
hull.WaterVolume = hull.Volume * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
hull.WaterVolume = hull.Volume * Rand.Range(generationParams.MinWaterPercentage, generationParams.MaxWaterPercentage, Rand.RandSync.Server) * 0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allEntities;
|
||||
@@ -414,7 +443,8 @@ namespace Barotrauma
|
||||
List<string> pendingModuleFlags,
|
||||
List<PlacedModule> selectedModules,
|
||||
LocationType locationType,
|
||||
bool retry = true)
|
||||
bool retry = true,
|
||||
bool allowExtendBelowInitialModule = false)
|
||||
{
|
||||
if (pendingModuleFlags.Count == 0) { return true; }
|
||||
|
||||
@@ -422,8 +452,11 @@ namespace Barotrauma
|
||||
foreach (OutpostModuleInfo.GapPosition gapPosition in GapPositions().Randomize(Rand.RandSync.Server))
|
||||
{
|
||||
if (currentModule.UsedGapPositions.HasFlag(gapPosition)) { continue; }
|
||||
//don't continue downwards if it'd extend below the airlock
|
||||
if (gapPosition == OutpostModuleInfo.GapPosition.Bottom && currentModule.Offset.Y <= 1) { continue; }
|
||||
if (!allowExtendBelowInitialModule)
|
||||
{
|
||||
//don't continue downwards if it'd extend below the airlock
|
||||
if (gapPosition == OutpostModuleInfo.GapPosition.Bottom && currentModule.Offset.Y <= 1) { continue; }
|
||||
}
|
||||
if (currentModule.Info.OutpostModuleInfo.GapPositions.HasFlag(gapPosition))
|
||||
{
|
||||
var newModule = AppendModule(currentModule, GetOpposingGapPosition(gapPosition), availableModules, pendingModuleFlags, selectedModules, locationType);
|
||||
@@ -438,7 +471,7 @@ namespace Barotrauma
|
||||
//try to append to some other module first
|
||||
foreach (PlacedModule otherModule in selectedModules)
|
||||
{
|
||||
if (AppendToModule(otherModule, availableModules, pendingModuleFlags, selectedModules, locationType, retry: false))
|
||||
if (AppendToModule(otherModule, availableModules, pendingModuleFlags, selectedModules, locationType, retry: false, allowExtendBelowInitialModule: allowExtendBelowInitialModule))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -454,7 +487,7 @@ namespace Barotrauma
|
||||
//retry
|
||||
currentModule = AppendModule(currentModule.PreviousModule, currentModule.ThisGapPosition, availableModules, pendingModuleFlags, selectedModules, locationType);
|
||||
if (currentModule == null) { break; }
|
||||
if (AppendToModule(currentModule, availableModules, pendingModuleFlags, selectedModules, locationType, retry: false))
|
||||
if (AppendToModule(currentModule, availableModules, pendingModuleFlags, selectedModules, locationType, retry: false, allowExtendBelowInitialModule: allowExtendBelowInitialModule))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -676,6 +709,10 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
availableModules = modules.Where(m => m.OutpostModuleInfo.ModuleFlags.Contains(moduleFlag));
|
||||
if (moduleFlag != "hallwayhorizontal" && moduleFlag != "hallwayvertical")
|
||||
{
|
||||
availableModules = availableModules.Where(m => !m.OutpostModuleInfo.ModuleFlags.Contains("hallwayhorizontal") && !m.OutpostModuleInfo.ModuleFlags.Contains("hallwayvertical"));
|
||||
}
|
||||
}
|
||||
|
||||
if (availableModules.Count() == 0) { return null; }
|
||||
@@ -840,7 +877,7 @@ namespace Barotrauma
|
||||
return from.AllowAttachToModules.Any(s => to.ModuleFlags.Contains(s));
|
||||
}
|
||||
|
||||
private static List<MapEntity> GenerateHallways(Submarine sub, LocationType locationType, IEnumerable<PlacedModule> placedModules, IEnumerable<SubmarineInfo> availableModules, Dictionary<PlacedModule, List<MapEntity>> allEntities)
|
||||
private static List<MapEntity> GenerateHallways(Submarine sub, LocationType locationType, IEnumerable<PlacedModule> placedModules, IEnumerable<SubmarineInfo> availableModules, Dictionary<PlacedModule, List<MapEntity>> allEntities, bool isRuin)
|
||||
{
|
||||
//if a hallway is shorter than this, one of the doors at the ends of the hallway is removed
|
||||
const float MinTwoDoorHallwayLength = 32.0f;
|
||||
@@ -1193,14 +1230,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static void LockUnusedDoors(IEnumerable<PlacedModule> placedModules, Dictionary<PlacedModule, List<MapEntity>> entities)
|
||||
private static void LockUnusedDoors(IEnumerable<PlacedModule> placedModules, Dictionary<PlacedModule, List<MapEntity>> entities, bool removeUnusedGaps)
|
||||
{
|
||||
foreach (PlacedModule module in placedModules)
|
||||
{
|
||||
foreach (MapEntity me in entities[module])
|
||||
{
|
||||
var gap = me as Gap;
|
||||
if (gap == null) { continue; }
|
||||
if (!(me is Gap gap)) { continue; }
|
||||
var door = gap.ConnectedDoor;
|
||||
if (door != null && !door.UseBetweenOutpostModules) { continue; }
|
||||
if (placedModules.Any(m => m.PreviousGap == gap || m.ThisGap == gap))
|
||||
@@ -1247,11 +1283,11 @@ namespace Barotrauma
|
||||
if (connectionPanel != null) { connectionPanel.Locked = true; }
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (removeUnusedGaps)
|
||||
{
|
||||
gap.Remove();
|
||||
WayPoint.WayPointList.Where(wp => wp.ConnectedGap == gap).ForEachMod(wp => wp.Remove());
|
||||
}
|
||||
}
|
||||
}
|
||||
entities[module].RemoveAll(e => e.Removed);
|
||||
}
|
||||
|
||||
@@ -89,11 +89,13 @@ namespace Barotrauma
|
||||
if (newFlags.Contains("hallwayhorizontal"))
|
||||
{
|
||||
moduleFlags.Add("hallwayhorizontal");
|
||||
if (newFlags.Contains("ruin")) { moduleFlags.Add("ruin"); }
|
||||
return;
|
||||
}
|
||||
if (newFlags.Contains("hallwayvertical"))
|
||||
{
|
||||
moduleFlags.Add("hallwayvertical");
|
||||
if (newFlags.Contains("ruin")) { moduleFlags.Add("ruin"); }
|
||||
return;
|
||||
}
|
||||
if (!newFlags.Any())
|
||||
|
||||
Reference in New Issue
Block a user