Build 0.18.2.0
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Barotrauma
|
||||
IEnumerable<string> aliases = null)
|
||||
: base(identifier)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(constructor != null);
|
||||
this.constructor = constructor;
|
||||
this.Name = TextManager.Get($"EntityName.{identifier}");
|
||||
this.Description = TextManager.Get($"EntityDescription.{identifier}");
|
||||
@@ -35,40 +36,52 @@ namespace Barotrauma
|
||||
this.Aliases = (aliases ?? Enumerable.Empty<string>()).Concat(identifier.Value.ToEnumerable()).ToImmutableHashSet();
|
||||
}
|
||||
|
||||
public static CoreEntityPrefab HullPrefab { get; private set; }
|
||||
public static CoreEntityPrefab GapPrefab { get; private set; }
|
||||
public static CoreEntityPrefab WayPointPrefab { get; private set; }
|
||||
public static CoreEntityPrefab SpawnPointPrefab { get; private set; }
|
||||
|
||||
public static void InitCorePrefabs()
|
||||
{
|
||||
CoreEntityPrefab ep = new CoreEntityPrefab(
|
||||
HullPrefab = new CoreEntityPrefab(
|
||||
"hull".ToIdentifier(),
|
||||
typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
|
||||
typeof(Hull).GetConstructor(new Type[] { typeof(Rectangle) }),
|
||||
resizeHorizontal: true,
|
||||
resizeVertical: true,
|
||||
linkable: true,
|
||||
allowedLinks: new Identifier[] { "hull".ToIdentifier() });
|
||||
Prefabs.Add(ep, false);
|
||||
Prefabs.Add(HullPrefab, false);
|
||||
|
||||
ep = new CoreEntityPrefab(
|
||||
GapPrefab = new CoreEntityPrefab(
|
||||
"gap".ToIdentifier(),
|
||||
typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
|
||||
typeof(Gap).GetConstructor(new Type[] { typeof(Rectangle) }),
|
||||
resizeHorizontal: true,
|
||||
resizeVertical: true);
|
||||
Prefabs.Add(ep, false);
|
||||
Prefabs.Add(GapPrefab, false);
|
||||
|
||||
ep = new CoreEntityPrefab(
|
||||
WayPointPrefab = new CoreEntityPrefab(
|
||||
"waypoint".ToIdentifier(),
|
||||
typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }));
|
||||
Prefabs.Add(ep, false);
|
||||
Prefabs.Add(WayPointPrefab, false);
|
||||
|
||||
ep = new CoreEntityPrefab(
|
||||
SpawnPointPrefab = new CoreEntityPrefab(
|
||||
"spawnpoint".ToIdentifier(),
|
||||
typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }));
|
||||
Prefabs.Add(ep, false);
|
||||
Prefabs.Add(SpawnPointPrefab, false);
|
||||
}
|
||||
|
||||
protected override void CreateInstance(Rectangle rect)
|
||||
{
|
||||
if (constructor == null) return;
|
||||
object[] lobject = new object[] { this, rect };
|
||||
constructor.Invoke(lobject);
|
||||
if (this == WayPointPrefab || this == SpawnPointPrefab)
|
||||
{
|
||||
object[] lobject = new object[] { this, rect };
|
||||
constructor.Invoke(lobject);
|
||||
}
|
||||
else
|
||||
{
|
||||
object[] lobject = new object[] { rect };
|
||||
constructor.Invoke(lobject);
|
||||
}
|
||||
}
|
||||
|
||||
private bool disposed = false;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Gap(MapEntityPrefab prefab, Rectangle rectangle)
|
||||
public Gap(Rectangle rectangle)
|
||||
: this(rectangle, Submarine.MainSub)
|
||||
{
|
||||
#if CLIENT
|
||||
@@ -136,7 +136,7 @@ namespace Barotrauma
|
||||
{ }
|
||||
|
||||
public Gap(Rectangle rect, bool isHorizontal, Submarine submarine, ushort id = Entity.NullEntityID)
|
||||
: base(MapEntityPrefab.FindByIdentifier("gap".ToIdentifier()), submarine, id)
|
||||
: base(CoreEntityPrefab.GapPrefab, submarine, id)
|
||||
{
|
||||
this.rect = rect;
|
||||
flowForce = Vector2.Zero;
|
||||
|
||||
@@ -410,8 +410,8 @@ namespace Barotrauma
|
||||
|
||||
public BallastFloraBehavior BallastFlora { get; set; }
|
||||
|
||||
public Hull(MapEntityPrefab prefab, Rectangle rectangle)
|
||||
: this (prefab, rectangle, Submarine.MainSub)
|
||||
public Hull(Rectangle rectangle)
|
||||
: this (rectangle, Submarine.MainSub)
|
||||
{
|
||||
#if CLIENT
|
||||
if (SubEditorScreen.IsSubEditor())
|
||||
@@ -421,8 +421,8 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
|
||||
public Hull(MapEntityPrefab prefab, Rectangle rectangle, Submarine submarine, ushort id = Entity.NullEntityID)
|
||||
: base (prefab, submarine, id)
|
||||
public Hull(Rectangle rectangle, Submarine submarine, ushort id = Entity.NullEntityID)
|
||||
: base (CoreEntityPrefab.HullPrefab, submarine, id)
|
||||
{
|
||||
rect = rectangle;
|
||||
|
||||
@@ -500,7 +500,7 @@ namespace Barotrauma
|
||||
|
||||
public override MapEntity Clone()
|
||||
{
|
||||
var clone = new Hull(MapEntityPrefab.FindByIdentifier("hull".ToIdentifier()), rect, Submarine);
|
||||
var clone = new Hull(rect, Submarine);
|
||||
foreach (KeyValuePair<Identifier, SerializableProperty> property in SerializableProperties)
|
||||
{
|
||||
if (!property.Value.Attributes.OfType<Editable>().Any()) { continue; }
|
||||
@@ -1543,7 +1543,7 @@ namespace Barotrauma
|
||||
int.Parse(element.GetAttribute("height").Value));
|
||||
}
|
||||
|
||||
var hull = new Hull(MapEntityPrefab.Find(null, "hull"), rect, submarine, idRemap.GetOffsetId(element))
|
||||
var hull = new Hull(rect, submarine, idRemap.GetOffsetId(element))
|
||||
{
|
||||
WaterVolume = element.GetAttributeFloat("pressure", 0.0f)
|
||||
};
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -14,6 +11,8 @@ namespace Barotrauma
|
||||
public readonly LocalizedString Description;
|
||||
|
||||
public readonly bool IsEndBiome;
|
||||
public readonly float MinDifficulty;
|
||||
public readonly float MaxDifficulty;
|
||||
|
||||
public readonly ImmutableHashSet<int> AllowedZones;
|
||||
|
||||
@@ -30,8 +29,9 @@ namespace Barotrauma
|
||||
element.GetAttributeString("description", ""));
|
||||
|
||||
IsEndBiome = element.GetAttributeBool("endbiome", false);
|
||||
|
||||
AllowedZones = element.GetAttributeIntArray("AllowedZones", new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }).ToImmutableHashSet();
|
||||
MinDifficulty = element.GetAttributeFloat("MinDifficulty", 0);
|
||||
MaxDifficulty = element.GetAttributeFloat("MaxDifficulty", 100);
|
||||
}
|
||||
|
||||
public static Identifier ParseIdentifier(ContentXElement element)
|
||||
|
||||
@@ -96,24 +96,31 @@ namespace Barotrauma
|
||||
public readonly Sprite WallSprite;
|
||||
public readonly Sprite WallEdgeSprite;
|
||||
|
||||
public static CaveGenerationParams GetRandom(LevelGenerationParams generationParams, bool abyss, Rand.RandSync rand)
|
||||
public static CaveGenerationParams GetRandom(Level level, bool abyss, Rand.RandSync rand)
|
||||
{
|
||||
var caveParams = CaveParams.OrderBy(p => p.UintIdentifier).ToList();
|
||||
if (caveParams.All(p => p.GetCommonness(generationParams, abyss) <= 0.0f))
|
||||
if (caveParams.All(p => p.GetCommonness(level.LevelData, abyss) <= 0.0f))
|
||||
{
|
||||
return caveParams.First();
|
||||
}
|
||||
return ToolBox.SelectWeightedRandom(caveParams.ToList(), caveParams.Select(p => p.GetCommonness(generationParams, abyss)).ToList(), rand);
|
||||
return ToolBox.SelectWeightedRandom(caveParams.ToList(), caveParams.Select(p => p.GetCommonness(level.LevelData, abyss)).ToList(), rand);
|
||||
}
|
||||
|
||||
public float GetCommonness(LevelGenerationParams generationParams, bool abyss)
|
||||
public float GetCommonness(LevelData levelData, bool abyss)
|
||||
{
|
||||
if (generationParams != null &&
|
||||
generationParams.Identifier != Identifier.Empty &&
|
||||
OverrideCommonness.TryGetValue(abyss ? "abyss".ToIdentifier() : generationParams.Identifier, out float commonness))
|
||||
if (levelData.GenerationParams != null && levelData.GenerationParams.Identifier != Identifier.Empty &&
|
||||
OverrideCommonness.TryGetValue(abyss ? "abyss".ToIdentifier() : levelData.GenerationParams.Identifier, out float commonness))
|
||||
{
|
||||
return commonness;
|
||||
}
|
||||
if (levelData?.Biome != null)
|
||||
{
|
||||
if (OverrideCommonness.TryGetValue(levelData.Biome.Identifier, out float biomeCommonness))
|
||||
{
|
||||
return biomeCommonness;
|
||||
}
|
||||
}
|
||||
|
||||
return Commonness;
|
||||
}
|
||||
|
||||
|
||||
@@ -442,6 +442,11 @@ namespace Barotrauma
|
||||
Loaded?.Remove();
|
||||
Loaded = this;
|
||||
Generating = true;
|
||||
#if CLIENT
|
||||
Debug.Assert(GenerationParams.Identifier != "coldcavernstutorial" || GameMain.GameSession?.GameMode == null || GameMain.GameSession.GameMode is TutorialMode);
|
||||
#endif
|
||||
Debug.Assert(GenerationParams.AnyBiomeAllowed || GenerationParams.AllowedBiomeIdentifiers.Contains(LevelData.Biome.Identifier));
|
||||
DebugConsole.NewMessage("Level identifier: " + GenerationParams.Identifier);
|
||||
|
||||
ClearEqualityCheckValues();
|
||||
EntitiesBeforeGenerate = GetEntities().ToList();
|
||||
@@ -1711,7 +1716,8 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
//if the bottom of the abyss area is below crush depth, try to move it up to keep (most) of the abyss content above crush depth
|
||||
if (abyssEndY + CrushDepth < 0)
|
||||
//but only if start of the abyss is above crush depth (no point in doing this if all of it is below crush depth)
|
||||
if (abyssEndY + CrushDepth < 0 && abyssStartY > -CrushDepth)
|
||||
{
|
||||
abyssEndY += Math.Min(-(abyssEndY + (int)CrushDepth), abyssHeight / 2);
|
||||
}
|
||||
@@ -1820,7 +1826,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var caveParams = CaveGenerationParams.GetRandom(GenerationParams, abyss: true, rand: Rand.RandSync.ServerAndClient);
|
||||
var caveParams = CaveGenerationParams.GetRandom(this, abyss: true, rand: Rand.RandSync.ServerAndClient);
|
||||
|
||||
float caveScaleRelativeToIsland = 0.7f;
|
||||
GenerateCave(
|
||||
@@ -1889,7 +1895,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < GenerationParams.CaveCount; i++)
|
||||
{
|
||||
var caveParams = CaveGenerationParams.GetRandom(GenerationParams, abyss: false, rand: Rand.RandSync.ServerAndClient);
|
||||
var caveParams = CaveGenerationParams.GetRandom(this, abyss: false, rand: Rand.RandSync.ServerAndClient);
|
||||
Point caveSize = new Point(
|
||||
Rand.Range(caveParams.MinWidth, caveParams.MaxWidth, Rand.RandSync.ServerAndClient),
|
||||
Rand.Range(caveParams.MinHeight, caveParams.MaxHeight, Rand.RandSync.ServerAndClient));
|
||||
@@ -2479,6 +2485,7 @@ namespace Barotrauma
|
||||
foreach (ItemPrefab itemPrefab in ItemPrefab.Prefabs.OrderBy(p => p.UintIdentifier))
|
||||
{
|
||||
if (itemPrefab.LevelCommonness.TryGetValue(levelName, out float commonness) ||
|
||||
itemPrefab.LevelCommonness.TryGetValue(LevelData.Biome.Identifier, out commonness) ||
|
||||
itemPrefab.LevelCommonness.TryGetValue(Identifier.Empty, out commonness))
|
||||
{
|
||||
if (commonness <= 0.0f) { continue; }
|
||||
@@ -3237,7 +3244,8 @@ namespace Barotrauma
|
||||
if (index < 0 || index >= bottomPositions.Count - 1) { return new Vector2(xPosition, BottomPos); }
|
||||
|
||||
float t = (xPosition - bottomPositions[index].X) / (bottomPositions[index + 1].X - bottomPositions[index].X);
|
||||
Debug.Assert(t <= 1.0f);
|
||||
//t can go slightly outside the 0-1 due to rounding, safe to ignore
|
||||
Debug.Assert(t <= 1.001f && t >= -0.001f);
|
||||
t = MathHelper.Clamp(t, 0.0f, 1.0f);
|
||||
|
||||
float yPos = MathHelper.Lerp(bottomPositions[index].Y, bottomPositions[index + 1].Y, t);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma
|
||||
|
||||
public readonly string Seed;
|
||||
|
||||
public readonly float Difficulty;
|
||||
public float Difficulty;
|
||||
|
||||
public readonly Biome Biome;
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace Barotrauma
|
||||
(int)MathUtils.Round(generationParams.Height, Level.GridCellSize));
|
||||
}
|
||||
|
||||
public LevelData(XElement element)
|
||||
public LevelData(XElement element, float? forceDifficulty = null)
|
||||
{
|
||||
Seed = element.GetAttributeString("seed", "");
|
||||
Difficulty = element.GetAttributeFloat("difficulty", 0.0f);
|
||||
Difficulty = forceDifficulty ?? element.GetAttributeFloat("difficulty", 0.0f);
|
||||
Size = element.GetAttributePoint("size", new Point(1000));
|
||||
Enum.TryParse(element.GetAttributeString("type", "LocationConnection"), out Type);
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(50, IsPropertySaveable.Yes, description: "Maximum number of resource clusters in the abyss (the actual number is picked between min and max according to the level difficulty)"), Editable(MinValueInt = 0, MaxValueInt = 1000)]
|
||||
[Serialize(40, IsPropertySaveable.Yes, description: "Maximum number of resource clusters in the abyss (the actual number is picked between min and max according to the level difficulty)"), Editable(MinValueInt = 0, MaxValueInt = 1000)]
|
||||
public int AbyssResourceClustersMax
|
||||
{
|
||||
get;
|
||||
|
||||
+4
-4
@@ -170,7 +170,7 @@ namespace Barotrauma
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
//get a random prefab and find a place to spawn it
|
||||
LevelObjectPrefab prefab = GetRandomPrefab(level.GenerationParams, availablePrefabs);
|
||||
LevelObjectPrefab prefab = GetRandomPrefab(level, availablePrefabs);
|
||||
if (prefab == null) { continue; }
|
||||
if (!suitableSpawnPositions.ContainsKey(prefab))
|
||||
{
|
||||
@@ -595,12 +595,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private LevelObjectPrefab GetRandomPrefab(LevelGenerationParams generationParams, IList<LevelObjectPrefab> availablePrefabs)
|
||||
private LevelObjectPrefab GetRandomPrefab(Level level, IList<LevelObjectPrefab> availablePrefabs)
|
||||
{
|
||||
if (availablePrefabs.Sum(p => p.GetCommonness(generationParams)) <= 0.0f) { return null; }
|
||||
if (availablePrefabs.Sum(p => p.GetCommonness(level.LevelData)) <= 0.0f) { return null; }
|
||||
return ToolBox.SelectWeightedRandom(
|
||||
availablePrefabs,
|
||||
availablePrefabs.Select(p => p.GetCommonness(generationParams)).ToList(), Rand.RandSync.ServerAndClient);
|
||||
availablePrefabs.Select(p => p.GetCommonness(level.LevelData)).ToList(), Rand.RandSync.ServerAndClient);
|
||||
}
|
||||
|
||||
private LevelObjectPrefab GetRandomPrefab(CaveGenerationParams caveParams, IList<LevelObjectPrefab> availablePrefabs, bool requireCaveSpecificOverride)
|
||||
|
||||
+12
-6
@@ -426,15 +426,21 @@ namespace Barotrauma
|
||||
return requireCaveSpecificOverride ? 0.0f : Commonness;
|
||||
}
|
||||
|
||||
public float GetCommonness(LevelGenerationParams generationParams)
|
||||
{
|
||||
if (generationParams != null &&
|
||||
generationParams.Identifier != Identifier.Empty &&
|
||||
(OverrideCommonness.TryGetValue(generationParams.Identifier, out float commonness) ||
|
||||
(!generationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
public float GetCommonness(LevelData levelData)
|
||||
{
|
||||
if (levelData.GenerationParams != null && levelData.GenerationParams.Identifier != Identifier.Empty &&
|
||||
OverrideCommonness.TryGetValue(levelData.GenerationParams.Identifier, out float commonness) ||
|
||||
(!levelData.GenerationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(levelData.GenerationParams.OldIdentifier, out commonness)))
|
||||
{
|
||||
return commonness;
|
||||
}
|
||||
if (levelData?.Biome != null)
|
||||
{
|
||||
if (OverrideCommonness.TryGetValue(levelData.Biome.Identifier, out float biomeCommonness))
|
||||
{
|
||||
return biomeCommonness;
|
||||
}
|
||||
}
|
||||
return Commonness;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,12 +152,6 @@ namespace Barotrauma
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
#if CLIENT
|
||||
VertexBuffer?.Dispose();
|
||||
VertexBuffer = null;
|
||||
|
||||
@@ -485,6 +485,19 @@ namespace Barotrauma
|
||||
TurnsInRadiation = element.GetAttributeInt(nameof(TurnsInRadiation).ToLower(), 0);
|
||||
StepsSinceSpecialsUpdated = element.GetAttributeInt("stepssincespecialsupdated", 0);
|
||||
|
||||
Identifier biomeId = element.GetAttributeIdentifier("biome", Identifier.Empty);
|
||||
if (biomeId != Identifier.Empty)
|
||||
{
|
||||
if (Biome.Prefabs.TryGet(biomeId, out Biome biome))
|
||||
{
|
||||
Biome = biome;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Error while loading the campaign map: could not find a biome with the identifier \"{biomeId}\".");
|
||||
}
|
||||
}
|
||||
|
||||
if (!typeNotFound)
|
||||
{
|
||||
for (int i = 0; i < Type.CanChangeTo.Count; i++)
|
||||
@@ -773,22 +786,41 @@ namespace Barotrauma
|
||||
|
||||
static float GetConnectionWeight(Location location, LocationConnection c)
|
||||
{
|
||||
float weight = c.Passed ? 1.0f : 5.0f;
|
||||
Location destination = c.OtherLocation(location);
|
||||
if (destination != null)
|
||||
if (destination == null) { return 0; }
|
||||
float minWeight = 0.0001f;
|
||||
float lowWeight = 0.2f;
|
||||
float normalWeight = 1.0f;
|
||||
float maxWeight = 2.0f;
|
||||
float weight = c.Passed ? lowWeight : normalWeight;
|
||||
if (location.Biome.AllowedZones.Contains(1))
|
||||
{
|
||||
if (destination.MapPosition.X > location.MapPosition.X) { weight *= 2.0f; }
|
||||
int missionCount = location.availableMissions.Count(m => m.Locations.Contains(destination));
|
||||
if (missionCount > 0)
|
||||
{
|
||||
weight /= missionCount * 2;
|
||||
}
|
||||
if (destination.IsRadiated())
|
||||
// In the first biome, give a stronger preference for locations that are farther to the right)
|
||||
float diff = destination.MapPosition.X - location.MapPosition.X;
|
||||
if (diff < 0)
|
||||
{
|
||||
weight *= 0.001f;
|
||||
weight *= 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float maxRelevantDiff = 300;
|
||||
weight = MathHelper.Lerp(weight, maxWeight, MathUtils.InverseLerp(0, maxRelevantDiff, diff));
|
||||
}
|
||||
}
|
||||
return weight;
|
||||
else if (destination.MapPosition.X > location.MapPosition.X)
|
||||
{
|
||||
weight *= 2.0f;
|
||||
}
|
||||
int missionCount = location.availableMissions.Count(m => m.Locations.Contains(destination));
|
||||
if (missionCount > 0)
|
||||
{
|
||||
weight /= missionCount * 2;
|
||||
}
|
||||
if (destination.IsRadiated())
|
||||
{
|
||||
weight *= 0.001f;
|
||||
}
|
||||
return MathHelper.Clamp(weight, minWeight, maxWeight);
|
||||
}
|
||||
|
||||
return InstantiateMission(prefab, connection);
|
||||
@@ -1255,6 +1287,7 @@ namespace Barotrauma
|
||||
new XAttribute("originaltype", (Type ?? OriginalType).Identifier),
|
||||
new XAttribute("basename", BaseName),
|
||||
new XAttribute("name", Name),
|
||||
new XAttribute("biome", Biome?.Identifier.Value ?? string.Empty),
|
||||
new XAttribute("discovered", Discovered),
|
||||
new XAttribute("position", XMLExtensions.Vector2ToString(MapPosition)),
|
||||
new XAttribute("pricemultiplier", PriceMultiplier),
|
||||
|
||||
@@ -131,18 +131,27 @@ namespace Barotrauma
|
||||
};
|
||||
Locations[locationIndices.X].Connections.Add(connection);
|
||||
Locations[locationIndices.Y].Connections.Add(connection);
|
||||
connection.LevelData = new LevelData(subElement.Element("Level"));
|
||||
string biomeId = subElement.GetAttributeString("biome", "");
|
||||
connection.Biome =
|
||||
Biome.Prefabs.FirstOrDefault(b => b.Identifier == biomeId) ??
|
||||
Biome.Prefabs.FirstOrDefault(b => !b.OldIdentifier.IsEmpty && b.OldIdentifier == biomeId) ??
|
||||
Biome.Prefabs.First();
|
||||
connection.Difficulty = MathHelper.Clamp(connection.Difficulty, connection.Biome.MinDifficulty, connection.Biome.MaxDifficulty);
|
||||
connection.LevelData = new LevelData(subElement.Element("Level"), connection.Difficulty);
|
||||
Connections.Add(connection);
|
||||
connectionElements.Add(subElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//backwards compatibility: location biomes weren't saved (or used for anything) previously,
|
||||
//assign them if they haven't been assigned
|
||||
Random rand = new MTRandom(ToolBox.StringToInt(Seed));
|
||||
if (Locations.First().Biome == null)
|
||||
{
|
||||
AssignBiomes(rand);
|
||||
}
|
||||
|
||||
int startLocationindex = element.GetAttributeInt("startlocation", -1);
|
||||
if (startLocationindex > 0 && startLocationindex < Locations.Count)
|
||||
{
|
||||
@@ -237,6 +246,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
System.Diagnostics.Debug.Assert(StartLocation != null, "Start location not assigned after level generation.");
|
||||
if (StartLocation?.LevelData != null)
|
||||
{
|
||||
StartLocation.LevelData.Difficulty = 0;
|
||||
}
|
||||
|
||||
//ensure all paths from the starting location have 0 difficulty to make the 1st campaign round very easy
|
||||
foreach (var locationConnection in StartLocation.Connections)
|
||||
@@ -251,6 +264,11 @@ namespace Barotrauma
|
||||
CurrentLocation.Discover(true);
|
||||
CurrentLocation.CreateStores();
|
||||
|
||||
foreach (var location in Locations)
|
||||
{
|
||||
location.UnlockInitialMissions();
|
||||
}
|
||||
|
||||
InitProjectSpecific();
|
||||
}
|
||||
|
||||
@@ -505,22 +523,31 @@ namespace Barotrauma
|
||||
//remove orphans
|
||||
Locations.RemoveAll(l => !Connections.Any(c => c.Locations.Contains(l)));
|
||||
|
||||
AssignBiomes(new MTRandom(ToolBox.StringToInt(Seed)));
|
||||
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
//float difficulty = GetLevelDifficulty(connection.CenterPos.X / Width);
|
||||
//connection.Difficulty = MathHelper.Clamp(difficulty + Rand.Range(-10.0f, 0.0f, Rand.RandSync.ServerAndClient), 1.2f, 100.0f);
|
||||
float difficulty = connection.CenterPos.X / Width * 100;
|
||||
float random = difficulty > 10 ? 5 : 0;
|
||||
connection.Difficulty = MathHelper.Clamp(difficulty + Rand.Range(-random, random, Rand.RandSync.ServerAndClient), 1.0f, 100.0f);
|
||||
float minDifficulty = 0;
|
||||
float maxDifficulty = 100;
|
||||
var biome = connection.Biome;
|
||||
if (biome != null)
|
||||
{
|
||||
minDifficulty = connection.Biome.MinDifficulty;
|
||||
maxDifficulty = connection.Biome.MaxDifficulty;
|
||||
if (connection.Locked)
|
||||
{
|
||||
connection.Difficulty = maxDifficulty;
|
||||
}
|
||||
}
|
||||
connection.Difficulty = MathHelper.Clamp(difficulty, minDifficulty, maxDifficulty);
|
||||
}
|
||||
|
||||
AssignBiomes();
|
||||
CreateEndLocation();
|
||||
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.LevelData = new LevelData(location, MathHelper.Clamp(location.MapPosition.X / Width * 100, 0.0f, 100.0f));
|
||||
location.UnlockInitialMissions();
|
||||
}
|
||||
foreach (LocationConnection connection in Connections)
|
||||
{
|
||||
@@ -549,7 +576,7 @@ namespace Barotrauma
|
||||
return Biome.Prefabs.FirstOrDefault(b => b.AllowedZones.Contains(zoneIndex));
|
||||
}
|
||||
|
||||
private void AssignBiomes()
|
||||
private void AssignBiomes(Random rand)
|
||||
{
|
||||
var biomes = Biome.Prefabs;
|
||||
float zoneWidth = Width / generationParams.DifficultyZones;
|
||||
@@ -565,7 +592,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (location.MapPosition.X < zoneX)
|
||||
{
|
||||
location.Biome = allowedBiomes[Rand.Range(0, allowedBiomes.Count, Rand.RandSync.ServerAndClient)];
|
||||
location.Biome = allowedBiomes[rand.Next() % allowedBiomes.Count];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,23 +34,6 @@ namespace Barotrauma
|
||||
return prefab;
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!Disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Humans.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
Disposed = true;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
public override void Dispose() { }
|
||||
}
|
||||
}
|
||||
@@ -109,14 +109,21 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public enum Type
|
||||
{
|
||||
WayPoint,
|
||||
SpawnPoint
|
||||
}
|
||||
|
||||
public WayPoint(Rectangle newRect, Submarine submarine)
|
||||
: this (MapEntityPrefab.FindByIdentifier("waypoint".ToIdentifier()), newRect, submarine)
|
||||
: this (Type.WayPoint, newRect, submarine)
|
||||
{
|
||||
}
|
||||
|
||||
public WayPoint(MapEntityPrefab prefab, Rectangle newRect, Submarine submarine, ushort id = Entity.NullEntityID)
|
||||
: base (prefab, submarine, id)
|
||||
public WayPoint(Type type, Rectangle newRect, Submarine submarine, ushort id = Entity.NullEntityID)
|
||||
: base (type is Type.WayPoint
|
||||
? CoreEntityPrefab.WayPointPrefab
|
||||
: CoreEntityPrefab.SpawnPointPrefab, submarine, id)
|
||||
{
|
||||
rect = newRect;
|
||||
idCardTags = Array.Empty<string>();
|
||||
@@ -1010,7 +1017,7 @@ namespace Barotrauma
|
||||
|
||||
|
||||
Enum.TryParse(element.GetAttributeString("spawn", "Path"), out SpawnType spawnType);
|
||||
WayPoint w = new WayPoint(MapEntityPrefab.FindByIdentifier((spawnType == SpawnType.Path ? "waypoint" : "spawnpoint").ToIdentifier()), rect, submarine, idRemap.GetOffsetId(element))
|
||||
WayPoint w = new WayPoint(spawnType == SpawnType.Path ? Type.WayPoint : Type.SpawnPoint, rect, submarine, idRemap.GetOffsetId(element))
|
||||
{
|
||||
spawnType = spawnType
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user