Release 1.9.7.0 - Summer Update 2025

This commit is contained in:
Regalis11
2025-06-17 16:38:11 +03:00
parent 22227f13e5
commit ea5a2bc693
297 changed files with 7344 additions and 2421 deletions
@@ -132,7 +132,7 @@ namespace Barotrauma
SoundTriggers = new LevelTrigger[Prefab.Sounds.Count];
for (int i = 0; i < Prefab.Sounds.Count; i++)
{
Sounds[i] = RoundSound.Load(Prefab.Sounds[i].SoundElement, false);
Sounds[i] = RoundSound.Load(Prefab.Sounds[i].SoundElement);
SoundTriggers[i] = Prefab.Sounds[i].TriggerIndex > -1 ? Triggers[Prefab.Sounds[i].TriggerIndex] : null;
}
@@ -714,21 +714,21 @@ namespace Barotrauma.Lights
const float MaxOffset = 256.0f;
//the magic numbers here are just based on experimentation
float MinHorizontalScale = MathHelper.Lerp(3.5f, 1.5f, ObstructVisionAmount);
float MaxHorizontalScale = MinHorizontalScale * 1.25f;
float MaxHorizontalScale = 10.0f;
float VerticalScale = MathHelper.Lerp(4.0f, 1.25f, ObstructVisionAmount);
//Starting point and scale-based modifier that moves the point of origin closer to the edge of the texture if the player moves their mouse further away, or vice versa.
float relativeOriginStartPosition = 0.1f; //Increasing this value moves the origin further behind the character
float originStartPosition = visionCircle.Width * relativeOriginStartPosition * MinHorizontalScale;
float relativeOriginLookAtPosModifier = -0.055f; //Increase this value increases how much the vision changes by moving the mouse
float originLookAtPosModifier = visionCircle.Width * relativeOriginLookAtPosModifier;
Vector2 scale = new Vector2(
MathHelper.Clamp(losOffset.Length() / MaxOffset, MinHorizontalScale, MaxHorizontalScale), VerticalScale);
//Increasing this value moves the origin further behind the character (current value chosen by experimentation)
float relativeOriginStartPosition = 0.2f;
//Divide by scale to move the origin closer to the edge of the texture, meaning the visible area moves forwards.
//Just stretching the texture without touching the origin would otherwise mean the blurry edge of visibility moves further behind the character (allowing you to see behind you better when looking far away)
float originStartPosition = visionCircle.Width * relativeOriginStartPosition / scale.X;
spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cam.Transform * Matrix.CreateScale(new Vector3(GameSettings.CurrentConfig.Graphics.LightMapScale, GameSettings.CurrentConfig.Graphics.LightMapScale, 1.0f)));
spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation,
new Vector2(originStartPosition + (scale.X * originLookAtPosModifier), visionCircle.Height / 2), scale, SpriteEffects.None, 0.0f);
new Vector2(originStartPosition, visionCircle.Height / 2), scale, SpriteEffects.None, 0.0f);
spriteBatch.End();
}
else
@@ -788,8 +788,8 @@ namespace Barotrauma.Lights
if (!convexHull.Intersects(camView)) { continue; }
Vector2 relativeViewPos = pos;
if (convexHull.ParentEntity?.Submarine != null)
{
if (convexHull.ParentEntity?.Submarine != null)
{
relativeViewPos -= convexHull.ParentEntity.Submarine.DrawPosition;
}
@@ -83,6 +83,8 @@ namespace Barotrauma
#if DEBUG
private GUIComponent editor;
private bool editorEnabled;
private void CreateEditor()
{
editor = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), GUI.Canvas, Anchor.TopRight, minSize: new Point(400, 0)));
@@ -534,8 +536,15 @@ namespace Barotrauma
#if DEBUG
if (GameMain.DebugDraw)
{
if (editor == null) CreateEditor();
editor.AddToGUIUpdateList(order: 1);
if (editor == null) { CreateEditor(); }
if (editorEnabled)
{
editor.AddToGUIUpdateList(order: 1);
}
if (PlayerInput.KeyHit(Keys.T))
{
editorEnabled = !editorEnabled;
}
}
if (PlayerInput.KeyHit(Keys.Space))
@@ -822,7 +831,7 @@ namespace Barotrauma
drawRect.X = (int)pos.X - drawRect.Width / 2;
drawRect.Y = (int)pos.Y - drawRect.Width / 2;
if (drawRect.X > rect.Right - GUI.IntScale(100) && generationParams.MissionIcon != null && location.AvailableMissions.Any())
if (drawRect.X > rect.Right - GUI.IntScale(100) && generationParams.MissionIcon != null && location.AvailableAndVisibleMissions.Any(m => m.Prefab.ShowInMenus))
{
Vector2 offScreenMissionIconPos = new Vector2(rect.Right - GUI.IntScale(50), drawRect.Center.Y);
generationParams.MissionIcon.Draw(spriteBatch,
@@ -934,18 +943,19 @@ namespace Barotrauma
}
if (location != CurrentLocation && generationParams.MissionIcon != null)
{
if ((CurrentLocation == currentDisplayLocation && CurrentLocation.AvailableMissions.Any(m => m.Locations.Contains(location))) ||
location.AvailableMissions.Any(m => m.Locations[0] == m.Locations[1]))
var currentLocationVisibleMissions = CurrentLocation.AvailableAndVisibleMissions;
if ((CurrentLocation == currentDisplayLocation && currentLocationVisibleMissions.Any(m => m.Locations.Contains(location))) ||
location.AvailableAndVisibleMissions.Any(m => m.Locations[0] == m.Locations[1]))
{
Vector2 missionIconPos = pos + new Vector2(1.35f, 0.35f) * generationParams.LocationIconSize * 0.5f * zoom;
generationParams.MissionIcon.Draw(spriteBatch, missionIconPos, generationParams.IndicatorColor, scale: missionIconScale * zoom);
if (Vector2.Distance(PlayerInput.MousePosition, missionIconPos) < generationParams.MissionIcon.SourceRect.Width * zoom && IsPreferredTooltip(missionIconPos))
{
var availableMissions = CurrentLocation.AvailableMissions
var allVisibleMissions = currentLocationVisibleMissions
.Where(m => m.Locations.Contains(location))
.Concat(location.AvailableMissions.Where(m => m.Locations[0] == m.Locations[1]))
.Concat(location.AvailableAndVisibleMissions.Where(m => m.Locations[0] == m.Locations[1]))
.Distinct();
tooltip = (new Rectangle(missionIconPos.ToPoint(), new Point(30)), TextManager.Get("mission") + '\n'+ string.Join('\n', availableMissions.Select(m => "- " + m.Name)));
tooltip = (new Rectangle(missionIconPos.ToPoint(), new Point(30)), TextManager.Get("mission") + '\n'+ string.Join('\n', allVisibleMissions.Select(m => "- " + m.Name)));
}
}
}
@@ -992,6 +1002,12 @@ namespace Barotrauma
spriteBatch.End();
GameMain.Instance.GraphicsDevice.ScissorRectangle = prevScissorRect;
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
#if DEBUG
if (GameMain.DebugDraw)
{
GUI.DrawString(spriteBatch, new Vector2(mapContainer.Center.X, mapContainer.Rect.Y), "Press T to toggle editing map generation parameters.", Color.Magenta, font: GUIStyle.SmallFont);
}
#endif
}
public static void DrawNoise(SpriteBatch spriteBatch, Rectangle rect, float strength)
@@ -1159,15 +1159,6 @@ namespace Barotrauma
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) { }
private float RotationRad
=> MathHelper.ToRadians(
this switch
{
Structure s => s.Rotation,
Item it => it.Rotation,
_ => 0.0f
});
private Vector2 GetEditingHandlePos(int x, int y, Camera cam)
{
Vector2 handleDiff = new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f));
@@ -29,6 +29,15 @@ namespace Barotrauma
Volume = element.GetAttributeFloat("volume", 1.0f);
IgnoreMuffling = element.GetAttributeBool("dontmuffle", false);
MuteBackgroundMusic = element.GetAttributeBool("MuteBackgroundMusic", false);
if (!Stream && Sound.DurationSeconds > 60.0f)
{
DebugConsole.AddWarning(
$"Potential issue in content package: a large audio clip \"{System.IO.Path.GetFileName(Filename)}\" is set to be loaded into memory instead of streaming it from the disk. "+
"This can lead to excessive memory usage. Large clips should generally be streamed, while small and frequently played sounds should be loaded to memory to avoid the IO overhead of streaming. "+
"Consider adding stream=\"true\" to the sound's XML element.",
contentPackage: element.ContentPackage);
}
FrequencyMultiplierRange = new Vector2(1.0f);
string freqMultAttr = element.GetAttributeString("frequencymultiplier", element.GetAttributeString("frequency", "1.0"));
@@ -61,10 +70,11 @@ namespace Barotrauma
private static readonly List<RoundSound> roundSounds = new List<RoundSound>();
private static readonly Dictionary<string, RoundSound> roundSoundByPath = new Dictionary<string, RoundSound>();
public static RoundSound? Load(ContentXElement element, bool stream = false)
public static RoundSound? Load(ContentXElement element)
{
if (GameMain.SoundManager?.Disabled ?? true) { return null; }
bool stream = element.GetAttributeBool(nameof(Stream), false);
var filename = element.GetAttributeContentPath("file") ?? element.GetAttributeContentPath("sound");
if (filename is null)
{
@@ -320,8 +320,8 @@ namespace Barotrauma
{
RectangleF worldRect = Quad2D.FromSubmarineRectangle(WorldRect).Rotated(
FlippedX != FlippedY
? rotationRad
: -rotationRad).BoundingAxisAlignedRectangle;
? RotationRad
: -RotationRad).BoundingAxisAlignedRectangle;
Vector2 worldPos = WorldPosition;
Vector2 min = new Vector2(worldRect.X, worldRect.Y);
@@ -451,7 +451,7 @@ namespace Barotrauma
MathUtils.PositiveModulo(-textureOffset.X, Prefab.BackgroundSprite.SourceRect.Width * TextureScale.X * Scale),
MathUtils.PositiveModulo(-textureOffset.Y, Prefab.BackgroundSprite.SourceRect.Height * TextureScale.Y * Scale));
float rotationRad = GetRotationForSprite(this.rotationRad, Prefab.BackgroundSprite);
float rotationRad = GetRotationForSprite(RotationRad, Prefab.BackgroundSprite);
Prefab.BackgroundSprite.DrawTiled(
spriteBatch,
@@ -484,7 +484,7 @@ namespace Barotrauma
if (back == GetRealDepth() > 0.5f)
{
Vector2 advanceX = MathUtils.RotatedUnitXRadians(this.rotationRad).FlipY();
Vector2 advanceX = MathUtils.RotatedUnitXRadians(RotationRad).FlipY();
Vector2 advanceY = advanceX.YX().FlipX();
if (FlippedX != FlippedY)
{
@@ -492,7 +492,7 @@ namespace Barotrauma
advanceY = advanceY.FlipX();
}
float sectionSpriteRotationRad = GetRotationForSprite(this.rotationRad, Prefab.Sprite);
float sectionSpriteRotationRad = GetRotationForSprite(RotationRad, Prefab.Sprite);
for (int i = 0; i < Sections.Length; i++)
{
@@ -558,9 +558,11 @@ namespace Barotrauma
foreach (var decorativeSprite in Prefab.DecorativeSprites)
{
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor) + this.rotationRad;
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor) + RotationRad;
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier) * Scale;
Vector2 drawPos = DrawPosition + MathUtils.RotatePoint(offset, -this.rotationRad);
if (FlippedX && Prefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (FlippedY && Prefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
Vector2 drawPos = DrawPosition + MathUtils.RotatePoint(offset, -this.RotationRad);
decorativeSprite.Sprite.Draw(
spriteBatch: spriteBatch,
pos: drawPos.FlipY(),
@@ -230,30 +230,28 @@ namespace Barotrauma
}
}
public static void DrawGrid(SpriteBatch spriteBatch, int gridCells, Vector2 gridCenter, Vector2 roundedGridCenter, float alpha = 1.0f)
public static void DrawGrid(SpriteBatch spriteBatch, int gridCells, Vector2 gridCenter, Vector2 roundedGridCenter, float alpha = 1.0f, Color? color = null)
{
Vector2 topLeft = roundedGridCenter - Vector2.One * GridSize * gridCells / 2;
Vector2 bottomRight = roundedGridCenter + Vector2.One * GridSize * gridCells / 2;
for (int i = 0; i < gridCells; i++)
{
float distFromGridX = (MathUtils.RoundTowardsClosest(gridCenter.X, GridSize.X) - gridCenter.X) / GridSize.X;
float distFromGridY = (MathUtils.RoundTowardsClosest(gridCenter.Y, GridSize.Y) - gridCenter.Y) / GridSize.Y;
float middleIndex = (gridCells - 1) / 2.0f;
float normalizedPos = Math.Abs((i - middleIndex) / middleIndex);
float expandX = MathHelper.Lerp(30.0f, 0.0f, normalizedPos);
float expandY = expandX;
float normalizedDistX = Math.Abs(i + distFromGridX - gridCells / 2) / (gridCells / 2);
float normalizedDistY = Math.Abs(i - distFromGridY - gridCells / 2) / (gridCells / 2);
float expandX = MathHelper.Lerp(30.0f, 0.0f, normalizedDistY);
float expandY = MathHelper.Lerp(30.0f, 0.0f, normalizedDistX);
Color lineColor = color ?? Color.White;
GUI.DrawLine(spriteBatch,
new Vector2(topLeft.X - expandX, -bottomRight.Y + i * GridSize.Y),
new Vector2(bottomRight.X + expandX, -bottomRight.Y + i * GridSize.Y),
Color.White * (1.0f - normalizedDistY) * alpha, depth: 0.6f, width: 3);
lineColor * (1.0f - normalizedPos) * alpha, depth: 0.6f, width: 3);
GUI.DrawLine(spriteBatch,
new Vector2(topLeft.X + i * GridSize.X, -topLeft.Y + expandY),
new Vector2(topLeft.X + i * GridSize.X, -bottomRight.Y - expandY),
Color.White * (1.0f - normalizedDistX) * alpha, depth: 0.6f, width: 3);
lineColor * (1.0f - normalizedPos) * alpha, depth: 0.6f, width: 3);
}
}