Merge remote-tracking branch 'barotrauma/master' into new-netcode

# Conflicts:
#	Subsurface/Properties/AssemblyInfo.cs
#	Subsurface/Source/Characters/AI/EnemyAIController.cs
#	Subsurface/Source/Characters/AICharacter.cs
#	Subsurface/Source/Characters/Character.cs
#	Subsurface/Source/Items/Components/Signal/Connection.cs
#	Subsurface/Source/Items/Item.cs
#	Subsurface/Source/Map/Structure.cs
#	Subsurface/Source/Networking/GameClient.cs
#	Subsurface/Source/Networking/GameServer.cs
#	Subsurface/Source/Screens/NetLobbyScreen.cs
This commit is contained in:
juanjp600
2016-11-05 18:18:20 -03:00
57 changed files with 454 additions and 362 deletions

View File

@@ -249,7 +249,7 @@ namespace Barotrauma
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Count();
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Length;
foreach (Limb limb in c.AnimController.Limbs)
{
if (limb.WearingItems.Find(w => w!=null && w.WearableComponent.Item.FireProof)!=null) continue;

View File

@@ -311,7 +311,7 @@ namespace Barotrauma
positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), PositionType.Cave));
if (tunnel.Count() > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count() / 2], PositionType.Cave));
if (tunnel.Count > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count / 2], PositionType.Cave));
pathCells.AddRange(newPathCells);
}

View File

@@ -124,21 +124,15 @@ namespace Barotrauma
if (backgroundCreatureManager!=null) backgroundCreatureManager.Draw(spriteBatch);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.Additive,
SamplerState.LinearWrap, DepthStencilState.Default, null, null,
cam.Transform);
for (int i = 1; i < 4; i++)
for (int i = 0; i < 4; i++)
{
float scale = 1.0f - i * 0.2f;
//alpha goes from 1.0 to 0.0 when scale is in the range of 0.2-0.1
float alpha = (cam.Zoom * scale) < 0.2f ? (cam.Zoom * scale - 0.1f) * 10.0f : 1.0f;
if (alpha <= 0.0f) continue;
Vector2 offset = (new Vector2(cam.WorldViewCenter.X, cam.WorldViewCenter.Y) + dustOffset) * scale;
Vector3 origin = new Vector3(cam.WorldView.Width, cam.WorldView.Height, 0.0f) * 0.5f;
@@ -151,11 +145,11 @@ namespace Barotrauma
spriteBatch.Draw(dustParticles.Texture,
new Vector2(cam.WorldViewCenter.X, -cam.WorldViewCenter.Y),
dustParticles.SourceRect, Color.White * alpha, 0.0f,
new Vector2(cam.WorldView.Width, cam.WorldView.Height) * 0.5f / scale, scale, SpriteEffects.None, 0);
new Vector2(cam.WorldView.Width, cam.WorldView.Height) * 0.5f / scale, scale, SpriteEffects.None, 1.0f - scale);
}
spriteBatch.End();
RenderWalls(GameMain.CurrGraphicsDevice, cam);
}

View File

@@ -271,8 +271,6 @@ namespace Barotrauma.RuinGeneration
foreach (Corridor corridor in corridors)
{
List<Line> corridorWalls = new List<Line>();
corridor.CreateWalls();
foreach (BTRoom leaf in rooms)
@@ -361,7 +359,7 @@ namespace Barotrauma.RuinGeneration
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]);
Vector2 size = (prop.Prefab is StructurePrefab) ? (prop.Prefab as StructurePrefab).Size : Vector2.Zero;
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
var shape = shapes[Rand.Int(shapes.Count, false)];
@@ -385,7 +383,7 @@ namespace Barotrauma.RuinGeneration
if (prop.Prefab is ItemPrefab)
{
var item = new Item(prop.Prefab as ItemPrefab, position, null);
var item = new Item((ItemPrefab)prop.Prefab, position, null);
item.MoveWithLevel = true;
}
else

View File

@@ -182,7 +182,7 @@ namespace Barotrauma.Lights
{
ClearCachedShadows();
for (int i = 0; i < vertices.Count(); i++)
for (int i = 0; i < vertices.Length; i++)
{
vertices[i] += amount;
losVertices[i] += amount;

View File

@@ -98,8 +98,8 @@ namespace Barotrauma.Lights
public LightSource (XElement element)
: this(Vector2.Zero, 100.0f, Color.White, null)
{
float range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
Color color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);

View File

@@ -95,10 +95,7 @@ namespace Barotrauma
(int)sl.wallVertices.Max(v => v.Y + position.Y),
(int)sl.wallVertices.Max(v => v.X + position.X),
(int)sl.wallVertices.Min(v => v.Y + position.Y));
int width = sl.rect.Width - sl.rect.X;
int height = sl.rect.Y - sl.rect.Height;
sl.rect = new Rectangle((int)position.X, (int)position.Y, 1, 1);
return sl;

View File

@@ -28,12 +28,16 @@ namespace Barotrauma
public WallSection(Rectangle rect)
{
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
this.rect = rect;
damage = 0.0f;
}
public WallSection(Rectangle rect, float damage)
{
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
this.rect = rect;
this.damage = 0.0f;
}
@@ -182,7 +186,7 @@ namespace Barotrauma
{
base.Move(amount);
for (int i = 0; i < sections.Count(); i++)
for (int i = 0; i < sections.Length; i++)
{
Rectangle r = sections[i].rect;
r.X += (int)amount.X;
@@ -209,6 +213,7 @@ namespace Barotrauma
: base(sp, submarine)
{
if (rectangle.Width == 0 || rectangle.Height == 0) return;
System.Diagnostics.Debug.Assert(rectangle.Width > 0 && rectangle.Height > 0);
rect = rectangle;
prefab = sp;
@@ -290,32 +295,39 @@ namespace Barotrauma
private void CreateSections()
{
int xsections = 1, ysections = 1;
int width, height;
int width = rect.Width, height = rect.Height;
if (!HasBody)
{
sections = new WallSection[1];
sections[0] = new WallSection(rect);
return;
}
{
if (flippedX && isHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width);
width = prefab.sprite.SourceRect.Width;
if (isHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize);
}
else
{
xsections = 1;
ysections = 1;
}
sections = new WallSection[xsections];
width = (int)wallSectionSize;
height = rect.Height;
}
else
{
ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize);
sections = new WallSection[ysections];
width = rect.Width;
height = (int)wallSectionSize;
if (isHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize);
sections = new WallSection[xsections];
width = (int)wallSectionSize;
}
else
{
ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize);
sections = new WallSection[ysections];
height = (int)wallSectionSize;
}
}
for (int x = 0; x < xsections; x++)
{
for (int y = 0; y < ysections; y++)
@@ -885,7 +897,7 @@ namespace Barotrauma
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
rect.Width + "," + rect.Height));
for (int i = 0; i < sections.Count(); i++)
for (int i = 0; i < sections.Length; i++)
{
if (sections[i].damage == 0.0f) continue;

View File

@@ -172,7 +172,7 @@ namespace Barotrauma
{
get
{
return subBody ==null ? Vector2.Zero : subBody.Position;
return subBody == null ? Vector2.Zero : subBody.Position;
}
}
@@ -304,18 +304,23 @@ namespace Barotrauma
{
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
}
}
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false)
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].DrawOverWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (!MapEntity.mapEntityList[i].DrawOverWater) continue;
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
if (GameMain.DebugDraw)
{
foreach (Submarine sub in Submarine.Loaded)
@@ -335,10 +340,7 @@ namespace Barotrauma
prevPos = currPos;
}
}
}
}
@@ -361,13 +363,14 @@ namespace Barotrauma
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (!MapEntity.mapEntityList[i].DrawBelowWater) continue;
if (predicate != null)
{
if (!predicate(MapEntity.mapEntityList[i])) continue;
}
if (MapEntity.mapEntityList[i].DrawBelowWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
}
}
@@ -484,14 +487,14 @@ namespace Barotrauma
/// check visibility between two points (in sim units)
/// </summary>
/// <returns>a physics body that was between the points (or null)</returns>
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false)
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd, bool ignoreLevel = false, bool ignoreSubs = false)
{
Body closestBody = null;
float closestFraction = 1.0f;
if (Vector2.Distance(rayStart, rayEnd) < 0.01f)
{
closestFraction = 0.01f;
lastPickedPosition = rayEnd;
return null;
}
@@ -501,6 +504,7 @@ namespace Barotrauma
(!fixture.CollisionCategories.HasFlag(Physics.CollisionWall) && !fixture.CollisionCategories.HasFlag(Physics.CollisionLevel))) return -1;
if (ignoreLevel && fixture.CollisionCategories == Physics.CollisionLevel) return -1;
if (ignoreSubs && fixture.Body.UserData is Submarine) return -1;
Structure structure = fixture.Body.UserData as Structure;
if (structure != null)
@@ -527,7 +531,7 @@ namespace Barotrauma
//movement ----------------------------------------------------
private bool flippedX = false;
private bool flippedX;
public bool FlippedX
{
get { return flippedX; }
@@ -643,9 +647,7 @@ namespace Barotrauma
public void SetPosition(Vector2 position)
{
if (!MathUtils.IsValid(position)) return;
Vector2 prevPos = subBody.Position;
subBody.SetPosition(position);
foreach (Submarine sub in loaded)
@@ -674,7 +676,7 @@ namespace Barotrauma
{
Submarine closest = null;
float closestDist = 0.0f;
foreach (Submarine sub in Submarine.loaded)
foreach (Submarine sub in loaded)
{
float dist = Vector2.Distance(worldPosition, sub.WorldPosition);
if (closest == null || dist < closestDist)

View File

@@ -397,7 +397,7 @@ namespace Barotrauma
int particleAmount = (int)(wallImpact*10.0f);
for (int i = 0; i < particleAmount; i++)
{
var particle = GameMain.ParticleManager.CreateParticle("iceshards",
GameMain.ParticleManager.CreateParticle("iceshards",
ConvertUnits.ToDisplayUnits(particlePos[0]) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
Rand.Vector(Rand.Range(50.0f,500.0f)) + Velocity);
}

View File

@@ -465,9 +465,7 @@ namespace Barotrauma
WayPoint[] ladderPoints = new WayPoint[2];
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
WayPoint prevPoint = ladderPoints[0];
Vector2 prevPos = prevPoint.SimPosition;
@@ -619,12 +617,12 @@ namespace Barotrauma
float dist = Vector2.Distance(wp.Position, Position);
if (closest == null || dist < closestDist)
{
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true);
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, true, true);
if (body != null && body != ignoredBody && !(body.UserData is Submarine))
{
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall)) continue;
}
closestDist = dist;
closest = wp;
}