Merge branch 'master' into new-netcode
Conflicts: Subsurface/Properties/AssemblyInfo.cs Subsurface/Source/Items/Components/DockingPort.cs Subsurface/Source/Items/Components/Signal/Wire.cs Subsurface/Source/Items/Item.cs
This commit is contained in:
@@ -119,15 +119,21 @@ namespace Barotrauma
|
||||
foreach (Limb limb in c.AnimController.Limbs)
|
||||
{
|
||||
float dist = Vector2.Distance(limb.WorldPosition, worldPosition);
|
||||
|
||||
//calculate distance from the "outer surface" of the physics body
|
||||
//doesn't take the rotation of the limb into account, but should be accurate enough for this purpose
|
||||
float limbRadius = Math.Max(Math.Max(limb.body.width * 0.5f, limb.body.height * 0.5f), limb.body.radius);
|
||||
dist = Math.Max(0.0f, dist - FarseerPhysics.ConvertUnits.ToDisplayUnits(limbRadius));
|
||||
|
||||
if (dist > range) continue;
|
||||
|
||||
float distFactor = 1.0f - dist / range;
|
||||
|
||||
if (limb.WorldPosition == worldPosition) continue;
|
||||
|
||||
c.AddDamage(limb.WorldPosition, DamageType.None,
|
||||
damage / c.AnimController.Limbs.Length * distFactor, 0.0f, stun * distFactor, false);
|
||||
|
||||
if (limb.WorldPosition == worldPosition) continue;
|
||||
|
||||
if (force > 0.0f)
|
||||
{
|
||||
limb.body.ApplyLinearImpulse(Vector2.Normalize(limb.WorldPosition - worldPosition) * distFactor * force);
|
||||
@@ -136,11 +142,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage)
|
||||
/// <summary>
|
||||
/// Returns a dictionary where the keys are the structures that took damage and the values are the amount of damage taken
|
||||
/// </summary>
|
||||
public static Dictionary<Structure,float> RangedStructureDamage(Vector2 worldPosition, float worldRange, float damage)
|
||||
{
|
||||
List<Structure> structureList = new List<Structure>();
|
||||
|
||||
|
||||
List<Structure> structureList = new List<Structure>();
|
||||
float dist = 600.0f;
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
{
|
||||
@@ -155,14 +162,28 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<Structure, float> damagedStructures = new Dictionary<Structure, float>();
|
||||
foreach (Structure structure in structureList)
|
||||
{
|
||||
for (int i = 0; i < structure.SectionCount; i++)
|
||||
{
|
||||
float distFactor = 1.0f - (Vector2.Distance(structure.SectionPosition(i, true), worldPosition) / worldRange);
|
||||
if (distFactor > 0.0f) structure.AddDamage(i, damage * distFactor);
|
||||
}
|
||||
if (distFactor <= 0.0f) continue;
|
||||
|
||||
structure.AddDamage(i, damage * distFactor);
|
||||
|
||||
if (damagedStructures.ContainsKey(structure))
|
||||
{
|
||||
damagedStructures[structure] += damage * distFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
damagedStructures.Add(structure, damage * distFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return damagedStructures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Gap";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool SelectableInEditor
|
||||
{
|
||||
get
|
||||
@@ -197,7 +205,13 @@ namespace Barotrauma
|
||||
Color clr = (open == 0.0f) ? Color.Red : Color.Cyan;
|
||||
if (isHighlighted) clr = Color.Gold;
|
||||
|
||||
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true,0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||
float depth = (ID % 255) * 0.000001f;
|
||||
|
||||
GUI.DrawRectangle(
|
||||
sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height),
|
||||
clr * 0.5f, true,
|
||||
depth,
|
||||
(int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||
|
||||
for (int i = 0; i < linkedTo.Count; i++)
|
||||
{
|
||||
@@ -209,10 +223,10 @@ namespace Barotrauma
|
||||
arrowPos += new Vector2(dir.X * (WorldRect.Width / 2 + 10), dir.Y * (WorldRect.Height / 2 + 10));
|
||||
|
||||
GUI.Arrow.Draw(sb,
|
||||
arrowPos,
|
||||
clr * 0.8f,
|
||||
arrowPos, clr * 0.8f,
|
||||
GUI.Arrow.Origin, MathUtils.VectorToAngle(dir) + MathHelper.PiOver2,
|
||||
isHorizontal ? new Vector2(rect.Height / 16.0f, 1.0f) : new Vector2(rect.Width / 16.0f, 1.0f));
|
||||
isHorizontal ? new Vector2(rect.Height / 16.0f, 1.0f) : new Vector2(rect.Width / 16.0f, 1.0f),
|
||||
SpriteEffects.None, depth);
|
||||
}
|
||||
|
||||
if (IsSelected)
|
||||
@@ -222,7 +236,7 @@ namespace Barotrauma
|
||||
new Vector2(rect.Width + 10, rect.Height + 10),
|
||||
Color.Red,
|
||||
false,
|
||||
0,
|
||||
depth,
|
||||
(int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(drawRect.X, -drawRect.Y),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
Color.Blue, false, 0, (int)Math.Max((1.5f / Screen.Selected.Cam.Zoom), 1.0f));
|
||||
Color.Blue, false, (ID % 255) * 0.000001f, (int)Math.Max((1.5f / Screen.Selected.Cam.Zoom), 1.0f));
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
|
||||
@@ -607,7 +607,6 @@ namespace Barotrauma
|
||||
spriteBatch.DrawString(GUI.SmallFont, "Pressure: " + ((int)pressure - rect.Y).ToString() +
|
||||
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 5, -drawRect.Y + 5), Color.White);
|
||||
spriteBatch.DrawString(GUI.SmallFont, volume + " / " + FullVolume, new Vector2(drawRect.X + 5, -drawRect.Y + 20), Color.White);
|
||||
|
||||
}
|
||||
|
||||
if ((IsSelected || isHighlighted) && editing)
|
||||
|
||||
@@ -348,9 +348,9 @@ namespace Barotrauma
|
||||
return pathCells;
|
||||
}
|
||||
|
||||
public static List<Body> GeneratePolygons(List<VoronoiCell> cells, out List<VertexPositionColor> verticeList, bool setSolid=true)
|
||||
public static List<Body> GeneratePolygons(List<VoronoiCell> cells, out List<VertexPositionTexture> verticeList, bool setSolid=true)
|
||||
{
|
||||
verticeList = new List<VertexPositionColor>();
|
||||
verticeList = new List<VertexPositionTexture>();
|
||||
var bodies = new List<Body>();
|
||||
|
||||
List<Vector2> tempVertices = new List<Vector2>();
|
||||
@@ -388,7 +388,12 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Vector2 vertex in triangles[i])
|
||||
{
|
||||
verticeList.Add(new VertexPositionColor(new Vector3(vertex, 0.0f), Color.Black));
|
||||
//shift the coordinates around a bit to make the texture repetition less obvious
|
||||
Vector2 uvCoords = new Vector2(
|
||||
vertex.X / 2000.0f + (float)Math.Sin(vertex.X / 500.0f) * 0.15f,
|
||||
vertex.Y / 2000.0f + (float)Math.Sin(vertex.Y / 700.0f) * 0.15f);
|
||||
|
||||
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 1.0f), uvCoords));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,8 +183,12 @@ namespace Barotrauma
|
||||
float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3;
|
||||
GameMain.LightManager.AmbientLight = new Color(backgroundColor * (10.0f / avgValue), 1.0f);
|
||||
|
||||
float minWidth = Submarine.MainSub == null ? 0.0f : Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height);
|
||||
minWidth = Math.Max(minWidth, 6500.0f);
|
||||
float minWidth = 6500.0f;
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
Rectangle dockedSubBorders = Submarine.MainSub.GetDockedBorders();
|
||||
minWidth = Math.Max(minWidth, Math.Max(dockedSubBorders.Width, dockedSubBorders.Height));
|
||||
}
|
||||
|
||||
startPosition = new Vector2(
|
||||
Rand.Range(minWidth, minWidth * 2, false),
|
||||
@@ -437,7 +441,7 @@ namespace Barotrauma
|
||||
|
||||
List<VoronoiCell> cellsWithBody = new List<VoronoiCell>(cells);
|
||||
|
||||
List<VertexPositionColor> bodyVertices;
|
||||
List<VertexPositionTexture> bodyVertices;
|
||||
bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out bodyVertices);
|
||||
|
||||
renderer.SetBodyVertices(bodyVertices.ToArray());
|
||||
@@ -692,6 +696,8 @@ namespace Barotrauma
|
||||
|
||||
int iter = 0;
|
||||
|
||||
ruinPos.Y = Math.Min(borders.Y + borders.Height - ruinSize.Y/2, ruinPos.Y);
|
||||
|
||||
while (mainPath.Any(p => Vector2.Distance(ruinPos, p.Center) < ruinRadius * 2.0f))
|
||||
{
|
||||
Vector2 weighedPathPos = ruinPos;
|
||||
@@ -711,6 +717,7 @@ namespace Barotrauma
|
||||
//}
|
||||
|
||||
weighedPathPos += moveAmount;
|
||||
weighedPathPos.Y = Math.Min(borders.Y + borders.Height - ruinSize.Y / 2, weighedPathPos.Y);
|
||||
}
|
||||
|
||||
ruinPos = weighedPathPos;
|
||||
@@ -743,10 +750,18 @@ namespace Barotrauma
|
||||
{
|
||||
var tooClose = GetTooCloseCells(ruinShape.Rect.Center.ToVector2(), Math.Max(ruinShape.Rect.Width, ruinShape.Rect.Height));
|
||||
|
||||
tooClose.ForEach(c =>
|
||||
foreach (VoronoiCell cell in tooClose)
|
||||
{
|
||||
if (c.edges.Any(e => ruinShape.Rect.Contains(e.point1) || ruinShape.Rect.Contains(e.point2))) c.CellType = CellType.Empty;
|
||||
});
|
||||
if (cell.CellType == CellType.Empty) continue;
|
||||
foreach (GraphEdge e in cell.edges)
|
||||
{
|
||||
if (MathUtils.GetLineRectangleIntersection(e.point1, e.point2, ruinShape.Rect) != null)
|
||||
{
|
||||
cell.CellType = CellType.Empty;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Barotrauma
|
||||
{
|
||||
class LevelRenderer : IDisposable
|
||||
{
|
||||
private static BasicEffect basicEffect;
|
||||
private static BasicEffect wallEdgeEffect, wallCenterEffect;
|
||||
|
||||
private static Sprite background, backgroundTop;
|
||||
private static Sprite dustParticles;
|
||||
@@ -39,14 +39,29 @@ namespace Barotrauma
|
||||
dustParticles = new Sprite("Content/Map/dustparticles.png", Vector2.Zero);
|
||||
}
|
||||
|
||||
if (basicEffect == null)
|
||||
if (wallEdgeEffect == null)
|
||||
{
|
||||
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
|
||||
basicEffect.TextureEnabled = true;
|
||||
basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceWall.png");
|
||||
wallEdgeEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
|
||||
{
|
||||
DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
|
||||
VertexColorEnabled = false,
|
||||
TextureEnabled = true,
|
||||
Texture = shaftTexture
|
||||
};
|
||||
wallEdgeEffect.CurrentTechnique = wallEdgeEffect.Techniques["BasicEffect_Texture"];
|
||||
}
|
||||
|
||||
if (wallCenterEffect == null)
|
||||
{
|
||||
wallCenterEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
|
||||
{
|
||||
VertexColorEnabled = false,
|
||||
TextureEnabled = true,
|
||||
Texture = backgroundTop.Texture
|
||||
};
|
||||
wallCenterEffect.CurrentTechnique = wallCenterEffect.Techniques["BasicEffect_Texture"];
|
||||
}
|
||||
|
||||
|
||||
if (backgroundSpriteManager==null)
|
||||
{
|
||||
@@ -79,9 +94,9 @@ namespace Barotrauma
|
||||
wallVertices.SetData(vertices);
|
||||
}
|
||||
|
||||
public void SetBodyVertices(VertexPositionColor[] vertices)
|
||||
public void SetBodyVertices(VertexPositionTexture[] vertices)
|
||||
{
|
||||
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
|
||||
bodyVertices.SetData(vertices);
|
||||
}
|
||||
|
||||
@@ -96,21 +111,20 @@ namespace Barotrauma
|
||||
|
||||
if (backgroundPos.Y < 1024)
|
||||
{
|
||||
if (backgroundPos.Y > -1024)
|
||||
{
|
||||
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
|
||||
background.DrawTiled(spriteBatch,
|
||||
(backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
|
||||
new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y),
|
||||
Vector2.Zero, level.BackgroundColor);
|
||||
}
|
||||
|
||||
if (backgroundPos.Y < 0)
|
||||
{
|
||||
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024));
|
||||
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
|
||||
Vector2.Zero, level.BackgroundColor);
|
||||
}
|
||||
if (backgroundPos.Y > -1024)
|
||||
{
|
||||
background.SourceRect = new Rectangle((int)backgroundPos.X, (int)Math.Max(backgroundPos.Y, 0), 1024, 1024);
|
||||
background.DrawTiled(spriteBatch,
|
||||
(backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero,
|
||||
new Vector2(GameMain.GraphicsWidth, (int)Math.Ceiling(1024 - backgroundPos.Y)),
|
||||
Vector2.Zero, level.BackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
@@ -165,12 +179,12 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
|
||||
new Vector2(cell.Center.X, -cell.Center.Y),
|
||||
Color.White);
|
||||
Color.Blue*0.5f);
|
||||
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
|
||||
new Vector2(edge.point2.X, -edge.point2.Y), cell.body==null ? Color.Gray : Color.White);
|
||||
new Vector2(edge.point2.X, -edge.point2.Y), cell.body==null ? Color.Cyan*0.5f : Color.White);
|
||||
}
|
||||
|
||||
foreach (Vector2 point in cell.bodyVertices)
|
||||
@@ -205,64 +219,21 @@ namespace Barotrauma
|
||||
{
|
||||
if (wallVertices == null) return;
|
||||
|
||||
basicEffect.World = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
wallEdgeEffect.World = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 100) * 0.5f;
|
||||
wallCenterEffect.World = wallEdgeEffect.World;
|
||||
|
||||
//render the solid center of the wall cells
|
||||
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
|
||||
graphicsDevice.BlendState = BlendState.AlphaBlend;
|
||||
graphicsDevice.SetVertexBuffer(bodyVertices);
|
||||
|
||||
basicEffect.VertexColorEnabled = true;
|
||||
basicEffect.TextureEnabled = false;
|
||||
basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_VertexColor"];
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
wallCenterEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f));
|
||||
|
||||
/*
|
||||
for (int side = 0; side < 2; side++)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
basicEffect.World = Matrix.CreateTranslation(new Vector3(level.WrappingWalls[side, i].Offset, 0.0f)) * cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
|
||||
graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].BodyVertices);
|
||||
|
||||
graphicsDevice.DrawPrimitives(
|
||||
PrimitiveType.TriangleList, 0,
|
||||
(int)Math.Floor(level.WrappingWalls[side, i].BodyVertices.VertexCount / 3.0f));
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
graphicsDevice.SetVertexBuffer(wallVertices);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
basicEffect.TextureEnabled = true;
|
||||
basicEffect.CurrentTechnique = basicEffect.Techniques["BasicEffect_Texture"];
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
|
||||
/*
|
||||
for (int side = 0; side < 2; side++)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
||||
basicEffect.World = Matrix.CreateTranslation(new Vector3(level.WrappingWalls[side,i].Offset, 0.0f)) * cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].WallVertices);
|
||||
|
||||
graphicsDevice.DrawPrimitives(
|
||||
PrimitiveType.TriangleList, 0,
|
||||
(int)Math.Floor(level.WrappingWalls[side, i].WallVertices.VertexCount / 3.0f));
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
//render the edges of the wall cells
|
||||
graphicsDevice.SetVertexBuffer(wallVertices);
|
||||
wallEdgeEffect.CurrentTechnique.Passes[0].Apply();
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -185,7 +185,8 @@ namespace Barotrauma.Lights
|
||||
if (NeedsHullUpdate)
|
||||
{
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
if (fullChList != null)
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
}
|
||||
}
|
||||
//light is outside, convexhull inside a sub
|
||||
@@ -299,7 +300,7 @@ namespace Barotrauma.Lights
|
||||
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
|
||||
|
||||
drawPos.Y = -drawPos.Y;
|
||||
|
||||
|
||||
if (range > 1.0f)
|
||||
{
|
||||
if (overrideLightTexture == null)
|
||||
@@ -326,6 +327,24 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
}
|
||||
|
||||
public void FlipX()
|
||||
{
|
||||
SpriteEffect = SpriteEffect == SpriteEffects.None ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||
if (LightSprite != null)
|
||||
{
|
||||
Vector2 lightOrigin = LightSprite.Origin;
|
||||
lightOrigin.X = LightSprite.SourceRect.Width - lightOrigin.X;
|
||||
LightSprite.Origin = lightOrigin;
|
||||
}
|
||||
|
||||
if (overrideLightTexture != null)
|
||||
{
|
||||
Vector2 lightOrigin = overrideLightTexture.Origin;
|
||||
lightOrigin.X = overrideLightTexture.SourceRect.Width - lightOrigin.X;
|
||||
overrideLightTexture.Origin = lightOrigin;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
if (LightSprite != null) LightSprite.Remove();
|
||||
|
||||
@@ -405,19 +405,29 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
sub.SetPosition(WorldPosition - Submarine.WorldPosition);
|
||||
sub.Submarine = Submarine;
|
||||
sub.SetPosition(WorldPosition);
|
||||
}
|
||||
|
||||
var linkedItem = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||
|
||||
if (linkedItem == null) return;
|
||||
|
||||
var linkedPort = ((Item)linkedItem).GetComponent<DockingPort>();
|
||||
|
||||
DockingPort linkedPort = null;
|
||||
DockingPort myPort = null;
|
||||
float closestDistance = 0.0f;
|
||||
|
||||
MapEntity linkedItem = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||
if (linkedItem == null)
|
||||
{
|
||||
linkedPort = DockingPort.list.Find(dp => dp.DockingTarget != null && dp.DockingTarget.Item.Submarine == sub);
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedPort = ((Item)linkedItem).GetComponent<DockingPort>();
|
||||
}
|
||||
|
||||
if (linkedPort == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float closestDistance = 0.0f;
|
||||
foreach (DockingPort port in DockingPort.list)
|
||||
{
|
||||
if (port.Item.Submarine != sub || port.IsHorizontal != linkedPort.IsHorizontal) continue;
|
||||
@@ -432,8 +442,23 @@ namespace Barotrauma
|
||||
|
||||
if (myPort != null)
|
||||
{
|
||||
myPort.DockingTarget = linkedPort;
|
||||
}
|
||||
Vector2 portDiff = myPort.Item.WorldPosition - sub.WorldPosition;
|
||||
Vector2 offset = (myPort.IsHorizontal ?
|
||||
Vector2.UnitX * Math.Sign(linkedPort.Item.WorldPosition.X - myPort.Item.WorldPosition.X) :
|
||||
Vector2.UnitY * Math.Sign(linkedPort.Item.WorldPosition.Y - myPort.Item.WorldPosition.Y));
|
||||
offset *= myPort.DockedDistance;
|
||||
|
||||
sub.SetPosition(
|
||||
(linkedPort.Item.WorldPosition - portDiff)
|
||||
- offset);
|
||||
|
||||
|
||||
myPort.Dock(linkedPort);
|
||||
myPort.Lock();
|
||||
}
|
||||
|
||||
sub.SetPosition(sub.WorldPosition - Submarine.WorldPosition);
|
||||
sub.Submarine = Submarine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
private static List<MapEntity> copiedList = new List<MapEntity>();
|
||||
|
||||
|
||||
private static List<MapEntity> highlightedList = new List<MapEntity>();
|
||||
|
||||
private static float highlightTimer;
|
||||
|
||||
private static GUIListBox highlightedListBox;
|
||||
public static GUIListBox HighlightedListBox
|
||||
{
|
||||
get { return highlightedListBox; }
|
||||
}
|
||||
|
||||
|
||||
protected static GUIComponent editingHUD;
|
||||
public static GUIComponent EditingHUD
|
||||
{
|
||||
@@ -243,6 +254,7 @@ namespace Barotrauma
|
||||
//clone links between the entities
|
||||
for (int i = 0; i < clones.Count; i++)
|
||||
{
|
||||
if (entitiesToClone[i].linkedTo == null) continue;
|
||||
foreach (MapEntity linked in entitiesToClone[i].linkedTo)
|
||||
{
|
||||
if (!entitiesToClone.Contains(linked)) continue;
|
||||
@@ -307,6 +319,11 @@ namespace Barotrauma
|
||||
mapEntityList.Insert(i, this);
|
||||
}
|
||||
|
||||
public virtual bool IsVisible(Rectangle worldView)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true) {}
|
||||
|
||||
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) {}
|
||||
@@ -329,6 +346,11 @@ namespace Barotrauma
|
||||
|
||||
mapEntityList.Remove(this);
|
||||
|
||||
if (selectedList.Contains(this))
|
||||
{
|
||||
selectedList = selectedList.FindAll(e => e != this);
|
||||
}
|
||||
|
||||
if (aiTarget != null) aiTarget.Remove();
|
||||
|
||||
if (linkedTo != null)
|
||||
@@ -369,7 +391,7 @@ namespace Barotrauma
|
||||
public virtual void Update(Camera cam, float deltaTime) { }
|
||||
|
||||
/// <summary>
|
||||
/// Update the selection logic in editmap-screen
|
||||
/// Update the selection logic in submarine editor
|
||||
/// </summary>
|
||||
public static void UpdateSelecting(Camera cam)
|
||||
{
|
||||
@@ -390,7 +412,15 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow) return;
|
||||
if (GUIComponent.MouseOn != null || !PlayerInput.MouseInsideWindow)
|
||||
{
|
||||
if (highlightedListBox == null ||
|
||||
(GUIComponent.MouseOn != highlightedListBox && !highlightedListBox.IsParentOf(GUIComponent.MouseOn)))
|
||||
{
|
||||
UpdateHighlightedListBox(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MapEntityPrefab.Selected != null)
|
||||
{
|
||||
@@ -428,10 +458,12 @@ namespace Barotrauma
|
||||
|
||||
Vector2 center = Vector2.Zero;
|
||||
clones.ForEach(c => center += c.WorldPosition);
|
||||
center /= clones.Count;
|
||||
center = Submarine.VectorToWorldGrid(center / clones.Count);
|
||||
|
||||
Vector2 moveAmount = Submarine.VectorToWorldGrid(cam.WorldViewCenter - center);
|
||||
|
||||
selectedList = new List<MapEntity>(clones);
|
||||
selectedList.ForEach(c => c.Move(cam.WorldViewCenter - center));
|
||||
selectedList.ForEach(c => c.Move(moveAmount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,19 +473,62 @@ namespace Barotrauma
|
||||
|
||||
if (startMovingPos == Vector2.Zero)
|
||||
{
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
List<MapEntity> highlightedEntities = new List<MapEntity>();
|
||||
if (highlightedListBox != null && highlightedListBox.IsParentOf(GUIComponent.MouseOn))
|
||||
{
|
||||
if (!e.SelectableInEditor) continue;
|
||||
|
||||
if (highLightedEntity == null || e.Sprite == null ||
|
||||
(highLightedEntity.Sprite != null && e.Sprite.Depth < highLightedEntity.Sprite.Depth))
|
||||
highLightedEntity = GUIComponent.MouseOn.UserData as MapEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
if (e.IsMouseOn(position)) highLightedEntity = e;
|
||||
if (!e.SelectableInEditor) continue;
|
||||
|
||||
if (e.IsMouseOn(position))
|
||||
{
|
||||
int i = 0;
|
||||
while (i < highlightedEntities.Count &&
|
||||
e.Sprite != null &&
|
||||
(highlightedEntities[i].Sprite == null || highlightedEntities[i].Sprite.Depth < e.Sprite.Depth))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
highlightedEntities.Insert(i, e);
|
||||
|
||||
if (i == 0) highLightedEntity = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerInput.MouseSpeed.LengthSquared() > 10)
|
||||
{
|
||||
highlightTimer = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool mouseNearHighlightBox = false;
|
||||
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
Rectangle expandedRect = highlightedListBox.Rect;
|
||||
expandedRect.Inflate(20, 20);
|
||||
mouseNearHighlightBox = expandedRect.Contains(PlayerInput.MousePosition);
|
||||
if (!mouseNearHighlightBox) highlightedListBox = null;
|
||||
}
|
||||
|
||||
highlightTimer += (float)Timing.Step;
|
||||
if (highlightTimer > 1.0f)
|
||||
{
|
||||
if (!mouseNearHighlightBox)
|
||||
{
|
||||
UpdateHighlightedListBox(highlightedEntities);
|
||||
highlightTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (highLightedEntity != null) highLightedEntity.isHighlighted = true;
|
||||
|
||||
}
|
||||
|
||||
//started moving selected entities
|
||||
@@ -501,11 +576,6 @@ namespace Barotrauma
|
||||
if (highLightedEntity != null) newSelection.Add(highLightedEntity);
|
||||
}
|
||||
|
||||
foreach (MapEntity e in newSelection)
|
||||
{
|
||||
e.isHighlighted = true;
|
||||
}
|
||||
|
||||
if (PlayerInput.LeftButtonReleased())
|
||||
{
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) ||
|
||||
@@ -513,14 +583,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (MapEntity e in newSelection)
|
||||
{
|
||||
bool alreadySelected = false;
|
||||
|
||||
foreach (MapEntity e2 in selectedList)
|
||||
{
|
||||
if (e.ID == e2.ID) alreadySelected = true;
|
||||
}
|
||||
|
||||
if (alreadySelected)
|
||||
if (selectedList.Contains(e))
|
||||
selectedList.Remove(e);
|
||||
else
|
||||
selectedList.Add(e);
|
||||
@@ -558,7 +621,8 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
if (PlayerInput.LeftButtonHeld() &&
|
||||
PlayerInput.KeyUp(Keys.Space))
|
||||
PlayerInput.KeyUp(Keys.Space) &&
|
||||
(highlightedListBox == null || (GUIComponent.MouseOn != highlightedListBox && !highlightedListBox.IsParentOf(GUIComponent.MouseOn))))
|
||||
{
|
||||
//if clicking a selected entity, start moving it
|
||||
foreach (MapEntity e in selectedList)
|
||||
@@ -571,6 +635,57 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateHighlightedListBox(List<MapEntity> highlightedEntities)
|
||||
{
|
||||
if (highlightedEntities == null || highlightedEntities.Count < 2)
|
||||
{
|
||||
highlightedListBox = null;
|
||||
return;
|
||||
}
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
if (GUIComponent.MouseOn == highlightedListBox || highlightedListBox.IsParentOf(GUIComponent.MouseOn)) return;
|
||||
if (highlightedEntities.SequenceEqual(highlightedList)) return;
|
||||
}
|
||||
|
||||
highlightedList = highlightedEntities;
|
||||
|
||||
highlightedListBox = new GUIListBox(
|
||||
new Rectangle((int)PlayerInput.MousePosition.X+15, (int)PlayerInput.MousePosition.Y+15, 150, highlightedEntities.Count * 15),
|
||||
null, Alignment.TopLeft, GUI.Style, null, false);
|
||||
|
||||
highlightedListBox.Color = Color.Black * 0.6f;
|
||||
|
||||
foreach (MapEntity entity in highlightedEntities)
|
||||
{
|
||||
var textBlock = new GUITextBlock(
|
||||
new Rectangle(0,0,0,15),
|
||||
ToolBox.LimitString(entity.Name, GUI.SmallFont, 140), GUI.Style, highlightedListBox, GUI.SmallFont);
|
||||
|
||||
textBlock.UserData = entity;
|
||||
}
|
||||
|
||||
highlightedListBox.OnSelected = (GUIComponent component, object obj) =>
|
||||
{
|
||||
MapEntity entity = obj as MapEntity;
|
||||
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) ||
|
||||
PlayerInput.KeyDown(Keys.RightControl))
|
||||
{
|
||||
if (selectedList.Contains(entity))
|
||||
selectedList.Remove(entity);
|
||||
else
|
||||
selectedList.Add(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectEntity(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draw the "selection rectangle" and outlines of entities that are being dragged (if any)
|
||||
@@ -608,6 +723,8 @@ namespace Barotrauma
|
||||
|
||||
public static void UpdateEditor(Camera cam)
|
||||
{
|
||||
if (highlightedListBox != null) highlightedListBox.Update((float)Timing.Step);
|
||||
|
||||
if (selectedList.Count == 1)
|
||||
{
|
||||
selectedList[0].UpdateEditing(cam);
|
||||
@@ -617,19 +734,21 @@ namespace Barotrauma
|
||||
selectedList[0].UpdateResizing(cam);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (editingHUD != null)
|
||||
{
|
||||
if (editingHUD == null) return;
|
||||
|
||||
foreach (GUIComponent component in editingHUD.children)
|
||||
if (selectedList.Count == 0 || editingHUD.UserData != selectedList[0])
|
||||
{
|
||||
var textBox = component as GUITextBox;
|
||||
if (textBox == null) continue;
|
||||
foreach (GUIComponent component in editingHUD.children)
|
||||
{
|
||||
var textBox = component as GUITextBox;
|
||||
if (textBox == null) continue;
|
||||
|
||||
textBox.Deselect();
|
||||
textBox.Deselect();
|
||||
}
|
||||
|
||||
editingHUD = null;
|
||||
}
|
||||
|
||||
editingHUD = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -644,6 +763,11 @@ namespace Barotrauma
|
||||
selectedList[0].DrawResizing(spriteBatch, cam);
|
||||
}
|
||||
}
|
||||
|
||||
if (highlightedListBox != null)
|
||||
{
|
||||
highlightedListBox.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeselectAll()
|
||||
@@ -658,8 +782,7 @@ namespace Barotrauma
|
||||
|
||||
selectedList.Add(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// copies a list of entities to the "clipboard" (copiedList)
|
||||
/// </summary>
|
||||
@@ -693,7 +816,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual void AddToGUIUpdateList()
|
||||
{
|
||||
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
|
||||
if (editingHUD != null && editingHUD.UserData == this) editingHUD.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public virtual void UpdateEditing(Camera cam) { }
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Barotrauma
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "structure"; }
|
||||
get { return prefab.Name; }
|
||||
}
|
||||
|
||||
public bool HasBody
|
||||
@@ -153,6 +153,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> Tags
|
||||
{
|
||||
get { return prefab.tags; }
|
||||
}
|
||||
|
||||
public override Rectangle Rect
|
||||
{
|
||||
get
|
||||
@@ -477,6 +482,15 @@ namespace Barotrauma
|
||||
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
||||
}
|
||||
|
||||
public override 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;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
@@ -505,6 +519,9 @@ namespace Barotrauma
|
||||
|
||||
Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition;
|
||||
|
||||
float depth = prefab.sprite.Depth;
|
||||
depth -= (ID % 255) * 0.000001f;
|
||||
|
||||
if (back && damageEffect == null)
|
||||
{
|
||||
if (prefab.BackgroundSprite != null)
|
||||
@@ -513,7 +530,7 @@ namespace Barotrauma
|
||||
spriteBatch,
|
||||
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
|
||||
new Vector2(rect.Width, rect.Height),
|
||||
Vector2.Zero, color, Point.Zero);
|
||||
color, Point.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,8 +569,8 @@ namespace Barotrauma
|
||||
spriteBatch,
|
||||
new Vector2(sections[i].rect.X + drawOffset.X, -(sections[i].rect.Y + drawOffset.Y)),
|
||||
new Vector2(sections[i].rect.Width, sections[i].rect.Height),
|
||||
Vector2.Zero, color,
|
||||
textureOffset);
|
||||
color,
|
||||
textureOffset, depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,22 +85,9 @@ namespace Barotrauma
|
||||
{
|
||||
StructurePrefab sp = new StructurePrefab();
|
||||
sp.name = element.Name.ToString();
|
||||
|
||||
//Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
|
||||
|
||||
//Rectangle sourceRect = new Rectangle(
|
||||
// (int)sourceVector.X,
|
||||
// (int)sourceVector.Y,
|
||||
// (int)sourceVector.Z,
|
||||
// (int)sourceVector.W);
|
||||
|
||||
//if (element.Attribute("sprite") != null)
|
||||
//{
|
||||
// sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
|
||||
// sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
|
||||
//}
|
||||
sp.tags = new List<string>();
|
||||
sp.tags.AddRange(ToolBox.GetAttributeString(element, "tags", "").Split(','));
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using Voronoi2;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -298,11 +299,96 @@ namespace Barotrauma
|
||||
tags &= ~tag;
|
||||
}
|
||||
|
||||
//drawing ----------------------------------------------------
|
||||
/// <summary>
|
||||
/// Returns a rect that contains the borders of this sub and all subs docked to it
|
||||
/// </summary>
|
||||
public Rectangle GetDockedBorders()
|
||||
{
|
||||
Rectangle dockedBorders = Borders;
|
||||
dockedBorders.Y -= dockedBorders.Height;
|
||||
|
||||
foreach (Submarine dockedSub in DockedTo)
|
||||
{
|
||||
Vector2 diff = dockedSub.Submarine == this ? dockedSub.WorldPosition : dockedSub.WorldPosition - WorldPosition;
|
||||
|
||||
|
||||
Rectangle dockedSubBorders = dockedSub.Borders;
|
||||
dockedSubBorders.Y -= dockedSubBorders.Height;
|
||||
dockedSubBorders.Location += diff.ToPoint();
|
||||
|
||||
dockedBorders = Rectangle.Union(dockedBorders, dockedSubBorders);
|
||||
}
|
||||
|
||||
dockedBorders.Y += dockedBorders.Height;
|
||||
return dockedBorders;
|
||||
}
|
||||
|
||||
public Vector2 FindSpawnPos(Vector2 spawnPos)
|
||||
{
|
||||
Rectangle dockedBorders = GetDockedBorders();
|
||||
|
||||
int iterations = 0;
|
||||
bool wallTooClose = false;
|
||||
do
|
||||
{
|
||||
Rectangle worldBorders = new Rectangle(
|
||||
dockedBorders.X + (int)spawnPos.X,
|
||||
dockedBorders.Y + (int)spawnPos.Y,
|
||||
dockedBorders.Width,
|
||||
dockedBorders.Height);
|
||||
|
||||
wallTooClose = false;
|
||||
|
||||
var nearbyCells = Level.Loaded.GetCells(
|
||||
spawnPos, (int)Math.Ceiling(Math.Max(dockedBorders.Width, dockedBorders.Height) / (float)Level.GridCellSize));
|
||||
|
||||
foreach (VoronoiCell cell in nearbyCells)
|
||||
{
|
||||
if (cell.CellType == CellType.Empty) continue;
|
||||
|
||||
foreach (GraphEdge e in cell.edges)
|
||||
{
|
||||
List<Vector2> intersections = MathUtils.GetLineRectangleIntersections(e.point1, e.point2, worldBorders);
|
||||
foreach (Vector2 intersection in intersections)
|
||||
{
|
||||
wallTooClose = true;
|
||||
|
||||
if (intersection.X < spawnPos.X)
|
||||
{
|
||||
spawnPos.X += intersection.X - worldBorders.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnPos.X += intersection.X - worldBorders.Right;
|
||||
}
|
||||
|
||||
if (intersection.Y < spawnPos.Y)
|
||||
{
|
||||
spawnPos.Y += intersection.Y - (worldBorders.Y - worldBorders.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnPos.Y += intersection.Y - worldBorders.Y;
|
||||
}
|
||||
|
||||
spawnPos.Y = Math.Min(spawnPos.Y, Level.Loaded.Size.Y - dockedBorders.Height / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iterations++;
|
||||
} while (wallTooClose && iterations < 10);
|
||||
|
||||
return spawnPos;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//drawing ----------------------------------------------------
|
||||
|
||||
public static void CullEntities(Camera cam)
|
||||
{
|
||||
List<Submarine> visibleSubs = new List<Submarine>();
|
||||
HashSet<Submarine> visibleSubs = new HashSet<Submarine>();
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
Rectangle worldBorders = new Rectangle(
|
||||
@@ -311,19 +397,20 @@ namespace Barotrauma
|
||||
sub.Borders.Width + 1000,
|
||||
sub.Borders.Height + 1000);
|
||||
|
||||
|
||||
if (Submarine.RectsOverlap(worldBorders, cam.WorldView))
|
||||
{
|
||||
visibleSubs.Add(sub);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle worldView = cam.WorldView;
|
||||
|
||||
visibleEntities = new List<MapEntity>();
|
||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||
{
|
||||
if (me.Submarine == null || visibleSubs.Contains(me.Submarine))
|
||||
{
|
||||
visibleEntities.Add(me);
|
||||
if (me.IsVisible(worldView)) visibleEntities.Add(me);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,11 +914,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void Preload()
|
||||
public static void RefreshSavedSubs()
|
||||
{
|
||||
|
||||
//string[] mapFilePaths;
|
||||
//Unload();
|
||||
SavedSubmarines.Clear();
|
||||
|
||||
if (!Directory.Exists(SavePath))
|
||||
|
||||
@@ -484,8 +484,6 @@ namespace Barotrauma
|
||||
|
||||
Vector2 lastContactPoint = worldPoints[0];
|
||||
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, ConvertUnits.ToDisplayUnits(lastContactPoint));
|
||||
|
||||
if (Character.Controlled != null && Character.Controlled.Submarine == submarine)
|
||||
{
|
||||
GameMain.GameScreen.Cam.Shake = impact * 2.0f;
|
||||
@@ -518,7 +516,29 @@ namespace Barotrauma
|
||||
item.body.ApplyLinearImpulse(item.body.Mass * impulse);
|
||||
}
|
||||
|
||||
Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
|
||||
var damagedStructures = Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
|
||||
|
||||
//play a damage sound for the structure that took the most damage
|
||||
float maxDamage = 0.0f;
|
||||
Structure maxDamageStructure = null;
|
||||
foreach (KeyValuePair<Structure,float> structureDamage in damagedStructures)
|
||||
{
|
||||
if (maxDamageStructure == null || structureDamage.Value > maxDamage)
|
||||
{
|
||||
maxDamage = structureDamage.Value;
|
||||
maxDamageStructure = structureDamage.Key;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxDamageStructure != null)
|
||||
{
|
||||
SoundPlayer.PlayDamageSound(
|
||||
DamageSoundType.StructureBlunt,
|
||||
impact * 10.0f,
|
||||
ConvertUnits.ToDisplayUnits(lastContactPoint),
|
||||
MathHelper.Clamp(maxDamage * 4.0f, 1000.0f, 4000.0f),
|
||||
maxDamageStructure.Tags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace Barotrauma
|
||||
set { spawnType = value; }
|
||||
}
|
||||
|
||||
//public override string Name
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return spawnType == SpawnType.Path ? "WayPoint" : "SpawnPoint";
|
||||
// }
|
||||
//}
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return spawnType == SpawnType.Path ? "WayPoint" : "SpawnPoint";
|
||||
}
|
||||
}
|
||||
|
||||
public string[] IdCardTags
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user