Unstable 1.2.1.0
This commit is contained in:
@@ -277,12 +277,21 @@ namespace Barotrauma
|
||||
Rectangle drawRect =
|
||||
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||
|
||||
if ((IsSelected || IsHighlighted) && editing)
|
||||
if (editing)
|
||||
{
|
||||
if (IsSelected || IsHighlighted)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUIStyle.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
}
|
||||
|
||||
float waterHeight = WaterVolume / rect.Width;
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
(IsHighlighted ? Color.LightBlue * 0.8f : GUIStyle.Red * 0.5f) * alpha, false, 0, (int)Math.Max(5.0f / Screen.Selected.Cam.Zoom, 1.0f));
|
||||
new Vector2(drawRect.X, -drawRect.Y + drawRect.Height - waterHeight),
|
||||
new Vector2(drawRect.Width, waterHeight),
|
||||
Color.Blue * 0.25f, isFilled: true);
|
||||
}
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
@@ -300,13 +309,27 @@ namespace Barotrauma
|
||||
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 5, -drawRect.Y + 5), Color.White);
|
||||
GUIStyle.SmallFont.DrawString(spriteBatch, waterVolume + " / " + Volume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * Math.Min(waterVolume / Volume, 1.0f))), Color.Cyan, true);
|
||||
if (WaterVolume > Volume)
|
||||
if (WaterVolume > 0)
|
||||
{
|
||||
float maxExcessWater = Volume * MaxCompress;
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, (int)(100 * (waterVolume - Volume) / maxExcessWater)), GUIStyle.Red, true);
|
||||
drawProgressBar(50, new Point(0, 0), Math.Min(waterVolume / Volume, 1.0f), Color.Cyan);
|
||||
if (WaterVolume > Volume)
|
||||
{
|
||||
float maxExcessWater = Volume * MaxCompress;
|
||||
drawProgressBar(50, new Point(0, 0), (waterVolume - Volume) / maxExcessWater, GUIStyle.Red);
|
||||
}
|
||||
}
|
||||
if (lethalPressure > 0)
|
||||
{
|
||||
drawProgressBar(50, new Point(20, 0), lethalPressure / 100.0f, Color.Red);
|
||||
}
|
||||
|
||||
void drawProgressBar(int height, Point offset, float fillAmount, Color color)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X - 2 + offset.X, -drawRect.Y - 2 + drawRect.Height / 2 + offset.Y, 14, height+4), Color.Black * 0.8f, depth: 0.01f, isFilled: true);
|
||||
|
||||
int barHeight = (int)(fillAmount * height);
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X + offset.X, -drawRect.Y + drawRect.Height / 2 + height - barHeight + offset.Y, 10, barHeight), color, isFilled: true);
|
||||
}
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.Center.X, -drawRect.Y + drawRect.Height / 2, 10, 100), Color.Black);
|
||||
|
||||
foreach (FireSource fs in FireSources)
|
||||
{
|
||||
@@ -732,7 +755,7 @@ namespace Barotrauma
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, sourceCharacter: null, isNetworkMessage: true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ namespace Barotrauma
|
||||
{
|
||||
mainElement = mainElement.FirstElement();
|
||||
prefabs.Clear();
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.Yellow);
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.MediumPurple);
|
||||
}
|
||||
else if (prefabs.Any())
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Barotrauma
|
||||
foreach (InterestingPosition pos in PositionsOfInterest)
|
||||
{
|
||||
Color color = Color.Yellow;
|
||||
if (pos.PositionType == PositionType.Cave)
|
||||
if (pos.PositionType == PositionType.Cave || pos.PositionType == PositionType.AbyssCave)
|
||||
{
|
||||
color = Color.DarkOrange;
|
||||
}
|
||||
@@ -61,6 +61,10 @@ namespace Barotrauma
|
||||
{
|
||||
color = Color.LightGray;
|
||||
}
|
||||
if (!pos.IsValid)
|
||||
{
|
||||
color = Color.Red;
|
||||
}
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(pos.Position.X - 15.0f, -pos.Position.Y - 15.0f), new Vector2(30.0f, 30.0f), color, true);
|
||||
}
|
||||
|
||||
@@ -1318,7 +1318,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
if (LightTextureTargetSize != Vector2.Zero)
|
||||
{
|
||||
LightSprite.DrawTiled(spriteBatch, drawPos, LightTextureTargetSize, color, startOffset: LightTextureOffset, textureScale: LightTextureScale);
|
||||
LightSprite.DrawTiled(spriteBatch, drawPos, LightTextureTargetSize, color: color, startOffset: LightTextureOffset, textureScale: LightTextureScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Barotrauma
|
||||
|
||||
Vector2 spriteScale = new Vector2(zoom);
|
||||
|
||||
uiSprite.Sprite.DrawTiled(spriteBatch, topLeft, size, Params.RadiationAreaColor, Vector2.Zero, textureScale: spriteScale);
|
||||
uiSprite.Sprite.DrawTiled(spriteBatch, topLeft, size, color: Params.RadiationAreaColor, startOffset: Vector2.Zero, textureScale: spriteScale);
|
||||
|
||||
Vector2 topRight = topLeft + Vector2.UnitX * size.X;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Barotrauma.Lights;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -65,9 +66,7 @@ namespace Barotrauma
|
||||
disableSelect = value;
|
||||
if (disableSelect)
|
||||
{
|
||||
startMovingPos = Vector2.Zero;
|
||||
selectionSize = Vector2.Zero;
|
||||
selectionPos = Vector2.Zero;
|
||||
StopSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,6 +493,13 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void StopSelection()
|
||||
{
|
||||
startMovingPos = Vector2.Zero;
|
||||
selectionSize = Vector2.Zero;
|
||||
selectionPos = Vector2.Zero;
|
||||
}
|
||||
|
||||
public static Vector2 GetNudgeAmount(bool doHold = true)
|
||||
{
|
||||
Vector2 nudgeAmount = Vector2.Zero;
|
||||
@@ -792,12 +798,16 @@ namespace Barotrauma
|
||||
foreach (MapEntity e in SelectedList)
|
||||
{
|
||||
SpriteEffects spriteEffects = SpriteEffects.None;
|
||||
float spriteRotation = 0.0f;
|
||||
float rectangleRotation = 0.0f;
|
||||
switch (e)
|
||||
{
|
||||
case Item item:
|
||||
{
|
||||
if (item.FlippedX && item.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
|
||||
if (item.flippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
if (item.FlippedY && item.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
spriteRotation = MathHelper.ToRadians(item.Rotation);
|
||||
rectangleRotation = spriteRotation;
|
||||
var wire = item.GetComponent<Wire>();
|
||||
if (wire != null && wire.Item.body != null && !wire.Item.body.Enabled)
|
||||
{
|
||||
@@ -809,7 +819,10 @@ namespace Barotrauma
|
||||
case Structure structure:
|
||||
{
|
||||
if (structure.FlippedX && structure.Prefab.CanSpriteFlipX) { spriteEffects ^= SpriteEffects.FlipHorizontally; }
|
||||
if (structure.flippedY && structure.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
if (structure.FlippedY && structure.Prefab.CanSpriteFlipY) { spriteEffects ^= SpriteEffects.FlipVertically; }
|
||||
spriteRotation = MathHelper.ToRadians(structure.Rotation);
|
||||
rectangleRotation = spriteRotation;
|
||||
if (structure.FlippedX != structure.FlippedY) { rectangleRotation = -rectangleRotation; }
|
||||
break;
|
||||
}
|
||||
case WayPoint wayPoint:
|
||||
@@ -831,11 +844,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
e.Prefab?.DrawPlacing(spriteBatch,
|
||||
new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteEffects);
|
||||
new Rectangle(e.WorldRect.Location + new Point((int)moveAmount.X, (int)-moveAmount.Y), e.WorldRect.Size), e.Scale, spriteRotation, spriteEffects: spriteEffects);
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(e.WorldRect.X, -e.WorldRect.Y) + moveAmount,
|
||||
new Vector2(e.rect.Width, e.rect.Height),
|
||||
Color.White, false, 0, (int)Math.Max(3.0f / GameScreen.Selected.Cam.Zoom, 2.0f));
|
||||
center: e.WorldRect.Center.ToVector2().FlipY() + moveAmount + new Vector2(0f, e.WorldRect.Height),
|
||||
width: e.WorldRect.Width, height: e.WorldRect.Height,
|
||||
rotation: rectangleRotation, clr: Color.White,
|
||||
depth: 0f, thickness: Math.Max(3.0f / GameScreen.Selected.Cam.Zoom, 2.0f));
|
||||
}
|
||||
|
||||
//stop dragging the "selection rectangle"
|
||||
@@ -877,6 +891,23 @@ namespace Barotrauma
|
||||
spriteBatch.DrawLine(corners[3] + offset, corners[0] - offset, color, thickness);
|
||||
}
|
||||
|
||||
protected static void ColorFlipButton(GUIButton btn, bool flip)
|
||||
{
|
||||
var color = flip ? GUIStyle.Green : Color.White;
|
||||
var hsv = ToolBox.RGBToHSV(color);
|
||||
|
||||
// Boost saturation and reduce value a bit because our default colors are too muted for this button's style
|
||||
var hsvBase = hsv;
|
||||
hsvBase.Y *= 4f;
|
||||
hsvBase.Z *= 0.8f;
|
||||
btn.Color = ToolBox.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
|
||||
btn.SelectedColor = ToolBox.HSVToRGB(hsvBase.X, hsvBase.Y, hsvBase.Z);
|
||||
|
||||
var hsvHover = hsv;
|
||||
hsvHover.Z *= 1.2f;
|
||||
btn.HoverColor = ToolBox.HSVToRGB(hsvHover.X, hsvHover.Y, hsvHover.Z);
|
||||
}
|
||||
|
||||
public static List<MapEntity> FilteredSelectedList { get; private set; } = new List<MapEntity>();
|
||||
|
||||
public static void UpdateEditor(Camera cam, float deltaTime)
|
||||
@@ -1105,6 +1136,25 @@ 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));
|
||||
var rotation = -RotationRad;
|
||||
handleDiff = MathUtils.RotatePoint(handleDiff, rotation);
|
||||
if (FlippedX) { handleDiff = handleDiff.FlipX(); }
|
||||
if (FlippedY) { handleDiff = handleDiff.FlipY(); }
|
||||
return cam.WorldToScreen(Position + handleDiff);
|
||||
}
|
||||
|
||||
float ResizeHandleSize => 10 * GUI.Scale;
|
||||
float ResizeHandleHighlightDistance => 8 * GUI.Scale;
|
||||
|
||||
@@ -1119,9 +1169,10 @@ namespace Barotrauma
|
||||
{
|
||||
for (int y = startY; y < 2; y += 2)
|
||||
{
|
||||
Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f)));
|
||||
Vector2 handlePos = GetEditingHandlePos(x, y, cam);
|
||||
|
||||
bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
|
||||
|
||||
if (highlighted && PlayerInput.PrimaryMouseButtonDown())
|
||||
{
|
||||
selectionPos = Vector2.Zero;
|
||||
@@ -1138,44 +1189,83 @@ namespace Barotrauma
|
||||
{
|
||||
if (prevRect == null)
|
||||
{
|
||||
prevRect = new Rectangle(Rect.Location, Rect.Size);
|
||||
prevRect = Rect;
|
||||
}
|
||||
|
||||
Vector2 placePosition = new Vector2(rect.X, rect.Y);
|
||||
Vector2 placeSize = new Vector2(rect.Width, rect.Height);
|
||||
Vector2 placePosition = prevRect.Value.Location.ToVector2();
|
||||
Vector2 placeSize = prevRect.Value.Size.ToVector2();
|
||||
|
||||
Vector2 mousePos = Submarine.MouseToWorldGrid(cam, Submarine.MainSub, round: true);
|
||||
|
||||
if (PlayerInput.IsShiftDown())
|
||||
static Vector2 flipThenRotate(Vector2 point, Vector2 center, float angle, bool flipX, bool flipY)
|
||||
{
|
||||
mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (flipX) { point = (point - center).FlipX() + center; }
|
||||
if (flipY) { point = (point - center).FlipY() + center; }
|
||||
|
||||
point = MathUtils.RotatePointAroundTarget(point, center, angle);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
static Vector2 rotateThenFlip(Vector2 point, Vector2 center, float angle, bool flipX, bool flipY)
|
||||
{
|
||||
point = MathUtils.RotatePointAroundTarget(point, center, angle);
|
||||
|
||||
if (flipX) { point = (point - center).FlipX() + center; }
|
||||
if (flipY) { point = (point - center).FlipY() + center; }
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
Vector2 mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Vector2 prevPos = placePosition;
|
||||
Vector2 prevOppositeCorner = prevPos + placeSize.FlipY();
|
||||
Vector2 prevCenter = placePosition + placeSize.FlipY() * 0.5f;
|
||||
mousePos = flipThenRotate(mousePos, prevCenter, RotationRad, FlippedX, FlippedY);
|
||||
|
||||
if (!PlayerInput.IsShiftDown())
|
||||
{
|
||||
mousePos = Submarine.VectorToWorldGrid(mousePos, Submarine.MainSub, round: true);
|
||||
}
|
||||
|
||||
if (resizeDirX > 0)
|
||||
{
|
||||
mousePos.X = Math.Max(mousePos.X, rect.X + Submarine.GridSize.X);
|
||||
mousePos.X = Math.Max(mousePos.X, prevRect.Value.X + Submarine.GridSize.X);
|
||||
placeSize.X = mousePos.X - placePosition.X;
|
||||
}
|
||||
else if (resizeDirX < 0)
|
||||
{
|
||||
mousePos.X = Math.Min(mousePos.X, rect.Right - Submarine.GridSize.X);
|
||||
mousePos.X = Math.Min(mousePos.X, prevRect.Value.Right - Submarine.GridSize.X);
|
||||
|
||||
placeSize.X = MathF.Round((placePosition.X + placeSize.X) - mousePos.X);
|
||||
placePosition.X = MathF.Round(mousePos.X);
|
||||
}
|
||||
if (resizeDirY < 0)
|
||||
{
|
||||
mousePos.Y = Math.Min(mousePos.Y, rect.Y - Submarine.GridSize.Y);
|
||||
mousePos.Y = Math.Min(mousePos.Y, prevRect.Value.Y - Submarine.GridSize.Y);
|
||||
placeSize.Y = placePosition.Y - mousePos.Y;
|
||||
}
|
||||
else if (resizeDirY > 0)
|
||||
{
|
||||
mousePos.Y = Math.Max(mousePos.Y, rect.Y - rect.Height + Submarine.GridSize.X);
|
||||
mousePos.Y = Math.Max(mousePos.Y, prevRect.Value.Y - prevRect.Value.Height + Submarine.GridSize.Y);
|
||||
|
||||
placeSize.Y = mousePos.Y - (rect.Y - rect.Height);
|
||||
placeSize.Y = mousePos.Y - (prevRect.Value.Y - prevRect.Value.Height);
|
||||
placePosition.Y = mousePos.Y;
|
||||
}
|
||||
|
||||
Vector2 newPos = placePosition;
|
||||
Vector2 newOppositeCorner = placePosition + placeSize.FlipY();
|
||||
|
||||
Vector2 transformedCornerDiff = rotateThenFlip(newPos-prevPos, Vector2.Zero, -RotationRad, FlippedX, FlippedY);
|
||||
Vector2 transformedOppositeCornerDiff = rotateThenFlip(newOppositeCorner-prevOppositeCorner, Vector2.Zero, -RotationRad, FlippedX, FlippedY);
|
||||
|
||||
Vector2 newPosTransformed = rotateThenFlip(prevPos, prevCenter, -RotationRad, FlippedX, FlippedY)
|
||||
+ transformedCornerDiff;
|
||||
Vector2 newOppositeTransformed = rotateThenFlip(prevOppositeCorner, prevCenter, -RotationRad, FlippedX, FlippedY)
|
||||
+ transformedOppositeCornerDiff;
|
||||
Vector2 newTransformedCenter = (newPosTransformed + newOppositeTransformed) * 0.5f;
|
||||
|
||||
var newDiff = (newOppositeCorner - newPos) * 0.5f;
|
||||
placePosition = newTransformedCenter - newDiff;
|
||||
|
||||
if ((int)placePosition.X != rect.X || (int)placePosition.Y != rect.Y || (int)placeSize.X != rect.Width || (int)placeSize.Y != rect.Height)
|
||||
{
|
||||
Rect = new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y);
|
||||
@@ -1210,15 +1300,16 @@ namespace Barotrauma
|
||||
IsHighlighted = true;
|
||||
|
||||
int startX = ResizeHorizontal ? -1 : 0;
|
||||
int StartY = ResizeVertical ? -1 : 0;
|
||||
int startY = ResizeVertical ? -1 : 0;
|
||||
|
||||
for (int x = startX; x < 2; x += 2)
|
||||
{
|
||||
for (int y = StartY; y < 2; y += 2)
|
||||
for (int y = startY; y < 2; y += 2)
|
||||
{
|
||||
Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f), y * (rect.Height * 0.5f)));
|
||||
Vector2 handlePos = GetEditingHandlePos(x, y, cam);
|
||||
|
||||
bool highlighted = Vector2.DistanceSquared(PlayerInput.MousePosition, handlePos) < ResizeHandleHighlightDistance * ResizeHandleHighlightDistance;
|
||||
var color = Color.White * (highlighted ? 1.0f : 0.6f);
|
||||
if (highlighted && !PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
GUI.MouseCursor = CursorState.Hand;
|
||||
@@ -1226,7 +1317,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
handlePos - new Vector2(ResizeHandleSize / 2),
|
||||
new Vector2(ResizeHandleSize),
|
||||
Color.White * (highlighted ? 1.0f : 0.6f),
|
||||
color,
|
||||
true, 0,
|
||||
(int)Math.Max(1.5f / GameScreen.Selected.Cam.Zoom, 1.0f));
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DrawPlacing(SpriteBatch spriteBatch, Rectangle drawRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
public virtual void DrawPlacing(SpriteBatch spriteBatch, Rectangle drawRect, float scale = 1.0f, float rotation = 0.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#nullable enable
|
||||
using Barotrauma.Sounds;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Sounds;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -45,7 +44,8 @@ namespace Barotrauma
|
||||
}
|
||||
if (FrequencyMultiplierRange.Y > 4.0f)
|
||||
{
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")");
|
||||
DebugConsole.ThrowError($"Loaded frequency range exceeds max value: {FrequencyMultiplierRange} (original string was \"{freqMultAttr}\")",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
IgnoreMuffling = element.GetAttributeBool("dontmuffle", false);
|
||||
}
|
||||
@@ -65,7 +65,8 @@ namespace Barotrauma
|
||||
if (filename is null)
|
||||
{
|
||||
string errorMsg = "Error when loading round sound (" + element + ") - file path not set";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
DebugConsole.ThrowError(errorMsg,
|
||||
contentPackage: element.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FilePathEmpty" + element.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
@@ -86,7 +87,8 @@ namespace Barotrauma
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\" (file not found).";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: element.ContentPackage);
|
||||
if (!ContentPackageManager.ModsEnabled)
|
||||
{
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
@@ -96,7 +98,8 @@ namespace Barotrauma
|
||||
catch (System.IO.InvalidDataException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + filename + "\" (invalid data).";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: element.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:InvalidData" + filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return null;
|
||||
}
|
||||
@@ -123,7 +126,8 @@ namespace Barotrauma
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
string errorMsg = "Failed to load sound file \"" + roundSound.Filename + "\".";
|
||||
DebugConsole.ThrowError(errorMsg, e);
|
||||
DebugConsole.ThrowError(errorMsg, e,
|
||||
contentPackage: roundSound.Sound?.XElement?.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce("RoundSound.LoadRoundSound:FileNotFound" + roundSound.Filename, GameAnalyticsManager.ErrorSeverity.Error, errorMsg + "\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,8 @@ namespace Barotrauma
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
|
||||
var mirrorX = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
@@ -160,10 +161,12 @@ namespace Barotrauma
|
||||
me.FlipX(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipX(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedX);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
ColorFlipButton(mirrorX, FlippedX);
|
||||
var mirrorY = new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"), style: "GUIButtonSmall")
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
@@ -173,9 +176,11 @@ namespace Barotrauma
|
||||
me.FlipY(relativeToSub: false);
|
||||
}
|
||||
if (!SelectedList.Contains(this)) { FlipY(relativeToSub: false); }
|
||||
ColorFlipButton(button, FlippedY);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ColorFlipButton(mirrorY, FlippedY);
|
||||
new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
@@ -357,8 +362,10 @@ namespace Barotrauma
|
||||
|
||||
Prefab.BackgroundSprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
|
||||
new Vector2(rect.X + rect.Width / 2 + drawOffset.X, -(rect.Y - rect.Height / 2 + drawOffset.Y)),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: Prefab.BackgroundSpriteColor,
|
||||
textureScale: TextureScale * Scale,
|
||||
startOffset: backGroundOffset,
|
||||
@@ -368,8 +375,10 @@ namespace Barotrauma
|
||||
{
|
||||
Prefab.BackgroundSprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)) + dropShadowOffset,
|
||||
new Vector2(rect.X + rect.Width / 2 + drawOffset.X, -(rect.Y - rect.Height / 2 + drawOffset.Y)) + dropShadowOffset,
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: Color.Black * 0.5f,
|
||||
textureScale: TextureScale * Scale,
|
||||
startOffset: backGroundOffset,
|
||||
@@ -385,6 +394,13 @@ namespace Barotrauma
|
||||
SpriteEffects oldEffects = Prefab.Sprite.effects;
|
||||
Prefab.Sprite.effects ^= SpriteEffects;
|
||||
|
||||
Vector2 advanceX = MathUtils.RotatedUnitXRadians(this.rotationRad).FlipY();
|
||||
Vector2 advanceY = advanceX.YX().FlipX();
|
||||
if (FlippedX != FlippedY)
|
||||
{
|
||||
advanceX = advanceX.FlipY();
|
||||
advanceY = advanceY.FlipX();
|
||||
}
|
||||
for (int i = 0; i < Sections.Length; i++)
|
||||
{
|
||||
Rectangle drawSection = Sections[i].rect;
|
||||
@@ -409,7 +425,7 @@ namespace Barotrauma
|
||||
drawSection = new Rectangle(
|
||||
drawSection.X,
|
||||
drawSection.Y,
|
||||
Sections[Sections.Length -1 ].rect.Right - drawSection.X,
|
||||
Sections[Sections.Length - 1].rect.Right - drawSection.X,
|
||||
drawSection.Y - (Sections[Sections.Length - 1].rect.Y - Sections[Sections.Length - 1].rect.Height));
|
||||
i = Sections.Length;
|
||||
}
|
||||
@@ -424,10 +440,18 @@ namespace Barotrauma
|
||||
sectionOffset.X += MathUtils.PositiveModulo((int)-textureOffset.X, Prefab.Sprite.SourceRect.Width);
|
||||
sectionOffset.Y += MathUtils.PositiveModulo((int)-textureOffset.Y, Prefab.Sprite.SourceRect.Height);
|
||||
|
||||
Vector2 pos = new Vector2(drawSection.X, drawSection.Y);
|
||||
pos -= rect.Location.ToVector2();
|
||||
pos = advanceX * pos.X + advanceY * pos.Y;
|
||||
pos += rect.Location.ToVector2();
|
||||
pos = new Vector2(pos.X + rect.Width / 2 + drawOffset.X, -(pos.Y - rect.Height / 2 + drawOffset.Y));
|
||||
|
||||
Prefab.Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(drawSection.X + drawOffset.X, -(drawSection.Y + drawOffset.Y)),
|
||||
pos,
|
||||
new Vector2(drawSection.Width, drawSection.Height),
|
||||
rotation: rotationRad,
|
||||
origin: rect.Size.ToVector2() * new Vector2(0.5f, 0.5f),
|
||||
color: color,
|
||||
startOffset: sectionOffset,
|
||||
depth: depth,
|
||||
@@ -437,7 +461,7 @@ namespace Barotrauma
|
||||
foreach (var decorativeSprite in Prefab.DecorativeSprites)
|
||||
{
|
||||
if (!spriteAnimState[decorativeSprite].IsActive) { continue; }
|
||||
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor);
|
||||
float rotation = decorativeSprite.GetRotation(ref spriteAnimState[decorativeSprite].RotationState, spriteAnimState[decorativeSprite].RandomRotationFactor) + this.rotationRad;
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref spriteAnimState[decorativeSprite].OffsetState, spriteAnimState[decorativeSprite].RandomOffsetMultiplier) * Scale;
|
||||
decorativeSprite.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X + offset.X, -(DrawPosition.Y + offset.Y)), color,
|
||||
rotation, decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale, Prefab.Sprite.effects,
|
||||
|
||||
@@ -94,16 +94,21 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight * 2), Color.White);
|
||||
}
|
||||
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
public override void DrawPlacing(SpriteBatch spriteBatch, Rectangle placeRect, float scale = 1.0f, float rotation = 0.0f, SpriteEffects spriteEffects = SpriteEffects.None)
|
||||
{
|
||||
SpriteEffects oldEffects = Sprite.effects;
|
||||
Sprite.effects ^= spriteEffects;
|
||||
|
||||
var position = placeRect.Location.ToVector2().FlipY();
|
||||
position += placeRect.Size.ToVector2() * 0.5f;
|
||||
|
||||
Sprite.DrawTiled(
|
||||
spriteBatch,
|
||||
new Vector2(placeRect.X, -placeRect.Y),
|
||||
new Vector2(placeRect.Width, placeRect.Height),
|
||||
color: Color.White * 0.8f,
|
||||
position,
|
||||
placeRect.Size.ToVector2(),
|
||||
color: Color.White * 0.8f,
|
||||
origin: placeRect.Size.ToVector2() * 0.5f,
|
||||
rotation: rotation,
|
||||
textureScale: TextureScale * scale);
|
||||
|
||||
Sprite.effects = oldEffects;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Margin applied around the view area when culling entities (i.e. entities that are this far outside the view are still considered visible)
|
||||
/// </summary>
|
||||
private const int CullMargin = 500;
|
||||
private const int CullMargin = 50;
|
||||
/// <summary>
|
||||
/// Update entity culling when any corner of the view has moved more than this
|
||||
/// </summary>
|
||||
@@ -713,18 +713,12 @@ namespace Barotrauma
|
||||
return GameMain.LightManager.Lights.Count(l => l.CastShadows && !l.IsBackground) - disabledItemLightCount;
|
||||
}
|
||||
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub, bool round = false)
|
||||
public static Vector2 MouseToWorldGrid(Camera cam, Submarine sub, Vector2? mousePos = null, bool round = false)
|
||||
{
|
||||
Vector2 position = PlayerInput.MousePosition;
|
||||
Vector2 position = mousePos ?? PlayerInput.MousePosition;
|
||||
position = cam.ScreenToWorld(position);
|
||||
|
||||
Vector2 worldGridPos = VectorToWorldGrid(position, round);
|
||||
|
||||
if (sub != null)
|
||||
{
|
||||
worldGridPos.X += sub.Position.X % GridSize.X;
|
||||
worldGridPos.Y += sub.Position.Y % GridSize.Y;
|
||||
}
|
||||
Vector2 worldGridPos = VectorToWorldGrid(position, sub, round);
|
||||
|
||||
return worldGridPos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user