Split Machines ItemComponents

There's still a lot of work to do before we can get the server to compile
This commit is contained in:
Juan Pablo Arce
2017-06-18 14:36:11 -03:00
parent 7168a534ed
commit 8f37e14917
98 changed files with 5264 additions and 4291 deletions
+14 -57
View File
@@ -10,11 +10,10 @@ using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking;
using Barotrauma.Lights;
namespace Barotrauma
{
class WallSection
partial class WallSection
{
public Rectangle rect;
public float damage;
@@ -24,8 +23,6 @@ namespace Barotrauma
//public float lastSentDamage;
public ConvexHull hull;
public WallSection(Rectangle rect)
{
System.Diagnostics.Debug.Assert(rect.Width > 0 && rect.Height > 0);
@@ -48,8 +45,6 @@ namespace Barotrauma
public static int wallSectionSize = 96;
public static List<Structure> WallList = new List<Structure>();
List<ConvexHull> convexHulls;
StructurePrefab prefab;
//farseer physics bodies, separated by gaps
@@ -202,10 +197,12 @@ namespace Barotrauma
}
}
#if CLIENT
if (convexHulls!=null)
{
convexHulls.ForEach(x => x.Move(amount));
}
#endif
}
public Structure(Rectangle rectangle, StructurePrefab sp, Submarine submarine)
@@ -257,10 +254,12 @@ namespace Barotrauma
}
}
#if CLIENT
if (prefab.CastShadow)
{
GenerateConvexHull();
}
#endif
InsertToList();
}
@@ -361,43 +360,6 @@ namespace Barotrauma
}
}
private void GenerateConvexHull()
{
// If not null and not empty , remove the hulls from the system
if(convexHulls != null && convexHulls.Any())
convexHulls.ForEach(x => x.Remove());
// list all of hulls for this structure
convexHulls = new List<ConvexHull>();
var mergedSections = new List<WallSection>();
foreach (var section in sections)
{
if (mergedSections.Count > 5)
{
mergedSections.Add(section);
GenerateMergedHull(mergedSections);
continue;
}
// if there is a gap and we have sections to merge, do it.
if (section.gap != null)
{
GenerateMergedHull(mergedSections);
}
else
{
mergedSections.Add(section);
}
}
// take care of any leftover pieces
if (mergedSections.Count > 0)
{
GenerateMergedHull(mergedSections);
}
}
private Rectangle GenerateMergedRect(List<WallSection> mergedSections)
{
if (isHorizontal)
@@ -410,17 +372,6 @@ namespace Barotrauma
}
}
private void GenerateMergedHull(List<WallSection> mergedSections)
{
if (!mergedSections.Any()) return;
Rectangle mergedRect = GenerateMergedRect(mergedSections);
var h = new ConvexHull(CalculateExtremes(mergedRect), Color.Black, this);
mergedSections.ForEach(x => x.hull = h);
convexHulls.Add(h);
mergedSections.Clear();
}
private static Vector2[] CalculateExtremes(Rectangle sectionRect)
{
Vector2[] corners = new Vector2[4];
@@ -477,7 +428,9 @@ namespace Barotrauma
}
}
#if CLIENT
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
#endif
}
public override void Remove()
@@ -504,7 +457,9 @@ namespace Barotrauma
}
}
#if CLIENT
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
#endif
}
public override bool IsVisible(Rectangle WorldView)
@@ -708,8 +663,9 @@ namespace Barotrauma
//remove existing gap if damage is below 50%
sections[sectionIndex].gap.Remove();
sections[sectionIndex].gap = null;
if(CastShadow)
GenerateConvexHull();
#if CLIENT
if(CastShadow) GenerateConvexHull();
#endif
}
}
else
@@ -723,8 +679,9 @@ namespace Barotrauma
gapRect.Height += 20;
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
sections[sectionIndex].gap.ConnectedWall = this;
#if CLIENT
if(CastShadow) GenerateConvexHull();
#endif
}
sections[sectionIndex].gap.Open = (damage / prefab.MaxHealth - 0.5f) * 2.0f;