Unstable 0.16.0.0
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShowGaps;
|
||||
return ShowGaps && SubEditorScreen.IsLayerVisible(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!editing || !ShowGaps) { return; }
|
||||
if (!editing || !ShowGaps || !SubEditorScreen.IsLayerVisible(this)) { return; }
|
||||
|
||||
Color clr = (open == 0.0f) ? GUI.Style.Red : Color.Cyan;
|
||||
if (IsHighlighted) clr = Color.Gold;
|
||||
@@ -128,8 +128,14 @@ namespace Barotrauma
|
||||
{
|
||||
//no flow particles between linked hulls (= rooms consisting of multiple hulls)
|
||||
if (hull1.linkedTo.Contains(hull2)) { return; }
|
||||
if (hull1.linkedTo.Any(h => h.linkedTo.Contains(hull1) && h.linkedTo.Contains(hull2))) { return; }
|
||||
if (hull2.linkedTo.Any(h => h.linkedTo.Contains(hull1) && h.linkedTo.Contains(hull2))) { return; }
|
||||
foreach (Hull h in hull1.linkedTo)
|
||||
{
|
||||
if (h.linkedTo.Contains(hull1) && h.linkedTo.Contains(hull2)) { return; }
|
||||
}
|
||||
foreach (Hull h in hull2.linkedTo)
|
||||
{
|
||||
if (h.linkedTo.Contains(hull1) && h.linkedTo.Contains(hull2)) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 pos = Position;
|
||||
@@ -177,7 +183,7 @@ namespace Barotrauma
|
||||
"bubbles",
|
||||
(Submarine == null ? pos : pos + Submarine.Position),
|
||||
velocity, 0, flowTargetHull);
|
||||
|
||||
|
||||
particleTimer -= emitInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ namespace Barotrauma
|
||||
private readonly List<RemoteDecal> remoteDecals = new List<RemoteDecal>();
|
||||
|
||||
private readonly HashSet<Decal> pendingDecalUpdates = new HashSet<Decal>();
|
||||
|
||||
|
||||
private double lastAmbientLightEditTime;
|
||||
|
||||
public override bool SelectableInEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShowHulls;
|
||||
return ShowHulls && SubEditorScreen.IsLayerVisible(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,39 +133,41 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
if (!entity.linkedTo.Contains(this)) { entity.linkedTo.Add(this); }
|
||||
if (!linkedTo.Contains(this)) { linkedTo.Add(entity); }
|
||||
if (!linkedTo.Contains(this)) { linkedTo.Add(entity); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific(float deltaTime, Camera cam)
|
||||
{
|
||||
serverUpdateDelay -= deltaTime;
|
||||
if (serverUpdateDelay <= 0.0f)
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
ApplyRemoteState();
|
||||
}
|
||||
|
||||
if (networkUpdatePending)
|
||||
{
|
||||
networkUpdateTimer += deltaTime;
|
||||
if (networkUpdateTimer > 0.2f)
|
||||
serverUpdateDelay -= deltaTime;
|
||||
if (serverUpdateDelay <= 0.0f)
|
||||
{
|
||||
if (!pendingSectionUpdates.Any() && !pendingDecalUpdates.Any())
|
||||
ApplyRemoteState();
|
||||
}
|
||||
if (networkUpdatePending)
|
||||
{
|
||||
networkUpdateTimer += deltaTime;
|
||||
if (networkUpdateTimer > 0.2f)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this);
|
||||
if (!pendingSectionUpdates.Any() && !pendingDecalUpdates.Any())
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this);
|
||||
}
|
||||
foreach (Decal decal in pendingDecalUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { decal });
|
||||
}
|
||||
foreach (int pendingSectionUpdate in pendingSectionUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { pendingSectionUpdate });
|
||||
}
|
||||
pendingSectionUpdates.Clear();
|
||||
networkUpdatePending = false;
|
||||
networkUpdateTimer = 0.0f;
|
||||
}
|
||||
foreach (Decal decal in pendingDecalUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { decal });
|
||||
}
|
||||
foreach (int pendingSectionUpdate in pendingSectionUpdates)
|
||||
{
|
||||
GameMain.NetworkMember?.CreateEntityEvent(this, new object[] { pendingSectionUpdate });
|
||||
}
|
||||
pendingSectionUpdates.Clear();
|
||||
networkUpdatePending = false;
|
||||
networkUpdateTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +245,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ShowHulls && !GameMain.DebugDraw) { return; }
|
||||
if ((!ShowHulls || !SubEditorScreen.IsLayerVisible(this)) && !GameMain.DebugDraw) { return; }
|
||||
|
||||
if (!editing && (!GameMain.DebugDraw || Screen.Selected.Cam.Zoom < 0.1f)) { return; }
|
||||
|
||||
@@ -385,45 +387,42 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Vector3[] corners = new Vector3[6];
|
||||
private static readonly Vector2[] uvCoords = new Vector2[4];
|
||||
private static readonly Vector3[] prevCorners = new Vector3[2];
|
||||
private static readonly Vector2[] prevUVs = new Vector2[2];
|
||||
|
||||
private void UpdateVertices(Camera cam, EntityGrid entityGrid, WaterRenderer renderer)
|
||||
{
|
||||
Vector2 submarinePos = Submarine == null ? Vector2.Zero : Submarine.DrawPosition;
|
||||
|
||||
//if there's no more space in the buffer, don't render the water in the hull
|
||||
//not an ideal solution, but this seems to only happen in cases where the missing
|
||||
//not an ideal solution, but this seems to only happen in cases where the missing
|
||||
//water is not very noticeable (e.g. zoomed very far out so that multiple subs and ruins are visible)
|
||||
if (renderer.PositionInBuffer > renderer.vertices.Length - 6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!renderer.IndoorsVertices.ContainsKey(entityGrid))
|
||||
{
|
||||
renderer.IndoorsVertices[entityGrid] = new VertexPositionColorTexture[WaterRenderer.DefaultIndoorsBufferSize];
|
||||
renderer.PositionInIndoorsBuffer[entityGrid] = 0;
|
||||
}
|
||||
|
||||
//calculate where the surface should be based on the water volume
|
||||
float top = rect.Y + submarinePos.Y;
|
||||
float bottom = top - rect.Height;
|
||||
float renderSurface = drawSurface + submarinePos.Y;
|
||||
|
||||
if (bottom > cam.WorldView.Y || top < cam.WorldView.Y - cam.WorldView.Height) return;
|
||||
if (bottom > cam.WorldView.Y || top < cam.WorldView.Y - cam.WorldView.Height) { return; }
|
||||
if (rect.X + submarinePos.X > cam.WorldView.Right || rect.Right + submarinePos.X < cam.WorldView.X) { return; }
|
||||
|
||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
if (!update)
|
||||
{
|
||||
// create the four corners of our triangle.
|
||||
|
||||
Vector3[] corners = new Vector3[4];
|
||||
|
||||
corners[0] = new Vector3(rect.X, rect.Y, 0.0f);
|
||||
corners[1] = new Vector3(rect.X + rect.Width, rect.Y, 0.0f);
|
||||
|
||||
corners[2] = new Vector3(corners[1].X, rect.Y - rect.Height, 0.0f);
|
||||
corners[3] = new Vector3(corners[0].X, corners[2].Y, 0.0f);
|
||||
|
||||
Vector2[] uvCoords = new Vector2[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
corners[i] += new Vector3(submarinePos, 0.0f);
|
||||
@@ -443,6 +442,15 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (!renderer.IndoorsVertices.ContainsKey(entityGrid))
|
||||
{
|
||||
renderer.IndoorsVertices[entityGrid] = new VertexPositionColorTexture[WaterRenderer.DefaultIndoorsBufferSize];
|
||||
}
|
||||
if (!renderer.PositionInIndoorsBuffer.ContainsKey(entityGrid))
|
||||
{
|
||||
renderer.PositionInIndoorsBuffer[entityGrid] = 0;
|
||||
}
|
||||
|
||||
float x = rect.X;
|
||||
if (Submarine != null) { x += Submarine.DrawPosition.X; }
|
||||
|
||||
@@ -454,20 +462,15 @@ namespace Barotrauma
|
||||
|
||||
x += start * WaveWidth;
|
||||
|
||||
Vector3[] prevCorners = new Vector3[2];
|
||||
Vector2[] prevUVs = new Vector2[2];
|
||||
|
||||
int width = WaveWidth;
|
||||
|
||||
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
Vector3[] corners = new Vector3[6];
|
||||
|
||||
//top left
|
||||
corners[0] = new Vector3(x, top, 0.0f);
|
||||
//watersurface left
|
||||
corners[3] = new Vector3(corners[0].X, renderSurface + waveY[i], 0.0f);
|
||||
|
||||
|
||||
//top right
|
||||
corners[1] = new Vector3(x + width, top, 0.0f);
|
||||
//watersurface right
|
||||
@@ -477,7 +480,7 @@ namespace Barotrauma
|
||||
corners[4] = new Vector3(x, bottom, 0.0f);
|
||||
//bottom right
|
||||
corners[5] = new Vector3(x + width, bottom, 0.0f);
|
||||
|
||||
|
||||
Vector2[] uvCoords = new Vector2[4];
|
||||
for (int n = 0; n < 4; n++)
|
||||
{
|
||||
@@ -714,7 +717,7 @@ namespace Barotrauma
|
||||
}
|
||||
remoteBackgroundSections.Clear();
|
||||
|
||||
if (remoteDecals.Any())
|
||||
if (remoteDecals.Count > 0)
|
||||
{
|
||||
decals.Clear();
|
||||
foreach (RemoteDecal remoteDecal in remoteDecals)
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
||||
public readonly WaterVertexData IndoorsSurfaceBottomColor = new WaterVertexData(0.2f, 0.1f, 0.9f, 1.0f);
|
||||
|
||||
public VertexPositionTexture[] vertices = new VertexPositionTexture[DefaultBufferSize];
|
||||
public Dictionary<EntityGrid, VertexPositionColorTexture[]> IndoorsVertices = new Dictionary<EntityGrid, VertexPositionColorTexture[]>();// VertexPositionColorTexture[DefaultBufferSize * 2];
|
||||
public Dictionary<EntityGrid, VertexPositionColorTexture[]> IndoorsVertices = new Dictionary<EntityGrid, VertexPositionColorTexture[]>();
|
||||
|
||||
public Effect WaterEffect
|
||||
{
|
||||
@@ -81,13 +81,17 @@ namespace Barotrauma
|
||||
|
||||
if (basicEffect == null)
|
||||
{
|
||||
basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
|
||||
basicEffect.TextureEnabled = true;
|
||||
basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
|
||||
{
|
||||
VertexColorEnabled = false,
|
||||
TextureEnabled = true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private readonly VertexPositionColorTexture[] tempVertices = new VertexPositionColorTexture[6];
|
||||
private readonly Vector3[] tempCorners = new Vector3[4];
|
||||
|
||||
public void RenderWater(SpriteBatch spriteBatch, RenderTarget2D texture, Camera cam)
|
||||
{
|
||||
spriteBatch.GraphicsDevice.BlendState = BlendState.NonPremultiplied;
|
||||
@@ -139,29 +143,26 @@ namespace Barotrauma
|
||||
|
||||
WaterEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
VertexPositionColorTexture[] verts = new VertexPositionColorTexture[6];
|
||||
|
||||
Rectangle view = cam != null ? cam.WorldView : spriteBatch.GraphicsDevice.Viewport.Bounds;
|
||||
|
||||
var corners = new Vector3[4];
|
||||
corners[0] = new Vector3(view.X, view.Y, 0.1f);
|
||||
corners[1] = new Vector3(view.Right, view.Y, 0.1f);
|
||||
corners[2] = new Vector3(view.Right, view.Y - view.Height, 0.1f);
|
||||
corners[3] = new Vector3(view.X, view.Y - view.Height, 0.1f);
|
||||
tempCorners[0] = new Vector3(view.X, view.Y, 0.1f);
|
||||
tempCorners[1] = new Vector3(view.Right, view.Y, 0.1f);
|
||||
tempCorners[2] = new Vector3(view.Right, view.Y - view.Height, 0.1f);
|
||||
tempCorners[3] = new Vector3(view.X, view.Y - view.Height, 0.1f);
|
||||
|
||||
WaterVertexData backGroundColor = new WaterVertexData(0.1f, 0.1f, 0.5f, 1.0f);
|
||||
verts[0] = new VertexPositionColorTexture(corners[0], backGroundColor, Vector2.Zero);
|
||||
verts[1] = new VertexPositionColorTexture(corners[1], backGroundColor, Vector2.Zero);
|
||||
verts[2] = new VertexPositionColorTexture(corners[2], backGroundColor, Vector2.Zero);
|
||||
verts[3] = new VertexPositionColorTexture(corners[0], backGroundColor, Vector2.Zero);
|
||||
verts[4] = new VertexPositionColorTexture(corners[2], backGroundColor, Vector2.Zero);
|
||||
verts[5] = new VertexPositionColorTexture(corners[3], backGroundColor, Vector2.Zero);
|
||||
tempVertices[0] = new VertexPositionColorTexture(tempCorners[0], backGroundColor, Vector2.Zero);
|
||||
tempVertices[1] = new VertexPositionColorTexture(tempCorners[1], backGroundColor, Vector2.Zero);
|
||||
tempVertices[2] = new VertexPositionColorTexture(tempCorners[2], backGroundColor, Vector2.Zero);
|
||||
tempVertices[3] = new VertexPositionColorTexture(tempCorners[0], backGroundColor, Vector2.Zero);
|
||||
tempVertices[4] = new VertexPositionColorTexture(tempCorners[2], backGroundColor, Vector2.Zero);
|
||||
tempVertices[5] = new VertexPositionColorTexture(tempCorners[3], backGroundColor, Vector2.Zero);
|
||||
|
||||
spriteBatch.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, verts, 0, 2);
|
||||
spriteBatch.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, tempVertices, 0, 2);
|
||||
|
||||
foreach (KeyValuePair<EntityGrid, VertexPositionColorTexture[]> subVerts in IndoorsVertices)
|
||||
{
|
||||
if (!PositionInIndoorsBuffer.ContainsKey(subVerts.Key) || PositionInIndoorsBuffer[subVerts.Key] == 0) continue;
|
||||
if (!PositionInIndoorsBuffer.ContainsKey(subVerts.Key) || PositionInIndoorsBuffer[subVerts.Key] == 0) { continue; }
|
||||
|
||||
offset = WavePos;
|
||||
if (subVerts.Key.Submarine != null) { offset -= subVerts.Key.Submarine.WorldPosition; }
|
||||
@@ -207,11 +208,23 @@ namespace Barotrauma
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
}
|
||||
|
||||
private readonly List<EntityGrid> buffersToRemove = new List<EntityGrid>();
|
||||
public void ResetBuffers()
|
||||
{
|
||||
PositionInBuffer = 0;
|
||||
PositionInIndoorsBuffer.Clear();
|
||||
IndoorsVertices.Clear();
|
||||
buffersToRemove.Clear();
|
||||
foreach (var buffer in IndoorsVertices.Keys)
|
||||
{
|
||||
if (buffer.Submarine?.Removed ?? false)
|
||||
{
|
||||
buffersToRemove.Add(buffer);
|
||||
}
|
||||
}
|
||||
foreach (var bufferToRemove in buffersToRemove)
|
||||
{
|
||||
IndoorsVertices.Remove(bufferToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -517,7 +517,7 @@ namespace Barotrauma.Lights
|
||||
private void RefreshConvexHullList(ConvexHullList chList, Vector2 lightPos, Submarine sub)
|
||||
{
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
if (fullChList == null) return;
|
||||
if (fullChList == null) { return; }
|
||||
|
||||
chList.List = fullChList.List.FindAll(ch => ch.Enabled && MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, ch.BoundingBox));
|
||||
|
||||
@@ -530,105 +530,121 @@ namespace Barotrauma.Lights
|
||||
/// </summary>
|
||||
private void CheckHullsInRange()
|
||||
{
|
||||
List<Submarine> subs = new List<Submarine>(Submarine.Loaded);
|
||||
subs.Add(null);
|
||||
|
||||
foreach (Submarine sub in subs)
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
//find the list of convexhulls that belong to the sub
|
||||
var chList = hullsInRange.Find(x => x.Submarine == sub);
|
||||
CheckHullsInRange(sub);
|
||||
}
|
||||
//check convex hulls that aren't in any sub
|
||||
CheckHullsInRange(null);
|
||||
}
|
||||
|
||||
//not found -> create one
|
||||
if (chList == null)
|
||||
private void CheckHullsInRange(Submarine sub)
|
||||
{
|
||||
//find the list of convexhulls that belong to the sub
|
||||
ConvexHullList chList = null;
|
||||
foreach (var ch in hullsInRange)
|
||||
{
|
||||
if (ch.Submarine == sub)
|
||||
{
|
||||
chList = new ConvexHullList(sub);
|
||||
hullsInRange.Add(chList);
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
|
||||
if (chList.List.Any(ch => ch.LastVertexChangeTime > lastRecalculationTime && !chList.IsHidden.Contains(ch)))
|
||||
{
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
|
||||
Vector2 lightPos = position;
|
||||
if (ParentSub == null)
|
||||
{
|
||||
//light and the convexhulls are both outside
|
||||
if (sub == null)
|
||||
{
|
||||
if (NeedsHullCheck)
|
||||
{
|
||||
RefreshConvexHullList(chList, lightPos, null);
|
||||
}
|
||||
}
|
||||
//light is outside, convexhulls inside a sub
|
||||
else
|
||||
{
|
||||
lightPos -= sub.Position;
|
||||
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Point(0, sub.Borders.Height);
|
||||
|
||||
//only draw if the light overlaps with the sub
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, subBorders))
|
||||
{
|
||||
if (chList.List.Count > 0) NeedsRecalculation = true;
|
||||
chList.List.Clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//light is inside, convexhull outside
|
||||
if (sub == null) continue;
|
||||
|
||||
//light and convexhull are both inside the same sub
|
||||
if (sub == ParentSub)
|
||||
{
|
||||
if (NeedsHullCheck)
|
||||
{
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
}
|
||||
//light and convexhull are inside different subs
|
||||
else
|
||||
{
|
||||
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullCheck) continue;
|
||||
|
||||
lightPos -= (sub.Position - ParentSub.Position);
|
||||
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Point(0, sub.Borders.Height);
|
||||
|
||||
//don't draw any shadows if the light doesn't overlap with the borders of the sub
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, subBorders))
|
||||
{
|
||||
if (chList.List.Count > 0) NeedsRecalculation = true;
|
||||
chList.List.Clear();
|
||||
continue;
|
||||
}
|
||||
|
||||
//recalculate vertices if the subs have moved > 5 px relative to each other
|
||||
Vector2 diff = ParentSub.WorldPosition - sub.WorldPosition;
|
||||
if (!diffToSub.TryGetValue(sub, out Vector2 prevDiff))
|
||||
{
|
||||
diffToSub.Add(sub, diff);
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
else if (Vector2.DistanceSquared(diff, prevDiff) > 5.0f * 5.0f)
|
||||
{
|
||||
diffToSub[sub] = diff;
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
chList = ch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//not found -> create one
|
||||
if (chList == null)
|
||||
{
|
||||
chList = new ConvexHullList(sub);
|
||||
hullsInRange.Add(chList);
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
|
||||
foreach (var ch in chList.List)
|
||||
{
|
||||
if (ch.LastVertexChangeTime > lastRecalculationTime && !chList.IsHidden.Contains(ch))
|
||||
{
|
||||
NeedsRecalculation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 lightPos = position;
|
||||
if (ParentSub == null)
|
||||
{
|
||||
//light and the convexhulls are both outside
|
||||
if (sub == null)
|
||||
{
|
||||
if (NeedsHullCheck)
|
||||
{
|
||||
RefreshConvexHullList(chList, lightPos, null);
|
||||
}
|
||||
}
|
||||
//light is outside, convexhulls inside a sub
|
||||
else
|
||||
{
|
||||
lightPos -= sub.Position;
|
||||
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Point(0, sub.Borders.Height);
|
||||
|
||||
//only draw if the light overlaps with the sub
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, subBorders))
|
||||
{
|
||||
if (chList.List.Count > 0) { NeedsRecalculation = true; }
|
||||
chList.List.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//light is inside, convexhull outside
|
||||
if (sub == null) { return; }
|
||||
|
||||
//light and convexhull are both inside the same sub
|
||||
if (sub == ParentSub)
|
||||
{
|
||||
if (NeedsHullCheck)
|
||||
{
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
}
|
||||
//light and convexhull are inside different subs
|
||||
else
|
||||
{
|
||||
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullCheck) { return; }
|
||||
|
||||
lightPos -= (sub.Position - ParentSub.Position);
|
||||
|
||||
Rectangle subBorders = sub.Borders;
|
||||
subBorders.Location += sub.HiddenSubPosition.ToPoint() - new Point(0, sub.Borders.Height);
|
||||
|
||||
//don't draw any shadows if the light doesn't overlap with the borders of the sub
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, subBorders))
|
||||
{
|
||||
if (chList.List.Count > 0) { NeedsRecalculation = true; }
|
||||
chList.List.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
//recalculate vertices if the subs have moved > 5 px relative to each other
|
||||
Vector2 diff = ParentSub.WorldPosition - sub.WorldPosition;
|
||||
if (!diffToSub.TryGetValue(sub, out Vector2 prevDiff))
|
||||
{
|
||||
diffToSub.Add(sub, diff);
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
else if (Vector2.DistanceSquared(diff, prevDiff) > 5.0f * 5.0f)
|
||||
{
|
||||
diffToSub[sub] = diff;
|
||||
NeedsRecalculation = true;
|
||||
}
|
||||
|
||||
RefreshConvexHullList(chList, lightPos, sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Vector2> FindRaycastHits()
|
||||
|
||||
@@ -75,10 +75,12 @@ namespace Barotrauma
|
||||
if (linkedTo.Contains(entity))
|
||||
{
|
||||
linkedTo.Remove(entity);
|
||||
entity.linkedTo.Remove(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedTo.Add(entity);
|
||||
if (!entity.linkedTo.Contains(this)) { entity.linkedTo.Add(this); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace Barotrauma
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SubEditorScreen.IsLayerVisible(this)) { return false; }
|
||||
|
||||
return HasBody ? ShowWalls : ShowStructures;
|
||||
}
|
||||
}
|
||||
@@ -244,8 +247,10 @@ namespace Barotrauma
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (prefab.sprite == null) { return; }
|
||||
|
||||
if (editing)
|
||||
{
|
||||
if (!SubEditorScreen.IsLayerVisible(this)) { return; }
|
||||
if (!HasBody && !ShowStructures) { return; }
|
||||
if (HasBody && !ShowWalls) { return; }
|
||||
}
|
||||
@@ -273,6 +278,7 @@ namespace Barotrauma
|
||||
if (prefab.sprite == null) { return; }
|
||||
if (editing)
|
||||
{
|
||||
if (!SubEditorScreen.IsLayerVisible(this)) { return; }
|
||||
if (!HasBody && !ShowStructures) { return; }
|
||||
if (HasBody && !ShowWalls) { return; }
|
||||
}
|
||||
@@ -285,13 +291,11 @@ namespace Barotrauma
|
||||
//color = Color.Lerp(color, Color.Gold, 0.5f);
|
||||
color = spriteColor;
|
||||
|
||||
|
||||
|
||||
Vector2 rectSize = rect.Size.ToVector2();
|
||||
if (BodyWidth > 0.0f) { rectSize.X = BodyWidth; }
|
||||
if (BodyHeight > 0.0f) { rectSize.Y = BodyHeight; }
|
||||
|
||||
Vector2 bodyPos = WorldPosition + BodyOffset;
|
||||
Vector2 bodyPos = WorldPosition + BodyOffset * Scale;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(bodyPos.X, -bodyPos.Y), rectSize.X, rectSize.Y, BodyRotation, Color.White,
|
||||
thickness: Math.Max(1, (int)(2 / Screen.Selected.Cam.Zoom)));
|
||||
@@ -465,7 +469,8 @@ namespace Barotrauma
|
||||
|
||||
public void UpdateSpriteStates(float deltaTime)
|
||||
{
|
||||
DecorativeSprite.UpdateSpriteStates(Prefab.DecorativeSpriteGroups, spriteAnimState, ID, deltaTime, ConditionalMatches);
|
||||
if (Prefab.DecorativeSpriteGroups.Count == 0) { return; }
|
||||
DecorativeSprite.UpdateSpriteStates(Prefab.DecorativeSpriteGroups, spriteAnimState, ID, deltaTime, ConditionalMatches);
|
||||
foreach (int spriteGroup in Prefab.DecorativeSpriteGroups.Keys)
|
||||
{
|
||||
for (int i = 0; i < Prefab.DecorativeSpriteGroups[spriteGroup].Count; i++)
|
||||
|
||||
@@ -25,14 +25,11 @@ namespace Barotrauma
|
||||
public readonly bool Stream;
|
||||
public readonly bool IgnoreMuffling;
|
||||
|
||||
|
||||
public string Filename
|
||||
{
|
||||
get { return Sound?.Filename; }
|
||||
}
|
||||
public readonly string Filename;
|
||||
|
||||
public RoundSound(XElement element, Sound sound)
|
||||
{
|
||||
Filename = sound?.Filename;
|
||||
Sound = sound;
|
||||
Stream = sound.Stream;
|
||||
Range = element.GetAttributeFloat("range", 1000.0f);
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace Barotrauma
|
||||
|
||||
private bool IsHidden()
|
||||
{
|
||||
if (!SubEditorScreen.IsLayerVisible(this)) { return false; }
|
||||
if (spawnType == SpawnType.Path)
|
||||
{
|
||||
return (!GameMain.DebugDraw && !ShowWayPoints);
|
||||
@@ -294,7 +295,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), TextManager.Get("Spawnpoint"), font: GUI.LargeFont);
|
||||
|
||||
|
||||
var spawnTypeContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -318,7 +319,10 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var descText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("IDCardDescription"), font: GUI.SmallFont);
|
||||
TextManager.Get("IDCardDescription"), font: GUI.SmallFont)
|
||||
{
|
||||
ToolTip = TextManager.Get("IDCardDescriptionTooltip")
|
||||
};
|
||||
GUITextBox propertyBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), descText.RectTransform, Anchor.CenterRight), IdCardDesc)
|
||||
{
|
||||
MaxTextLength = 150,
|
||||
@@ -342,7 +346,10 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var idCardTagsText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform),
|
||||
TextManager.Get("IDCardTags"), font: GUI.SmallFont);
|
||||
TextManager.Get("IDCardTags"), font: GUI.SmallFont)
|
||||
{
|
||||
ToolTip = TextManager.Get("IDCardTagsTooltip")
|
||||
};
|
||||
propertyBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), idCardTagsText.RectTransform, Anchor.CenterRight), string.Join(", ", idCardTags))
|
||||
{
|
||||
MaxTextLength = 60,
|
||||
@@ -414,6 +421,6 @@ namespace Barotrauma
|
||||
PositionEditingHUD();
|
||||
|
||||
return editingHUD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user