Unstable 0.1400.7.0 (Coronavirus edition)
This commit is contained in:
@@ -101,7 +101,7 @@ namespace Barotrauma
|
||||
return editingHUD;
|
||||
}
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
public override void UpdateEditing(Camera cam, float deltaTime)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData as Hull != this)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,14 @@ namespace Barotrauma
|
||||
|
||||
public LevelWallVertexBuffer(VertexPositionTexture[] wallVertices, VertexPositionTexture[] wallEdgeVertices, Texture2D wallTexture, Texture2D edgeTexture, Color color)
|
||||
{
|
||||
if (wallVertices.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Failed to instantiate a LevelWallVertexBuffer (no wall vertices).");
|
||||
}
|
||||
if (wallVertices.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Failed to instantiate a LevelWallVertexBuffer (no wall edge vertices).");
|
||||
}
|
||||
this.wallVertices = LevelRenderer.GetColoredVertices(wallVertices, color);
|
||||
WallBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, wallVertices.Length, BufferUsage.WriteOnly);
|
||||
WallBuffer.SetData(this.wallVertices);
|
||||
|
||||
@@ -617,14 +617,10 @@ namespace Barotrauma.Lights
|
||||
|
||||
private List<Vector2> FindRaycastHits()
|
||||
{
|
||||
if (!CastShadows)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (Range < 1.0f || Color.A < 1) { return null; }
|
||||
if (!CastShadows || Range < 1.0f || Color.A < 1) { return null; }
|
||||
|
||||
Vector2 drawPos = position;
|
||||
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
|
||||
if (ParentSub != null) { drawPos += ParentSub.DrawPosition; }
|
||||
|
||||
var hulls = new List<ConvexHull>();
|
||||
foreach (ConvexHullList chList in hullsInRange)
|
||||
@@ -826,13 +822,13 @@ namespace Barotrauma.Lights
|
||||
Vector2 dirNormal = new Vector2(-dir.Y, dir.X) * 3;
|
||||
|
||||
//do two slightly offset raycasts to hit the segment itself and whatever's behind it
|
||||
Pair<int,Vector2> intersection1 = RayCast(drawPos, drawPos + dir * boundsExtended * 2 - dirNormal, visibleSegments);
|
||||
Pair<int,Vector2> intersection2 = RayCast(drawPos, drawPos + dir * boundsExtended * 2 + dirNormal, visibleSegments);
|
||||
var intersection1 = RayCast(drawPos, drawPos + dir * boundsExtended * 2 - dirNormal, visibleSegments);
|
||||
var intersection2 = RayCast(drawPos, drawPos + dir * boundsExtended * 2 + dirNormal, visibleSegments);
|
||||
|
||||
if (intersection1.First < 0) return null;
|
||||
if (intersection2.First < 0) return null;
|
||||
Segment seg1 = visibleSegments[intersection1.First];
|
||||
Segment seg2 = visibleSegments[intersection2.First];
|
||||
if (intersection1.index < 0) return null;
|
||||
if (intersection2.index < 0) return null;
|
||||
Segment seg1 = visibleSegments[intersection1.index];
|
||||
Segment seg2 = visibleSegments[intersection2.index];
|
||||
|
||||
bool isPoint1 = MathUtils.LineToPointDistanceSquared(seg1.Start.WorldPos, seg1.End.WorldPos, p.WorldPos) < 25.0f;
|
||||
bool isPoint2 = MathUtils.LineToPointDistanceSquared(seg2.Start.WorldPos, seg2.End.WorldPos, p.WorldPos) < 25.0f;
|
||||
@@ -849,12 +845,12 @@ namespace Barotrauma.Lights
|
||||
hullList.IsHidden.Remove(seg2.ConvexHull);
|
||||
}
|
||||
}
|
||||
else if (intersection1.First != intersection2.First)
|
||||
else if (intersection1.index != intersection2.index)
|
||||
{
|
||||
//the raycasts landed on different segments
|
||||
//we definitely want to generate new geometry here
|
||||
output.Add(isPoint1 ? p.WorldPos : intersection1.Second);
|
||||
output.Add(isPoint2 ? p.WorldPos : intersection2.Second);
|
||||
output.Add(isPoint1 ? p.WorldPos : intersection1.pos);
|
||||
output.Add(isPoint2 ? p.WorldPos : intersection2.pos);
|
||||
|
||||
foreach (ConvexHullList hullList in hullsInRange)
|
||||
{
|
||||
@@ -884,7 +880,7 @@ namespace Barotrauma.Lights
|
||||
return output;
|
||||
}
|
||||
|
||||
private Pair<int, Vector2> RayCast(Vector2 rayStart, Vector2 rayEnd, List<Segment> segments)
|
||||
private (int index, Vector2 pos) RayCast(Vector2 rayStart, Vector2 rayEnd, List<Segment> segments)
|
||||
{
|
||||
Vector2? closestIntersection = null;
|
||||
int segment = -1;
|
||||
@@ -943,8 +939,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
}
|
||||
|
||||
Pair<int, Vector2> retVal = new Pair<int, Vector2>(segment, closestIntersection == null ? rayEnd : (Vector2)closestIntersection);
|
||||
return retVal;
|
||||
return (segment, closestIntersection == null ? rayEnd : (Vector2)closestIntersection);
|
||||
}
|
||||
|
||||
|
||||
@@ -1281,11 +1276,6 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (Range < 1.0f || Color.A < 1 || CurrentBrightness <= 0.0f) { return; }
|
||||
|
||||
if (CastShadows)
|
||||
{
|
||||
CheckHullsInRange();
|
||||
}
|
||||
|
||||
//if the light doesn't cast shadows, we can simply render the texture without having to calculate the light volume
|
||||
if (!CastShadows)
|
||||
{
|
||||
@@ -1298,16 +1288,27 @@ namespace Barotrauma.Lights
|
||||
float scale = Range / (currentTexture.Width / 2.0f);
|
||||
|
||||
Vector2 drawPos = position;
|
||||
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
|
||||
if (ParentSub != null) { drawPos += ParentSub.DrawPosition; }
|
||||
drawPos.Y = -drawPos.Y;
|
||||
|
||||
spriteBatch.Draw(currentTexture, drawPos, null, Color.Multiply(CurrentBrightness), -rotation, center, scale, SpriteEffects.None, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
CheckHullsInRange();
|
||||
|
||||
if (NeedsRecalculation)
|
||||
{
|
||||
var verts = FindRaycastHits();
|
||||
if (verts == null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError($"Failed to generate vertices for a light source. Range: {Range}, color: {Color}, brightness: {CurrentBrightness}, parent: {ParentBody?.UserData ?? "Unknown"}");
|
||||
#endif
|
||||
Enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
CalculateLightVertices(verts);
|
||||
|
||||
lastRecalculationTime = (float)Timing.TotalTime;
|
||||
|
||||
@@ -55,23 +55,23 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch, pos + Vector2.UnitX * 50.0f, pos - Vector2.UnitX * 50.0f, color * alpha, 0.0f, 5);
|
||||
}
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
public override void UpdateEditing(Camera cam, float deltaTime)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData as LinkedSubmarine != this)
|
||||
{
|
||||
editingHUD = CreateEditingHUD();
|
||||
}
|
||||
|
||||
editingHUD.UpdateManually((float)Timing.Step);
|
||||
editingHUD.UpdateManually(deltaTime);
|
||||
|
||||
if (!PlayerInput.PrimaryMouseButtonClicked() || !PlayerInput.KeyDown(Keys.Space)) return;
|
||||
if (!PlayerInput.PrimaryMouseButtonClicked() || !PlayerInput.KeyDown(Keys.Space)) { return; }
|
||||
|
||||
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
|
||||
foreach (MapEntity entity in mapEntityList)
|
||||
{
|
||||
if (entity == this || !entity.IsHighlighted || !(entity is Item) || !entity.IsMouseOn(position)) continue;
|
||||
if (((Item)entity).GetComponent<DockingPort>() == null) continue;
|
||||
if (entity == this || !entity.IsHighlighted || !(entity is Item) || !entity.IsMouseOn(position)) { continue; }
|
||||
if (((Item)entity).GetComponent<DockingPort>() == null) { continue; }
|
||||
if (linkedTo.Contains(entity))
|
||||
{
|
||||
linkedTo.Remove(entity);
|
||||
|
||||
@@ -838,9 +838,9 @@ namespace Barotrauma
|
||||
|
||||
public static List<MapEntity> FilteredSelectedList { get; private set; } = new List<MapEntity>();
|
||||
|
||||
public static void UpdateEditor(Camera cam)
|
||||
public static void UpdateEditor(Camera cam, float deltaTime)
|
||||
{
|
||||
if (highlightedListBox != null) highlightedListBox.UpdateManually((float)Timing.Step);
|
||||
if (highlightedListBox != null) { highlightedListBox.UpdateManually(deltaTime); }
|
||||
|
||||
if (editingHUD != null)
|
||||
{
|
||||
@@ -865,7 +865,7 @@ namespace Barotrauma
|
||||
var first = FilteredSelectedList.FirstOrDefault();
|
||||
if (first != null)
|
||||
{
|
||||
first.UpdateEditing(cam);
|
||||
first.UpdateEditing(cam, deltaTime);
|
||||
if (first.ResizeHorizontal || first.ResizeVertical)
|
||||
{
|
||||
first.UpdateResizing(cam);
|
||||
@@ -1017,7 +1017,7 @@ namespace Barotrauma
|
||||
if (editingHUD != null && editingHUD.UserData == this) editingHUD.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public virtual void UpdateEditing(Camera cam) { }
|
||||
public virtual void UpdateEditing(Camera cam, float deltaTime) { }
|
||||
|
||||
protected static void PositionEditingHUD()
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
||||
convexHulls.Add(h);
|
||||
}
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
public override void UpdateEditing(Camera cam, float deltaTime)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData as Structure != this)
|
||||
{
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string,HullCollection> hullCollections;
|
||||
private List<Door> doors;
|
||||
private readonly Dictionary<string, HullCollection> hullCollections;
|
||||
private readonly List<Door> doors;
|
||||
|
||||
|
||||
private static SubmarinePreview instance = null;
|
||||
@@ -104,7 +104,7 @@ namespace Barotrauma
|
||||
(spriteBatch, component) => {
|
||||
camera.UpdateTransform(interpolate: true, updateListener: false);
|
||||
Rectangle drawRect = new Rectangle(component.Rect.X + 1, component.Rect.Y + 1, component.Rect.Width - 2, component.Rect.Height - 2);
|
||||
RenderSubmarine(spriteBatch, drawRect);
|
||||
RenderSubmarine(spriteBatch, drawRect, component);
|
||||
},
|
||||
(deltaTime, component) => {
|
||||
bool isMouseOnComponent = GUI.MouseOn == component;
|
||||
@@ -121,6 +121,10 @@ namespace Barotrauma
|
||||
{
|
||||
specsContainer.Visible = GUI.IsMouseOn(titleText);
|
||||
}
|
||||
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape))
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
});
|
||||
|
||||
var topContainer = new GUIFrame(new RectTransform(new Vector2(1f, 0.07f), innerPadded.RectTransform, Anchor.TopLeft), style: null)
|
||||
@@ -225,6 +229,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (var subElement in submarineInfo.SubmarineElement.Elements())
|
||||
{
|
||||
if (subElement.GetAttributeBool("hiddeningame", false)) { continue; }
|
||||
switch (subElement.Name.LocalName.ToLowerInvariant())
|
||||
{
|
||||
case "item":
|
||||
@@ -240,8 +245,7 @@ namespace Barotrauma
|
||||
string identifier = subElement.GetAttributeString("roomname", "").ToLowerInvariant();
|
||||
if (!string.IsNullOrEmpty(identifier))
|
||||
{
|
||||
HullCollection hullCollection = null;
|
||||
if (!hullCollections.TryGetValue(identifier, out hullCollection))
|
||||
if (!hullCollections.TryGetValue(identifier, out HullCollection hullCollection))
|
||||
{
|
||||
hullCollection = new HullCollection(identifier);
|
||||
hullCollections.Add(identifier, hullCollection);
|
||||
@@ -476,12 +480,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var transformedBarrelPos = MathUtils.RotatePointAroundTarget(
|
||||
subElement.GetAttributeVector2("barrelpos", Vector2.Zero) * scale,
|
||||
new Vector2(rect.Width / 2, rect.Height / 2),
|
||||
Vector2 barrelPos = subElement.GetAttributeVector2("barrelpos", Vector2.Zero);
|
||||
Vector2 relativeBarrelPos = barrelPos * prefab.Scale - new Vector2(rect.Width / 2, rect.Height / 2);
|
||||
var transformedBarrelPos = MathUtils.RotatePoint(
|
||||
relativeBarrelPos,
|
||||
MathHelper.ToRadians(rotation));
|
||||
|
||||
Vector2 drawPos = new Vector2(rect.X + transformedBarrelPos.X, rect.Y - transformedBarrelPos.Y);
|
||||
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;
|
||||
|
||||
railSprite?.Draw(spriteRecorder,
|
||||
@@ -491,7 +497,7 @@ namespace Barotrauma
|
||||
SpriteEffects.None, depth + (railSprite.Depth - prefab.sprite.Depth));
|
||||
|
||||
barrelSprite?.Draw(spriteRecorder,
|
||||
drawPos - new Vector2((float)Math.Cos(MathHelper.ToRadians(rotation)), (float)Math.Sin(MathHelper.ToRadians(rotation))) * scale,
|
||||
drawPos,
|
||||
color,
|
||||
rotation + MathHelper.PiOver2, scale,
|
||||
SpriteEffects.None, depth + (barrelSprite.Depth - prefab.sprite.Depth));
|
||||
@@ -564,7 +570,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderSubmarine(SpriteBatch spriteBatch, Rectangle scissorRectangle)
|
||||
private void RenderSubmarine(SpriteBatch spriteBatch, Rectangle scissorRectangle, GUIComponent component)
|
||||
{
|
||||
if (spriteRecorder == null) { return; }
|
||||
|
||||
@@ -605,11 +611,13 @@ namespace Barotrauma
|
||||
foreach (var hullCollection in hullCollections.Values)
|
||||
{
|
||||
bool mouseOver = false;
|
||||
|
||||
foreach (var rect in hullCollection.Rects)
|
||||
if (GUI.MouseOn == null || GUI.MouseOn == component)
|
||||
{
|
||||
mouseOver = rect.Contains(mousePos);
|
||||
if (mouseOver) { break; }
|
||||
foreach (var rect in hullCollection.Rects)
|
||||
{
|
||||
mouseOver = rect.Contains(mousePos);
|
||||
if (mouseOver) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var rect in hullCollection.Rects)
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
public override void UpdateEditing(Camera cam, float deltaTime)
|
||||
{
|
||||
if (editingHUD == null || editingHUD.UserData != this)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user