Build 0.21.6.0 (1.0 pre-patch)

This commit is contained in:
Regalis11
2023-01-31 18:08:26 +02:00
parent e1c04bc31d
commit cf9ecd35b3
231 changed files with 4479 additions and 2276 deletions
@@ -293,11 +293,11 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch,
new Vector2(drawRect.X, -drawRect.Y),
new Vector2(rect.Width, rect.Height),
Color.Blue * alpha, false, (ID % 255) * 0.000001f, (int)Math.Max(1.5f / Screen.Selected.Cam.Zoom, 1.0f));
Color.Blue * alpha, false, (ID % 255) * 0.000001f, (int)Math.Max(MathF.Ceiling(1.5f / Screen.Selected.Cam.Zoom), 1.0f));
GUI.DrawRectangle(spriteBatch,
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
GUIStyle.Red * ((100.0f - OxygenPercentage) / 400.0f) * alpha, true, 0, (int)Math.Max(1.5f / Screen.Selected.Cam.Zoom, 1.0f));
GUIStyle.Red * ((100.0f - OxygenPercentage) / 400.0f) * alpha, true, 0, (int)Math.Max(MathF.Ceiling(1.5f / Screen.Selected.Cam.Zoom), 1.0f));
if (GameMain.DebugDraw)
{
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
@@ -65,15 +64,9 @@ namespace Barotrauma
public Texture2D WaterTexture { get; }
public WaterRenderer(GraphicsDevice graphicsDevice, ContentManager content)
public WaterRenderer(GraphicsDevice graphicsDevice)
{
#if WINDOWS
WaterEffect = content.Load<Effect>("Effects/watershader");
#endif
#if LINUX || OSX
WaterEffect = content.Load<Effect>("Effects/watershader_opengl");
#endif
WaterEffect = EffectLoader.Load("Effects/watershader");
WaterTexture = TextureLoader.FromFile("Content/Effects/waterbump.png");
WaterEffect.Parameters["xWaterBumpMap"].SetValue(WaterTexture);
@@ -1,6 +1,5 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using System.Collections.Generic;
using System.Linq;
using System;
@@ -73,12 +72,14 @@ namespace Barotrauma.Lights
private int recalculationCount;
private float time;
public IEnumerable<LightSource> Lights
{
get { return lights; }
}
public LightManager(GraphicsDevice graphics, ContentManager content)
public LightManager(GraphicsDevice graphics)
{
lights = new List<LightSource>(100);
@@ -96,13 +97,8 @@ namespace Barotrauma.Lights
{
CreateRenderTargets(graphics);
#if WINDOWS
LosEffect = content.Load<Effect>("Effects/losshader");
SolidColorEffect = content.Load<Effect>("Effects/solidcolor");
#else
LosEffect = content.Load<Effect>("Effects/losshader_opengl");
SolidColorEffect = content.Load<Effect>("Effects/solidcolor_opengl");
#endif
LosEffect = EffectLoader.Load("Effects/losshader");
SolidColorEffect = EffectLoader.Load("Effects/solidcolor");
if (lightEffect == null)
{
@@ -171,10 +167,12 @@ namespace Barotrauma.Lights
public void Update(float deltaTime)
{
//wrap around if the timer gets very large, otherwise we'd start running into floating point accuracy issues
time = (time + deltaTime) % 100000.0f;
foreach (LightSource light in activeLights)
{
if (!light.Enabled) { continue; }
light.Update(deltaTime);
light.Update(time);
}
}
@@ -200,8 +200,6 @@ namespace Barotrauma.Lights
private static Texture2D lightTexture;
private float blinkTimer, flickerState, pulseState;
private VertexPositionColorTexture[] vertices;
private short[] indices;
@@ -486,12 +484,12 @@ namespace Barotrauma.Lights
if (addLight) { GameMain.LightManager.AddLight(this); }
}
public void Update(float deltaTime)
public void Update(float time)
{
float brightness = 1.0f;
if (lightSourceParams.BlinkFrequency > 0.0f)
{
blinkTimer = (blinkTimer + deltaTime * lightSourceParams.BlinkFrequency) % 1.0f;
float blinkTimer = (time * lightSourceParams.BlinkFrequency) % 1.0f;
if (blinkTimer > 0.5f)
{
CurrentBrightness = 0.0f;
@@ -500,14 +498,13 @@ namespace Barotrauma.Lights
}
if (lightSourceParams.PulseFrequency > 0.0f && lightSourceParams.PulseAmount > 0.0f)
{
pulseState = (pulseState + deltaTime * lightSourceParams.PulseFrequency) % 1.0f;
float pulseState = (time * lightSourceParams.PulseFrequency) % 1.0f;
//oscillate between 0-1
brightness *= 1.0f - (float)(Math.Sin(pulseState * MathHelper.TwoPi) + 1.0f) / 2.0f * lightSourceParams.PulseAmount;
}
if (lightSourceParams.Flicker > 0.0f)
if (lightSourceParams.Flicker > 0.0f && lightSourceParams.FlickerSpeed > 0.0f)
{
flickerState += deltaTime * lightSourceParams.FlickerSpeed;
flickerState %= 255;
float flickerState = (time * lightSourceParams.FlickerSpeed) % 255;
brightness *= 1.0f - PerlinNoise.GetPerlin(flickerState, flickerState * 0.5f) * lightSourceParams.Flicker;
}
CurrentBrightness = brightness;
@@ -68,7 +68,7 @@ namespace Barotrauma
private (Rectangle targetArea, RichString tip)? tooltip;
private (SubmarineInfo pendingSub, float realWorldCrushDepth) pendingSubInfo;
private SubmarineInfo.PendingSubInfo pendingSubInfo;
private RichString beaconStationActiveText, beaconStationInactiveText;
@@ -936,39 +936,8 @@ namespace Barotrauma
if (connection.LevelData.HasHuntingGrounds) { iconCount++; }
if (connection.Locked) { iconCount++; }
string tooltip = null;
float subCrushDepth = Level.DefaultRealWorldCrushDepth;
var currentOrPendingSub = SubmarineSelection.CurrentOrPendingSubmarine();
if (Submarine.MainSub != null && Submarine.MainSub.Info == currentOrPendingSub)
{
subCrushDepth = Submarine.MainSub.RealWorldCrushDepth;
}
else if (currentOrPendingSub != null)
{
if (pendingSubInfo.pendingSub != currentOrPendingSub)
{
// Store the real world crush depth for the pending sub so that we don't have to calculate it again every time
pendingSubInfo = (currentOrPendingSub, currentOrPendingSub.GetRealWorldCrushDepth());
}
subCrushDepth = pendingSubInfo.realWorldCrushDepth;
}
if (GameMain.GameSession?.Campaign?.UpgradeManager != null)
{
var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth".ToIdentifier());
if (hullUpgradePrefab != null)
{
int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
int currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First());
if (pendingLevel > currentLevel)
{
string updateValueStr = hullUpgradePrefab.SourceElement?.GetChildElement("Structure")?.GetAttributeString("crushdepth", null);
if (!string.IsNullOrEmpty(updateValueStr))
{
subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel - currentLevel, updateValueStr);
}
}
}
}
float subCrushDepth = SubmarineInfo.GetSubCrushDepth(SubmarineSelection.CurrentOrPendingSubmarine(), ref pendingSubInfo);
string crushDepthWarningIconStyle = null;
if (connection.LevelData.InitialDepth * Physics.DisplayToRealWorldRatio > subCrushDepth)
{
@@ -1125,6 +1094,14 @@ namespace Barotrauma
}
}
/// <summary>
/// Resets <see cref="pendingSubInfo"/> and forces crush depth to be calculated again for icon displaying purposes
/// </summary>
public void ResetPendingSub()
{
pendingSubInfo = new SubmarineInfo.PendingSubInfo();
}
partial void RemoveProjSpecific()
{
noiseOverlay?.Remove();
@@ -515,11 +515,11 @@ namespace Barotrauma
Item targetContainer = null;
bool isShiftDown = PlayerInput.IsShiftDown();
if (!isShiftDown) return null;
if (!isShiftDown) { return null; }
foreach (MapEntity e in mapEntityList)
{
if (!e.SelectableInEditor ||!(e is Item potentialContainer)) { continue; }
if (!e.SelectableInEditor || e is not Item potentialContainer) { continue; }
if (e.IsMouseOn(position))
{
@@ -83,7 +83,10 @@ namespace Barotrauma
{
string errorMsg = "Failed to load sound file \"" + filename + "\" (file not found).";
DebugConsole.ThrowError(errorMsg, e);
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
if (!ContentPackageManager.ModsEnabled)
{
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
}
return null;
}
catch (System.IO.InvalidDataException e)
@@ -89,7 +89,11 @@ namespace Barotrauma
CreateSpecsWindow(descriptionBox, font, includeDescription: true);
}
public void CreateSpecsWindow(GUIListBox parent, GUIFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
public void CreateSpecsWindow(GUIListBox parent, GUIFont font,
bool includeTitle = true,
bool includeClass = true,
bool includeDescription = false,
bool includeCrushDepth = false)
{
float leftPanelWidth = 0.6f;
float rightPanelWidth = 0.4f / leftPanelWidth;
@@ -155,6 +159,22 @@ namespace Barotrauma
{ CanBeFocused = false };
cargoCapacityText.RectTransform.MinSize = new Point(0, cargoCapacityText.Children.First().Rect.Height);
if (includeCrushDepth)
{
var crushDepthText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
TextManager.Get("CrushDepth"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
{
CanBeFocused = false
};
new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crushDepthText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
TextManager.GetWithVariable("meterformat", "[meters]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetSubCrushDepth())),
textAlignment: Alignment.TopLeft, font: font, wrap: true)
{
CanBeFocused = false
};
crushDepthText.RectTransform.MinSize = new Point(0, crushDepthText.Children.First().Rect.Height);
}
if (RecommendedCrewSizeMax > 0)
{
var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
@@ -227,5 +247,57 @@ namespace Barotrauma
GUITextBlock.AutoScaleAndNormalize(parent.Content.GetAllChildren<GUITextBlock>().Where(c => c != submarineNameText && c != descBlock));
parent.ForceLayoutRecalculation();
}
public readonly record struct PendingSubInfo(SubmarineInfo PendingSub = null, bool StructuresDefineRealWorldCrushDepth = false, float RealWorldCrushDepth = Level.DefaultRealWorldCrushDepth);
private float GetSubCrushDepth()
{
var pendingSubInfo = new PendingSubInfo();
return GetSubCrushDepth(this, ref pendingSubInfo);
}
public static float GetSubCrushDepth(SubmarineInfo subInfo, ref PendingSubInfo pendingSubInfo)
{
float subCrushDepth = Level.DefaultRealWorldCrushDepth;
if (Submarine.MainSub != null && Submarine.MainSub.Info == subInfo)
{
subCrushDepth = Submarine.MainSub.RealWorldCrushDepth;
}
else if (subInfo != null)
{
if (pendingSubInfo.PendingSub != subInfo)
{
// Store the real world crush depth for the pending sub so that we don't have to calculate it again every time
pendingSubInfo = new PendingSubInfo(subInfo, subInfo.IsCrushDepthDefinedInStructures(out float realWorldCrushDepth), realWorldCrushDepth);
}
subCrushDepth = pendingSubInfo.RealWorldCrushDepth;
}
if (GameMain.GameSession?.Campaign?.UpgradeManager != null && UpgradePrefab.Find("increasewallhealth".ToIdentifier()) is UpgradePrefab hullUpgradePrefab)
{
int pendingLevel = GameMain.GameSession.Campaign.UpgradeManager.GetUpgradeLevel(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First(), info: subInfo);
// If there is a sub switch pending, unless its structures have crush depth defined in their elements,
// calculate the value based on the default crush depth and pending upgrade level
int currentLevel = 0;
if (pendingSubInfo.PendingSub is null || pendingSubInfo.StructuresDefineRealWorldCrushDepth)
{
currentLevel = GameMain.GameSession.Campaign.UpgradeManager.GetRealUpgradeLevelForSub(hullUpgradePrefab, hullUpgradePrefab.UpgradeCategories.First(), subInfo);
}
if (pendingLevel > currentLevel)
{
string updateValueStr = hullUpgradePrefab.SourceElement?.GetChildElement("Structure")?.GetAttributeString("crushdepth", null);
if (!string.IsNullOrEmpty(updateValueStr))
{
if (currentLevel > 0)
{
// If the current level is greater than 0, reset the crush depth value back to the base value before calculating the upgrade
int upgradePercentage = UpgradePrefab.ParsePercentage(updateValueStr, Identifier.Empty, suppressWarnings: true);
subCrushDepth /= (1f + (upgradePercentage / 100f * currentLevel));
}
subCrushDepth = PropertyReference.CalculateUpgrade(subCrushDepth, pendingLevel, updateValueStr);
}
}
}
return subCrushDepth;
}
}
}
@@ -4,26 +4,29 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Barotrauma.Items.Components;
namespace Barotrauma
{
class SubmarinePreview : IDisposable
sealed class SubmarinePreview : IDisposable
{
private SpriteRecorder spriteRecorder;
private readonly SubmarineInfo submarineInfo;
private SpriteRecorder spriteRecorder;
private Camera camera;
private Task loadTask;
private (Vector2 Min, Vector2 Max) bounds;
private volatile bool isDisposed;
private GUIFrame previewFrame;
private class HullCollection
private sealed class HullCollection
{
public readonly List<Rectangle> Rects;
public readonly LocalizedString Name;
@@ -42,7 +45,7 @@ namespace Barotrauma
}
}
private struct Door
private readonly struct Door
{
public readonly Rectangle Rect;
@@ -150,7 +153,9 @@ namespace Barotrauma
ScrollBarVisible = false,
Spacing = GUI.IntScale(5)
};
subInfo.CreateSpecsWindow(specsContainer, GUIStyle.Font, includeTitle: false, includeDescription: true);
subInfo.CreateSpecsWindow(specsContainer, GUIStyle.Font,
includeTitle: false,
includeDescription: true);
int width = specsContainer.Rect.Width;
void recalculateSpecsContainerHeight()
{
@@ -186,7 +191,22 @@ namespace Barotrauma
});
recalculateSpecsContainerHeight();
GeneratePreviewMeshes();
TaskPool.Add(nameof(GeneratePreviewMeshes), GeneratePreviewMeshes(), _ =>
{
if (isDisposed) { return; }
// Reset the camera's position on the main thread,
// because the Camera class is not thread-safe and
// it's possible for its state to not get updated
// properly if done within a task
camera.Position = (bounds.Min + bounds.Max) * (0.5f, -0.5f);
Vector2 span2d = bounds.Max - bounds.Min;
Vector2 scaledSpan2d = span2d / camera.Resolution.ToVector2();
float scaledSpan = Math.Max(scaledSpan2d.X, scaledSpan2d.Y);
camera.MinZoom = Math.Min(0.1f, 0.4f / scaledSpan);
camera.Zoom = 0.7f / scaledSpan;
camera.StopMovement();
camera.UpdateTransform(interpolate: false, updateListener: false);
});
}
public static void AddToGUIUpdateList()
@@ -207,6 +227,7 @@ namespace Barotrauma
spriteRecorder.Begin(SpriteSortMode.BackToFront);
HashSet<int> toIgnore = new HashSet<int>();
HashSet<int> wires = new HashSet<int>();
foreach (var subElement in submarineInfo.SubmarineElement.Elements())
{
@@ -221,7 +242,7 @@ namespace Barotrauma
ExtractItemContainerIds(component, toIgnore);
break;
case "connectionpanel":
ExtractConnectionPanelLinks(component, toIgnore);
ExtractConnectionPanelLinks(component, wires);
break;
}
}
@@ -231,20 +252,25 @@ namespace Barotrauma
await Task.Yield();
}
var wireNodes = new List<XElement>();
foreach (var subElement in submarineInfo.SubmarineElement.Elements())
{
if (subElement.GetAttributeBool("hiddeningame", false)) { continue; }
switch (subElement.Name.LocalName.ToLowerInvariant())
{
case "structure":
case "item":
if (!toIgnore.Contains(subElement.GetAttributeInt("ID", 0)))
var id = subElement.GetAttributeInt("ID", 0);
if (wires.Contains(id))
{
wireNodes.Add(subElement);
}
else if (!toIgnore.Contains(id))
{
BakeMapEntity(subElement);
}
break;
case "structure":
BakeMapEntity(subElement);
break;
case "hull":
Identifier identifier = subElement.GetAttributeIdentifier("roomname", "");
if (!identifier.IsEmpty)
@@ -261,15 +287,14 @@ namespace Barotrauma
if (isDisposed) { return; }
await Task.Yield();
}
spriteRecorder.End();
camera.Position = (spriteRecorder.Min + spriteRecorder.Max) * 0.5f;
float scaledSpan = (spriteRecorder.Max - spriteRecorder.Min).X / camera.Resolution.X;
camera.Zoom = 0.8f / scaledSpan;
camera.StopMovement();
bounds = (spriteRecorder.Min, spriteRecorder.Max);
wireNodes.ForEach(BakeWireNodes);
spriteRecorder.End();
}
private void ExtractItemContainerIds(XElement component, HashSet<int> ids)
private static void ExtractItemContainerIds(XElement component, HashSet<int> ids)
{
string containedString = component.GetAttributeString("contained", "");
string[] itemIdStrings = containedString.Split(',');
@@ -283,7 +308,7 @@ namespace Barotrauma
}
}
private void ExtractConnectionPanelLinks(XElement component, HashSet<int> ids)
private static void ExtractConnectionPanelLinks(XElement component, HashSet<int> ids)
{
var pins = component.Elements("input").Concat(component.Elements("output"));
foreach (var pin in pins)
@@ -297,6 +322,39 @@ namespace Barotrauma
}
}
private void BakeWireNodes(XElement element)
{
var prefabIdentifier = element.GetAttributeIdentifier("identifier", "");
if (prefabIdentifier.IsEmpty) { return; }
if (!ItemPrefab.Prefabs.TryGet(prefabIdentifier, out var prefab)) { return; }
var prefabWireComponentElement = prefab.ConfigElement.GetChildElement("wire");
if (prefabWireComponentElement is null) { return; }
var wireComponent = element.GetChildElement("wire");
if (wireComponent is null) { return; }
var color = element.GetAttributeColor("spritecolor") ?? Color.White;
var nodes = Wire.ExtractNodes(wireComponent).ToImmutableArray();
var wireSprite = Wire.ExtractWireSprite(prefab.ConfigElement);
var useSpriteDepth = element.GetAttributeBool("usespritedepth", false);
var depth =
useSpriteDepth
? element.GetAttributeFloat("spritedepth", 1.0f)
: wireSprite.Depth;
var width = prefabWireComponentElement.GetAttributeFloat("width", 0.3f);
for (int i = 0; i < nodes.Length - 1; i++)
{
var line = (Start: nodes[i], End: nodes[i + 1]);
var wireSegment = new Wire.WireSection(line.Start, line.End);
wireSegment.Draw(spriteRecorder, wireSprite, color, Vector2.Zero, depth, width);
}
}
private void BakeMapEntity(XElement element)
{
Identifier identifier = element.GetAttributeIdentifier("identifier", Identifier.Empty);
@@ -313,27 +371,27 @@ namespace Barotrauma
float rotation = element.GetAttributeFloat("rotation", 0f);
MapEntityPrefab prefab = null;
if (element.Name.ToString().Equals("item", StringComparison.OrdinalIgnoreCase) &&
ItemPrefab.Prefabs.TryGet(identifier, out ItemPrefab ip))
MapEntityPrefab prefab;
if (element.NameAsIdentifier() == "item"
&& ItemPrefab.Prefabs.TryGet(identifier, out ItemPrefab ip))
{
prefab = ip;
}
else
{
prefab = MapEntityPrefab.List.FirstOrDefault(p => p.Identifier == identifier);
prefab = MapEntityPrefab.FindByIdentifier(identifier);
}
if (prefab == null) { return; }
var texture = prefab.Sprite.Texture;
var srcRect = prefab.Sprite.SourceRect;
flippedX &= prefab.CanSpriteFlipX;
flippedY &= prefab.CanSpriteFlipY;
SpriteEffects spriteEffects = SpriteEffects.None;
if (flippedX && ((prefab as ItemPrefab)?.CanSpriteFlipX ?? true))
if (flippedX)
{
spriteEffects |= SpriteEffects.FlipHorizontally;
}
if (flippedY && ((prefab as ItemPrefab)?.CanSpriteFlipY ?? true))
if (flippedY)
{
spriteEffects |= SpriteEffects.FlipVertically;
}
@@ -419,8 +477,8 @@ namespace Barotrauma
{
float offsetState = 0f;
Vector2 offset = decorativeSprite.GetOffset(ref offsetState, Vector2.Zero) * scale;
if (flippedX && itemPrefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (flippedY && itemPrefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
if (flippedX) { offset.X = -offset.X; }
if (flippedY) { offset.Y = -offset.Y; }
decorativeSprite.Sprite.DrawTiled(spriteRecorder,
new Vector2(spritePos.X + offset.X - rect.Width / 2, -(spritePos.Y + offset.Y + rect.Height / 2)),
rect.Size.ToVector2(), color: color,
@@ -451,8 +509,8 @@ namespace Barotrauma
float rotationState = 0f; float offsetState = 0f;
float rot = decorativeSprite.GetRotation(ref rotationState, 0f);
Vector2 offset = decorativeSprite.GetOffset(ref offsetState, Vector2.Zero) * scale;
if (flippedX && itemPrefab.CanSpriteFlipX) { offset.X = -offset.X; }
if (flippedY && itemPrefab.CanSpriteFlipY) { offset.Y = -offset.Y; }
if (flippedX) { offset.X = -offset.X; }
if (flippedY) { offset.Y = -offset.Y; }
decorativeSprite.Sprite.Draw(spriteRecorder, new Vector2(spritePos.X + offset.X, -(spritePos.Y + offset.Y)), color,
MathHelper.ToRadians(rotation) + rot, decorativeSprite.GetScale(0f) * scale, prefab.Sprite.effects,
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.Sprite.Depth), 0.999f));
@@ -472,6 +530,7 @@ namespace Barotrauma
{
overrideSprite = false;
float relativeScale = scale / prefab.Scale;
foreach (var subElement in prefab.ConfigElement.Elements())
{
switch (subElement.Name.LocalName.ToLowerInvariant())
@@ -498,7 +557,6 @@ namespace Barotrauma
relativeBarrelPos,
MathHelper.ToRadians(rotation));
float relativeScale = scale / prefab.Scale;
Vector2 drawPos = new Vector2(rect.X + rect.Width * relativeScale / 2 + transformedBarrelPos.X * relativeScale, rect.Y - rect.Height * relativeScale / 2 - transformedBarrelPos.Y * relativeScale);
drawPos.Y = -drawPos.Y;
@@ -516,20 +574,22 @@ namespace Barotrauma
break;
case "door":
doors.Add(new Door(rect));
var scaledRect = rect with { Size = (rect.Size.ToVector2() * relativeScale).ToPoint() };
doors.Add(new Door(scaledRect));
var doorSpriteElem = subElement.Elements().FirstOrDefault(e => e.Name.LocalName.Equals("sprite", StringComparison.OrdinalIgnoreCase));
if (doorSpriteElem != null)
{
string texturePath = doorSpriteElem.GetAttributeString("texture", "");
Vector2 pos = rect.Location.ToVector2() * new Vector2(1f, -1f);
string texturePath = doorSpriteElem.GetAttributeStringUnrestricted("texture", "");
Vector2 pos = scaledRect.Location.ToVector2() * new Vector2(1f, -1f);
if (subElement.GetAttributeBool("horizontal", false))
{
pos.Y += (float)rect.Height * 0.5f;
pos.Y += (float)scaledRect.Height * 0.5f;
}
else
{
pos.X += (float)rect.Width * 0.5f;
pos.X += (float)scaledRect.Width * 0.5f;
}
Sprite doorSprite = new Sprite(doorSpriteElem, texturePath.Contains("/") ? "" : Path.GetDirectoryName(prefab.FilePath));
spriteRecorder.Draw(doorSprite.Texture, pos,
@@ -555,7 +615,7 @@ namespace Barotrauma
}
}
public void ParseUpgrades(XElement prefabConfigElement, ref float scale)
private void ParseUpgrades(XElement prefabConfigElement, ref float scale)
{
foreach (var upgrade in prefabConfigElement.Elements("Upgrade"))
{