v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -20,7 +20,8 @@ namespace Barotrauma
|
||||
|
||||
public override bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
return Screen.Selected == GameMain.SubEditorScreen || GameMain.DebugDraw;
|
||||
if (Screen.Selected != GameMain.SubEditorScreen && !GameMain.DebugDraw) { return false; }
|
||||
return base.IsVisible(worldView);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch sb, bool editing, bool back = true)
|
||||
|
||||
@@ -81,16 +81,12 @@ namespace Barotrauma
|
||||
public override bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
if (BallastFlora != null) { return true; }
|
||||
|
||||
if (Screen.Selected != GameMain.SubEditorScreen && !GameMain.DebugDraw)
|
||||
{
|
||||
if (decals.Count == 0 && paintAmount < minimumPaintAmountToDraw) { return false; }
|
||||
|
||||
Rectangle worldRect = WorldRect;
|
||||
if (worldRect.X > worldView.Right || worldRect.Right < worldView.X) { return false; }
|
||||
if (worldRect.Y < worldView.Y - worldView.Height || worldRect.Y - worldRect.Height > worldView.Y) { return false; }
|
||||
}
|
||||
return true;
|
||||
return base.IsVisible(worldView);
|
||||
}
|
||||
|
||||
public override bool IsMouseOn(Vector2 position)
|
||||
@@ -103,12 +99,31 @@ namespace Barotrauma
|
||||
|
||||
private GUIComponent CreateEditingHUD(bool inGame = false)
|
||||
{
|
||||
int heightScaled = GUI.IntScale(20);
|
||||
editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) }) { UserData = this };
|
||||
GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.8f), editingHUD.RectTransform, Anchor.Center), style: null)
|
||||
{
|
||||
CanTakeKeyBoardFocus = false
|
||||
};
|
||||
new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUIStyle.LargeFont);
|
||||
var hullEditor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUIStyle.LargeFont);
|
||||
|
||||
if (!inGame)
|
||||
{
|
||||
if (Linkable)
|
||||
{
|
||||
var linkText = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, heightScaled), isFixedSize: true), TextManager.Get("HoldToLink"), font: GUIStyle.SmallFont);
|
||||
var hullLinkText = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, heightScaled), isFixedSize: true), TextManager.Get("hulllinkinfo"), font: GUIStyle.SmallFont);
|
||||
var itemsText = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, heightScaled), isFixedSize: true), TextManager.Get("AllowedLinks"), font: GUIStyle.SmallFont);
|
||||
LocalizedString allowedItems = AllowedLinks.None() ? TextManager.Get("None") : string.Join(", ", AllowedLinks);
|
||||
itemsText.Text = TextManager.AddPunctuation(':', itemsText.Text, allowedItems);
|
||||
hullEditor.AddCustomContent(linkText, 1);
|
||||
hullEditor.AddCustomContent(hullLinkText, 2);
|
||||
hullEditor.AddCustomContent(itemsText, 3);
|
||||
linkText.TextColor = GUIStyle.Orange;
|
||||
hullLinkText.TextColor = GUIStyle.Orange;
|
||||
itemsText.TextColor = GUIStyle.Orange;
|
||||
}
|
||||
}
|
||||
|
||||
PositionEditingHUD();
|
||||
|
||||
|
||||
@@ -47,62 +47,75 @@ namespace Barotrauma
|
||||
if (renderer == null) { return; }
|
||||
renderer.DrawDebugOverlay(spriteBatch, cam);
|
||||
|
||||
if (GameMain.DebugDraw && Screen.Selected.Cam.Zoom > 0.1f)
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
foreach (InterestingPosition pos in PositionsOfInterest)
|
||||
if (Screen.Selected.Cam.Zoom > 0.1f)
|
||||
{
|
||||
Color color = Color.Yellow;
|
||||
if (pos.PositionType == PositionType.Cave || pos.PositionType == PositionType.AbyssCave)
|
||||
foreach (InterestingPosition pos in PositionsOfInterest)
|
||||
{
|
||||
color = Color.DarkOrange;
|
||||
}
|
||||
else if (pos.PositionType == PositionType.Ruin)
|
||||
{
|
||||
color = Color.LightGray;
|
||||
}
|
||||
if (!pos.IsValid)
|
||||
{
|
||||
color = Color.Red;
|
||||
}
|
||||
Color color = Color.Yellow;
|
||||
if (pos.PositionType == PositionType.Cave || pos.PositionType == PositionType.AbyssCave)
|
||||
{
|
||||
color = Color.DarkOrange;
|
||||
}
|
||||
else if (pos.PositionType == PositionType.Ruin)
|
||||
{
|
||||
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);
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(pos.Position.X - 15.0f, -pos.Position.Y - 15.0f), new Vector2(30.0f, 30.0f), color, true);
|
||||
}
|
||||
|
||||
foreach (RuinGeneration.Ruin ruin in Ruins)
|
||||
{
|
||||
Rectangle ruinArea = ruin.Area;
|
||||
ruinArea.Y = -ruinArea.Y - ruinArea.Height;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, ruinArea, Color.DarkSlateBlue, false, 0, 5);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (RuinGeneration.Ruin ruin in Ruins)
|
||||
{
|
||||
Rectangle ruinArea = ruin.Area;
|
||||
ruinArea.Y = -ruinArea.Y - ruinArea.Height;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, ruinArea, Color.DarkSlateBlue, false, 0, 5);
|
||||
}
|
||||
|
||||
foreach (var positions in wreckPositions.Values)
|
||||
|
||||
float zoomFactor = MathHelper.Lerp(20, 1, MathUtils.InverseLerp(Screen.Selected.Cam.MinZoom, Screen.Selected.Cam.DefaultZoom, Screen.Selected.Cam.Zoom));
|
||||
foreach ((string debugInfo, List<Vector2> positions) in positionHistory)
|
||||
{
|
||||
for (int i = 0; i < positions.Count; i++)
|
||||
{
|
||||
float t = (i + 1) / (float)positions.Count;
|
||||
float multiplier = MathHelper.Lerp(0, 1, t);
|
||||
float multiplier = MathHelper.Lerp(0.1f, 1, t);
|
||||
Color color = Color.Red * multiplier;
|
||||
var pos = positions[i];
|
||||
pos.Y = -pos.Y;
|
||||
var size = new Vector2(100);
|
||||
GUI.DrawRectangle(spriteBatch, pos - size / 2, size, color, thickness: 10);
|
||||
var size = new Vector2(200);
|
||||
if (i == 0)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, pos - size, size * 2, Color.Red, thickness: 2 * zoomFactor);
|
||||
GUI.DrawString(spriteBatch, pos - new Vector2(10, 20), debugInfo, Color.White, font: GUIStyle.LargeFont, forceUpperCase: ForceUpperCase.Yes);
|
||||
}
|
||||
if (i < positions.Count - 1)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, pos - size / 2, size, Color.Red, isFilled: true);
|
||||
}
|
||||
var nextPos = positions[i + 1];
|
||||
nextPos.Y = -nextPos.Y;
|
||||
GUI.DrawLine(spriteBatch, pos, nextPos, color, width: 10);
|
||||
GUI.DrawLine(spriteBatch, pos, nextPos, color, width: 4 * zoomFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var rects in blockedRects.Values)
|
||||
foreach ((Submarine sub, List<Rectangle> rects) in blockedRects)
|
||||
{
|
||||
foreach (var rect in rects)
|
||||
foreach (Rectangle t in rects)
|
||||
{
|
||||
Rectangle newRect = rect;
|
||||
Rectangle newRect = t;
|
||||
newRect.Y = -newRect.Y;
|
||||
GUI.DrawRectangle(spriteBatch, newRect, Color.Red, thickness: 5);
|
||||
GUI.DrawRectangle(spriteBatch, newRect, Color.Red * 0.1f, isFilled: true);
|
||||
GUI.DrawString(spriteBatch, newRect.Center.ToVector2(), $"{sub.Info.Name}", Color.White, font: GUIStyle.LargeFont, forceUpperCase: ForceUpperCase.Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -239,7 +240,8 @@ namespace Barotrauma
|
||||
|
||||
public void DrawBackground(SpriteBatch spriteBatch, Camera cam,
|
||||
LevelObjectManager backgroundSpriteManager = null,
|
||||
BackgroundCreatureManager backgroundCreatureManager = null)
|
||||
BackgroundCreatureManager backgroundCreatureManager = null,
|
||||
ParticleManager particleManager = null)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap);
|
||||
|
||||
@@ -277,7 +279,7 @@ namespace Barotrauma
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.NonPremultiplied,
|
||||
SamplerState.LinearWrap, DepthStencilState.DepthRead, null, null,
|
||||
cam.Transform);
|
||||
cam.Transform);
|
||||
|
||||
backgroundSpriteManager?.DrawObjectsBack(spriteBatch, cam);
|
||||
if (cam.Zoom > 0.05f)
|
||||
@@ -321,6 +323,9 @@ namespace Barotrauma
|
||||
color: level.GenerationParams.WaterParticleColor * alpha, textureScale: new Vector2(texScale));
|
||||
}
|
||||
}
|
||||
|
||||
GameMain.ParticleManager?.Draw(spriteBatch, inWater: true, inSub: false, ParticleBlendState.AlphaBlend, background: true);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
RenderWalls(GameMain.Instance.GraphicsDevice, cam);
|
||||
@@ -465,7 +470,8 @@ namespace Barotrauma
|
||||
var wallList = i == 0 ? level.ExtraWalls : level.UnsyncedExtraWalls;
|
||||
foreach (LevelWall wall in wallList)
|
||||
{
|
||||
if (!(wall is DestructibleLevelWall destructibleWall) || destructibleWall.Destroyed) { continue; }
|
||||
if (wall is not DestructibleLevelWall destructibleWall || destructibleWall.Destroyed) { continue; }
|
||||
if (!wall.IsVisible(cam.WorldView)) { continue; }
|
||||
|
||||
wallCenterEffect.Texture = level.GenerationParams.DestructibleWallSprite?.Texture ?? level.GenerationParams.WallSprite.Texture;
|
||||
wallCenterEffect.World = wall.GetTransform() * transformMatrix;
|
||||
@@ -521,6 +527,7 @@ namespace Barotrauma
|
||||
foreach (LevelWall wall in wallList)
|
||||
{
|
||||
if (wall is DestructibleLevelWall) { continue; }
|
||||
if (!wall.IsVisible(cam.WorldView)) { continue; }
|
||||
//TODO: use LevelWallVertexBuffers for extra walls as well
|
||||
wallCenterEffect.World = wall.GetTransform() * transformMatrix;
|
||||
wallCenterEffect.Alpha = wall.Alpha;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using FarseerPhysics;
|
||||
using Barotrauma.Extensions;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -41,5 +43,23 @@ namespace Barotrauma
|
||||
level.GenerationParams.WallEdgeSprite.Texture,
|
||||
color);
|
||||
}
|
||||
|
||||
public bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
RectangleF worldViewInSimUnits = new RectangleF(
|
||||
ConvertUnits.ToSimUnits(worldView.Location.ToVector2()),
|
||||
ConvertUnits.ToSimUnits(worldView.Size.ToVector2()));
|
||||
|
||||
foreach (var fixture in Body.FixtureList)
|
||||
{
|
||||
fixture.GetAABB(out var aabb, 0);
|
||||
Vector2 lowerBound = aabb.LowerBound + Body.Position;
|
||||
if (lowerBound.X > worldViewInSimUnits.Right || lowerBound.Y > worldViewInSimUnits.Y) { continue; }
|
||||
Vector2 upperBound = aabb.UpperBound + Body.Position;
|
||||
if (upperBound.X < worldViewInSimUnits.X || upperBound.Y < worldViewInSimUnits.Y - worldViewInSimUnits.Height) { continue; }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,6 +12,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
public readonly Submarine Submarine;
|
||||
public HashSet<ConvexHull> IsHidden = new HashSet<ConvexHull>();
|
||||
public HashSet<ConvexHull> HasBeenVisible = new HashSet<ConvexHull>();
|
||||
public readonly List<ConvexHull> List = new List<ConvexHull>();
|
||||
|
||||
public ConvexHullList(Submarine submarine)
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
private readonly List<LightSource> activeLights = new List<LightSource>(capacity: 100);
|
||||
private readonly List<LightSource> activeLightsWithLightVolume = new List<LightSource>(capacity: 100);
|
||||
private readonly List<LightSource> activeShadowCastingLights = new List<LightSource>(capacity: 100);
|
||||
|
||||
public static int ActiveLightCount { get; private set; }
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
//above the top boundary of the level (in an inactive respawn shuttle?)
|
||||
if (Level.Loaded != null && light.WorldPosition.Y > Level.Loaded.Size.Y) { continue; }
|
||||
if (Level.IsPositionAboveLevel(light.WorldPosition)) { continue; }
|
||||
|
||||
float range = light.LightSourceParams.TextureRange;
|
||||
if (light.LightSprite != null)
|
||||
@@ -315,19 +315,20 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
//find the lights with an active light volume
|
||||
activeLightsWithLightVolume.Clear();
|
||||
activeShadowCastingLights.Clear();
|
||||
foreach (var activeLight in activeLights)
|
||||
{
|
||||
if (!activeLight.CastShadows) { continue; }
|
||||
if (activeLight.Range < 1.0f || activeLight.Color.A < 1 || activeLight.CurrentBrightness <= 0.0f) { continue; }
|
||||
activeLightsWithLightVolume.Add(activeLight);
|
||||
activeShadowCastingLights.Add(activeLight);
|
||||
}
|
||||
|
||||
//remove some lights with a light volume if there's too many of them
|
||||
if (activeLightsWithLightVolume.Count > GameSettings.CurrentConfig.Graphics.VisibleLightLimit && Screen.Selected is { IsEditor: false })
|
||||
if (activeShadowCastingLights.Count > GameSettings.CurrentConfig.Graphics.VisibleLightLimit && Screen.Selected is { IsEditor: false })
|
||||
{
|
||||
for (int i = GameSettings.CurrentConfig.Graphics.VisibleLightLimit; i < activeLightsWithLightVolume.Count; i++)
|
||||
for (int i = GameSettings.CurrentConfig.Graphics.VisibleLightLimit; i < activeShadowCastingLights.Count; i++)
|
||||
{
|
||||
activeLights.Remove(activeLightsWithLightVolume[i]);
|
||||
activeLights.Remove(activeShadowCastingLights[i]);
|
||||
}
|
||||
}
|
||||
activeLights.Sort((l1, l2) => l1.LastRecalculationTime.CompareTo(l2.LastRecalculationTime));
|
||||
@@ -827,7 +828,7 @@ namespace Barotrauma.Lights
|
||||
public void ClearLights()
|
||||
{
|
||||
activeLights.Clear();
|
||||
activeLightsWithLightVolume.Clear();
|
||||
activeShadowCastingLights.Clear();
|
||||
lights.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -245,7 +245,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!needsRecalculation && value)
|
||||
if (value)
|
||||
{
|
||||
foreach (ConvexHullList chList in convexHullsInRange)
|
||||
{
|
||||
@@ -550,7 +550,6 @@ namespace Barotrauma.Lights
|
||||
chList.List.Clear();
|
||||
foreach (var convexHull in fullChList.List)
|
||||
{
|
||||
if (!convexHull.Enabled) { continue; }
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, convexHull.BoundingBox)) { continue; }
|
||||
if (lightSourceParams.Directional)
|
||||
{
|
||||
@@ -572,6 +571,7 @@ namespace Barotrauma.Lights
|
||||
chList.List.Add(convexHull);
|
||||
}
|
||||
chList.IsHidden.RemoveWhere(ch => !chList.List.Contains(ch));
|
||||
chList.HasBeenVisible.RemoveWhere(ch => !chList.List.Contains(ch));
|
||||
HullsUpToDate.Add(sub);
|
||||
}
|
||||
|
||||
@@ -604,7 +604,8 @@ namespace Barotrauma.Lights
|
||||
|
||||
foreach (var ch in chList.List)
|
||||
{
|
||||
if (ch.LastVertexChangeTime > LastRecalculationTime && !chList.IsHidden.Contains(ch))
|
||||
if (ch.LastVertexChangeTime > LastRecalculationTime &&
|
||||
(!chList.IsHidden.Contains(ch) || chList.HasBeenVisible.Contains(ch)))
|
||||
{
|
||||
NeedsRecalculation = true;
|
||||
break;
|
||||
@@ -712,8 +713,8 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
foreach (ConvexHull hull in chList.List)
|
||||
{
|
||||
if (hull.IsInvalid) { continue; }
|
||||
if (!chList.IsHidden.Contains(hull))
|
||||
if (hull.IsInvalid || !hull.Enabled) { continue; }
|
||||
if (!chList.IsHidden.Contains(hull) || chList.HasBeenVisible.Contains(hull))
|
||||
{
|
||||
//find convexhull segments that are close enough and facing towards the light source
|
||||
lock (mutex)
|
||||
@@ -732,7 +733,17 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
foreach (ConvexHull hull in chList.List)
|
||||
{
|
||||
chList.IsHidden.Add(hull);
|
||||
if (!hull.Enabled)
|
||||
{
|
||||
//if the hull is not enabled, we cannot determine if it's visible or hidden from the point of view of the light source
|
||||
//so let's not mark it as hidden, but instead consider it as something that has been visible, so we know to recalculate if/when it becomes enabled again
|
||||
chList.IsHidden.Remove(hull);
|
||||
chList.HasBeenVisible.Add(hull);
|
||||
continue;
|
||||
}
|
||||
|
||||
//mark convex hulls as hidden at this point, they're removed if we find any of the segments to be visible
|
||||
chList.IsHidden.Add(hull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,14 +1422,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (conditionals.None()) { return; }
|
||||
if (conditionalTarget == null) { return; }
|
||||
if (logicalOperator == PropertyConditional.LogicalOperatorType.And)
|
||||
{
|
||||
Enabled = conditionals.All(c => c.Matches(conditionalTarget));
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = conditionals.Any(c => c.Matches(conditionalTarget));
|
||||
}
|
||||
Enabled = PropertyConditional.CheckConditionals(conditionalTarget, conditionals, logicalOperator);
|
||||
}
|
||||
|
||||
public void DebugDrawVertices(SpriteBatch spriteBatch)
|
||||
@@ -1501,6 +1505,7 @@ namespace Barotrauma.Lights
|
||||
foreach (var convexHullList in convexHullsInRange)
|
||||
{
|
||||
convexHullList.IsHidden.Remove(visibleConvexHull);
|
||||
convexHullList.HasBeenVisible.Add(visibleConvexHull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -923,23 +923,25 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
Vector2 dPos = pos;
|
||||
//move the debug texts upwards so they don't go under the info panel that appears when highlighted
|
||||
Vector2 dPos = pos + new Vector2(15, -100);
|
||||
if (location == HighlightedLocation)
|
||||
{
|
||||
dPos.Y -= 80;
|
||||
GUI.DrawString(spriteBatch, dPos + new Vector2(15, 32), "Faction: " + (location.Faction?.Prefab.Name ?? "none"), Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
GUI.DrawString(spriteBatch, dPos + new Vector2(15, 50), "Secondary Faction: " + (location.SecondaryFaction?.Prefab.Name ?? "none"), Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
dPos.Y += 48;
|
||||
GUI.DrawString(spriteBatch, dPos, "Faction: " + (location.Faction?.Prefab.Name ?? "none"), Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
GUI.DrawString(spriteBatch, dPos + new Vector2(0, 18), "Secondary Faction: " + (location.SecondaryFaction?.Prefab.Name ?? "none"), Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
dPos.Y += 50;
|
||||
|
||||
if (PlayerInput.KeyDown(Keys.LeftShift))
|
||||
{
|
||||
GUI.DrawString(spriteBatch, new Vector2(150,150), "Dist: " +
|
||||
GUI.DrawString(spriteBatch, new Vector2(150, 150), "Dist: " +
|
||||
GetDistanceToClosestLocationOrConnection(CurrentLocation, int.MaxValue, loc => loc == location), Color.White, Color.Black, font: GUIStyle.SubHeadingFont);
|
||||
|
||||
}
|
||||
GUI.DrawString(spriteBatch, dPos, $"Difficulty: {location.LevelData.Difficulty.FormatSingleDecimal()}",
|
||||
ToolBox.GradientLerp(location.LevelData.Difficulty / 100.0f, GUIStyle.Blue, GUIStyle.Yellow, GUIStyle.Red), Color.Black * 0.8f, 4, font: GUIStyle.SmallFont);
|
||||
|
||||
dPos.Y += 25;
|
||||
GUI.DrawString(spriteBatch, dPos, $"Biome: {location.LevelData.Biome.DisplayName} ({location.LevelData.GenerationParams.Identifier})", Color.White, Color.Black, font: GUIStyle.SmallFont);
|
||||
}
|
||||
dPos.Y += 48;
|
||||
GUI.DrawString(spriteBatch, dPos, $"Difficulty: {location.LevelData.Difficulty.FormatSingleDecimal()}", Color.White, Color.Black * 0.8f, 4, font: GUIStyle.SmallFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1196,7 +1198,9 @@ namespace Barotrauma
|
||||
Vector2 center = rectCenter + (connection.CenterPos + viewOffset) * zoom;
|
||||
if (viewArea.Contains(center) && connection.Biome != null)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, center, (connection.LevelData?.GenerationParams?.Identifier ?? connection.Biome.Identifier) + " (" + connection.Difficulty.FormatSingleDecimal() + ")", Color.White);
|
||||
GUI.DrawString(spriteBatch, center - Vector2.UnitX * 50,
|
||||
$"{(connection.LevelData?.GenerationParams?.Identifier ?? connection.Biome.Identifier)} ({connection.Difficulty.FormatSingleDecimal()})",
|
||||
ToolBox.GradientLerp(connection.Difficulty / 100.0f, GUIStyle.Blue, GUIStyle.Yellow, GUIStyle.Red), backgroundColor: Color.Black * 0.7f, font: GUIStyle.SmallFont);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,16 @@ namespace Barotrauma
|
||||
|
||||
public virtual bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
Rectangle worldRect = WorldRect;
|
||||
if (worldRect.X > worldView.Right || worldRect.Right < worldView.X) { return false; }
|
||||
if (worldRect.Y < worldView.Y - worldView.Height || worldRect.Y - worldRect.Height > worldView.Y) { return false; }
|
||||
//zoomed extremely far out -> no need to render
|
||||
if (Screen.Selected.Cam.Zoom < 0.05f) { return false; }
|
||||
if (worldRect.Width * Screen.Selected.Cam.Zoom < 1.0f ||
|
||||
worldRect.Height * Screen.Selected.Cam.Zoom < 1.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -91,6 +101,8 @@ namespace Barotrauma
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { }
|
||||
|
||||
public virtual float GetDrawDepth() { return 0.0f; }
|
||||
|
||||
/// <summary>
|
||||
/// A method that modifies the draw depth to prevent z-fighting between entities with the same sprite depth
|
||||
/// </summary>
|
||||
@@ -305,6 +317,15 @@ namespace Barotrauma
|
||||
if (PlayerInput.IsCtrlDown())
|
||||
{
|
||||
HashSet<MapEntity> clones = Clone(SelectedList.ToList()).Where(c => c != null).ToHashSet();
|
||||
|
||||
if (clones.Count == 1)
|
||||
{
|
||||
if (clones.First() is WayPoint wayPoint && SelectedList.First() is WayPoint originalWaypoint && originalWaypoint.SpawnType == SpawnType.Path)
|
||||
{
|
||||
originalWaypoint.ConnectTo(wayPoint);
|
||||
}
|
||||
}
|
||||
|
||||
SelectedList = clones;
|
||||
SelectedList.ForEach(c => c.Move(moveAmount));
|
||||
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(new List<MapEntity>(clones), false));
|
||||
@@ -1068,6 +1089,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(clones, false, handleInventoryBehavior: false));
|
||||
if (Screen.Selected is SubEditorScreen subEditor) { subEditor.ReconstructLayers(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -73,9 +73,16 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Sound? existingSound = null;
|
||||
if (roundSoundByPath.TryGetValue(filename.FullPath, out RoundSound? rs) && rs.Sound is { Disposed: false })
|
||||
if (roundSoundByPath.TryGetValue(filename.FullPath, out RoundSound? rs))
|
||||
{
|
||||
existingSound = rs.Sound;
|
||||
if (rs.Sound is { Disposed: false })
|
||||
{
|
||||
existingSound = rs.Sound;
|
||||
}
|
||||
else
|
||||
{
|
||||
roundSoundByPath.Remove(filename.FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (existingSound is null)
|
||||
|
||||
@@ -328,11 +328,11 @@ namespace Barotrauma
|
||||
Vector2 max = new Vector2(worldRect.Right, worldRect.Y + worldRect.Height);
|
||||
foreach (DecorativeSprite decorativeSprite in Prefab.DecorativeSprites)
|
||||
{
|
||||
float scale = decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale;
|
||||
min.X = Math.Min(worldPos.X - decorativeSprite.Sprite.size.X * decorativeSprite.Sprite.RelativeOrigin.X * scale, min.X);
|
||||
max.X = Math.Max(worldPos.X + decorativeSprite.Sprite.size.X * (1.0f - decorativeSprite.Sprite.RelativeOrigin.X) * scale, max.X);
|
||||
min.Y = Math.Min(worldPos.Y - decorativeSprite.Sprite.size.Y * (1.0f - decorativeSprite.Sprite.RelativeOrigin.Y) * scale, min.Y);
|
||||
max.Y = Math.Max(worldPos.Y + decorativeSprite.Sprite.size.Y * decorativeSprite.Sprite.RelativeOrigin.Y * scale, max.Y);
|
||||
Vector2 scale = decorativeSprite.GetScale(ref spriteAnimState[decorativeSprite].ScaleState, spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale;
|
||||
min.X = Math.Min(worldPos.X - decorativeSprite.Sprite.size.X * decorativeSprite.Sprite.RelativeOrigin.X * scale.X, min.X);
|
||||
max.X = Math.Max(worldPos.X + decorativeSprite.Sprite.size.X * (1.0f - decorativeSprite.Sprite.RelativeOrigin.X) * scale.X, max.X);
|
||||
min.Y = Math.Min(worldPos.Y - decorativeSprite.Sprite.size.Y * (1.0f - decorativeSprite.Sprite.RelativeOrigin.Y) * scale.Y, min.Y);
|
||||
max.Y = Math.Max(worldPos.Y + decorativeSprite.Sprite.size.Y * decorativeSprite.Sprite.RelativeOrigin.Y * scale.Y, max.Y);
|
||||
}
|
||||
Vector2 offset = GetCollapseEffectOffset();
|
||||
min += offset;
|
||||
@@ -341,6 +341,9 @@ namespace Barotrauma
|
||||
if (min.X > worldView.Right || max.X < worldView.X) { return false; }
|
||||
if (min.Y > worldView.Y || max.Y < worldView.Y - worldView.Height) { return false; }
|
||||
|
||||
Vector2 extents = max - min;
|
||||
if (extents.X * Screen.Selected.Cam.Zoom < 1.0f) { return false; }
|
||||
if (extents.Y * Screen.Selected.Cam.Zoom < 1.0f) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -368,7 +371,7 @@ namespace Barotrauma
|
||||
return SpriteDepthOverrideIsSet ? SpriteOverrideDepth : Prefab.Sprite.Depth;
|
||||
}
|
||||
|
||||
public float GetDrawDepth()
|
||||
public override float GetDrawDepth()
|
||||
{
|
||||
return GetDrawDepth(GetRealDepth(), Prefab.Sprite);
|
||||
}
|
||||
@@ -560,7 +563,8 @@ namespace Barotrauma
|
||||
pos: drawPos.FlipY(),
|
||||
color: color,
|
||||
rotate: rotation,
|
||||
scale: decorativeSprite.GetScale(spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale,
|
||||
origin: decorativeSprite.Sprite.Origin,
|
||||
scale: decorativeSprite.GetScale(ref spriteAnimState[decorativeSprite].ScaleState, spriteAnimState[decorativeSprite].RandomScaleFactor) * Scale,
|
||||
spriteEffect: Prefab.Sprite.effects ^ SpriteEffects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - Prefab.Sprite.Depth), 0.999f));
|
||||
}
|
||||
|
||||
@@ -656,6 +656,7 @@ namespace Barotrauma
|
||||
errorMsgs.Add(TextManager.GetWithVariables("InsufficientFreeConnectionsWarning",
|
||||
("[doorcount]", doorLinks.ToString()),
|
||||
("[freeconnectioncount]", (item.Connections[i].MaxWires - wireCount).ToString())).Value);
|
||||
warnings.Add(SubEditorScreen.WarningType.InsufficientFreeConnectionsWarning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -836,7 +837,7 @@ namespace Barotrauma
|
||||
subBody.PositionBuffer.Insert(index, posInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ClientEventRead(IReadMessage msg, float sendingTime)
|
||||
{
|
||||
Identifier layerIdentifier = msg.ReadIdentifier();
|
||||
|
||||
@@ -572,8 +572,9 @@ namespace Barotrauma
|
||||
Vector2 offset = decorativeSprite.GetOffset(ref offsetState, Vector2.Zero) * scale;
|
||||
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,
|
||||
rotationRad + rot, decorativeSprite.GetScale(0f) * scale, prefab.Sprite.effects,
|
||||
float throwAway = 0.0f;
|
||||
decorativeSprite.Sprite.Draw(spriteRecorder, new Vector2(spritePos.X + offset.X, -(spritePos.Y + offset.Y)), color, decorativeSprite.Sprite.Origin,
|
||||
rotationRad + rot, decorativeSprite.GetScale(ref throwAway, 0f) * scale, prefab.Sprite.effects,
|
||||
depth: Math.Min(depth + (decorativeSprite.Sprite.Depth - prefab.Sprite.Depth), 0.999f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Barotrauma
|
||||
|
||||
public override bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
return Screen.Selected == GameMain.SubEditorScreen || GameMain.DebugDraw;
|
||||
if (Screen.Selected != GameMain.SubEditorScreen && !GameMain.DebugDraw) { return false; }
|
||||
return base.IsVisible(worldView);
|
||||
}
|
||||
|
||||
public override bool SelectableInEditor
|
||||
@@ -92,6 +93,11 @@ namespace Barotrauma
|
||||
if (sprite != null)
|
||||
{
|
||||
float spriteScale = iconSize / (float)sprite.SourceRect.Width;
|
||||
if (Ladders == null && ConnectedDoor == null && ConnectedGap != null)
|
||||
{
|
||||
clr = Color.White;
|
||||
spriteScale *= 1.5f;
|
||||
}
|
||||
sprite.Draw(spriteBatch, drawPos, clr, origin: sprite.size / 2, scale: spriteScale, depth: 0.001f);
|
||||
sprite2?.Draw(spriteBatch, drawPos + sprite.size * spriteScale * 0.5f, clr, origin: sprite2.size / 2, scale: spriteScale, depth: 0.001f);
|
||||
}
|
||||
@@ -100,27 +106,39 @@ namespace Barotrauma
|
||||
{
|
||||
AssignedJob.Icon.Draw(spriteBatch, drawPos, AssignedJob.UIColor, scale: iconSize / (float)AssignedJob.Icon.SourceRect.Width * 0.8f, depth: 0.0f);
|
||||
}
|
||||
|
||||
foreach (MapEntity e in linkedTo)
|
||||
|
||||
// alternate line drawing for when cloning the waypoint: line goes from current position to original position, where moving started
|
||||
if (StartMovingPos != Vector2.Zero && SelectedList.Contains(this) && PlayerInput.IsCtrlDown())
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
|
||||
new Vector2(StartMovingPos.X, -StartMovingPos.Y),
|
||||
(IsTraversable ? GUIStyle.Green : Color.Gray) * 0.7f, width: 5, depth: 0.002f);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (MapEntity e in linkedTo)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
|
||||
(IsTraversable ? GUIStyle.Green : Color.Gray) * 0.7f, width: 5, depth: 0.002f);
|
||||
}
|
||||
}
|
||||
|
||||
if (ConnectedGap != null)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(ConnectedGap.DrawPosition.X, -ConnectedGap.DrawPosition.Y),
|
||||
GUIStyle.Green * 0.5f, width: 1);
|
||||
Color.White, width: 1);
|
||||
}
|
||||
if (Ladders != null)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
drawPos,
|
||||
new Vector2(Ladders.Item.DrawPosition.X, -Ladders.Item.DrawPosition.Y),
|
||||
GUIStyle.Green * 0.5f, width: 1);
|
||||
Color.White, width: 1);
|
||||
}
|
||||
|
||||
var color = Color.WhiteSmoke;
|
||||
@@ -419,6 +437,7 @@ namespace Barotrauma
|
||||
jobDropDown.AddItem(TextManager.Get("Any"), null);
|
||||
foreach (JobPrefab jobPrefab in JobPrefab.Prefabs)
|
||||
{
|
||||
if (jobPrefab.HiddenJob) { continue; }
|
||||
jobDropDown.AddItem(jobPrefab.Name, jobPrefab);
|
||||
}
|
||||
jobDropDown.SelectItem(AssignedJob);
|
||||
@@ -432,7 +451,7 @@ namespace Barotrauma
|
||||
};
|
||||
propertyBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
tags = text.Split(',').ToIdentifiers().ToHashSet();
|
||||
tags = text.ToIdentifiers().ToHashSet();
|
||||
return true;
|
||||
};
|
||||
propertyBox.OnEnterPressed += (textBox, text) =>
|
||||
|
||||
Reference in New Issue
Block a user