Merge branch 'master' into new-netcode
Conflicts: Subsurface/Source/Events/MonsterEvent.cs
This commit is contained in:
@@ -40,6 +40,8 @@ namespace Barotrauma.Lights
|
||||
//when were the vertices of the light volume last calculated
|
||||
private float lastRecalculationTime;
|
||||
|
||||
private Dictionary<Submarine, Vector2> diffToSub;
|
||||
|
||||
private DynamicVertexBuffer lightVolumeBuffer;
|
||||
private DynamicIndexBuffer lightVolumeIndexBuffer;
|
||||
private int vertexCount;
|
||||
@@ -122,7 +124,7 @@ namespace Barotrauma.Lights
|
||||
color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
|
||||
|
||||
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);
|
||||
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
@@ -150,7 +152,9 @@ namespace Barotrauma.Lights
|
||||
CastShadows = true;
|
||||
|
||||
texture = LightTexture;
|
||||
|
||||
|
||||
diffToSub = new Dictionary<Submarine, Vector2>();
|
||||
|
||||
GameMain.LightManager.AddLight(this);
|
||||
}
|
||||
|
||||
@@ -269,20 +273,34 @@ namespace Barotrauma.Lights
|
||||
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);
|
||||
|
||||
//only draw if the light overlaps with the sub
|
||||
//don't draw any shadows if the light doesn't overlap with the borders of the sub
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, 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;
|
||||
Vector2 prevDiff;
|
||||
if (!diffToSub.TryGetValue(sub, out 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +463,11 @@ namespace Barotrauma
|
||||
Vector2 moveAmount = Submarine.VectorToWorldGrid(cam.WorldViewCenter - center);
|
||||
|
||||
selectedList = new List<MapEntity>(clones);
|
||||
selectedList.ForEach(c => c.Move(moveAmount));
|
||||
foreach (MapEntity clone in selectedList)
|
||||
{
|
||||
clone.Move(moveAmount);
|
||||
clone.Submarine = Submarine.MainSub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,17 +160,17 @@ namespace Barotrauma
|
||||
|
||||
private List<Vector2> GenerateConvexHull()
|
||||
{
|
||||
if (!Structure.WallList.Any())
|
||||
List<Structure> subWalls = Structure.WallList.FindAll(wall => wall.Submarine == submarine);
|
||||
|
||||
if (subWalls.Count == 0)
|
||||
{
|
||||
return new List<Vector2> { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) };
|
||||
}
|
||||
|
||||
List<Vector2> points = new List<Vector2>();
|
||||
|
||||
foreach (Structure wall in Structure.WallList)
|
||||
foreach (Structure wall in subWalls)
|
||||
{
|
||||
if (wall.Submarine != submarine) continue;
|
||||
|
||||
points.Add(new Vector2(wall.Rect.X, wall.Rect.Y));
|
||||
points.Add(new Vector2(wall.Rect.X + wall.Rect.Width, wall.Rect.Y));
|
||||
points.Add(new Vector2(wall.Rect.X, wall.Rect.Y - wall.Rect.Height));
|
||||
|
||||
Reference in New Issue
Block a user