Vertical docking port, docking sounds, water flows properly between horizontally docked hulls, falseoutput of signal check components can be changed, lighting and FOW works between hulls (todo: some logic for determining when to update light.HullsInRange when two subs are moving relative to each other)

This commit is contained in:
Regalis
2016-06-27 17:48:20 +03:00
parent b04e204dc3
commit 38c5251005
19 changed files with 291 additions and 116 deletions
+12 -1
View File
@@ -375,7 +375,18 @@ namespace Barotrauma.Lights
Vector2 lightSourcePos = light.Position;
if (light.Submarine==null && parentEntity != null && parentEntity.Submarine != null) lightSourcePos -= parentEntity.Submarine.Position;
if (parentEntity != null && parentEntity.Submarine != null)
{
if (light.Submarine == null)
{
lightSourcePos -= parentEntity.Submarine.Position;
}
else if (light.Submarine != parentEntity.Submarine)
{
lightSourcePos += (light.Submarine.Position-parentEntity.Submarine.Position);
}
}
CachedShadow cachedShadow = null;
if (!cachedShadows.TryGetValue(light, out cachedShadow) ||
@@ -95,6 +95,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in lights)
{
if (light.Color.A < 0.01f || light.Range < 1.0f) continue;
//!!!!!!!!!!!!!!!!
if (light.hullsInRange == null) light.UpdateHullsInRange();
if (!light.hullsInRange.Any() || !MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
+12 -6
View File
@@ -86,7 +86,7 @@ namespace Barotrauma.Lights
{
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
if (Math.Abs(prevHullUpdateRange - range) < 5.0f) return;
if (Math.Abs(prevHullUpdateRange - range) < 10.0f) return;
UpdateHullsInRange();
prevHullUpdateRange = range;
@@ -143,18 +143,24 @@ namespace Barotrauma.Lights
foreach (ConvexHull ch in ConvexHull.list)
{
if (Submarine == null && ch.ParentEntity.Submarine != null)
Vector2 lightPos = position;
if (Submarine==null)
{
if (MathUtils.CircleIntersectsRectangle(position - ch.ParentEntity.Submarine.Position, range, ch.BoundingBox))
if (ch.ParentEntity.Submarine != null)
{
hullsInRange.Add(ch);
lightPos -= ch.ParentEntity.Submarine.Position;
}
}
else if (MathUtils.CircleIntersectsRectangle(position, range, ch.BoundingBox))
else if (ch.ParentEntity.Submarine != null && ch.ParentEntity.Submarine != Submarine)
{
lightPos -= (ch.ParentEntity.Submarine.Position - Submarine.Position);
}
if (MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox))
{
hullsInRange.Add(ch);
}
}
}