Fixed #7 (re-applied)
This commit is contained in:
@@ -2,16 +2,17 @@
|
|||||||
using Barotrauma.IO;
|
using Barotrauma.IO;
|
||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
|
using Barotrauma.PerkBehaviors;
|
||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Barotrauma.PerkBehaviors;
|
|
||||||
using Voronoi2;
|
using Voronoi2;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
@@ -508,23 +509,16 @@ namespace Barotrauma
|
|||||||
return dockedBorders;
|
return dockedBorders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly HashSet<Submarine> connectedSubs;
|
private readonly ConcurrentBag<Submarine> connectedSubs;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of all submarines that are connected to this one via docking ports, including this sub.
|
/// Returns a list of all submarines that are connected to this one via docking ports, including this sub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<Submarine> GetConnectedSubs()
|
public ConcurrentBag<Submarine> GetConnectedSubs()
|
||||||
{
|
{
|
||||||
return connectedSubs;
|
return connectedSubs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshConnectedSubs()
|
private void GetConnectedSubsRecursive(ConcurrentBag<Submarine> subs)
|
||||||
{
|
|
||||||
connectedSubs.Clear();
|
|
||||||
connectedSubs.Add(this);
|
|
||||||
GetConnectedSubsRecursive(connectedSubs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetConnectedSubsRecursive(HashSet<Submarine> subs)
|
|
||||||
{
|
{
|
||||||
foreach (Submarine dockedSub in DockedTo)
|
foreach (Submarine dockedSub in DockedTo)
|
||||||
{
|
{
|
||||||
@@ -534,6 +528,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshConnectedSubs()
|
||||||
|
{
|
||||||
|
connectedSubs.Clear();
|
||||||
|
connectedSubs.Add(this);
|
||||||
|
GetConnectedSubsRecursive(connectedSubs);
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to find a spawn position close to the specified position where the sub doesn't collide with walls/ruins
|
/// Attempt to find a spawn position close to the specified position where the sub doesn't collide with walls/ruins
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1551,6 +1551,7 @@ namespace Barotrauma
|
|||||||
if (includingConnectedSubs)
|
if (includingConnectedSubs)
|
||||||
{
|
{
|
||||||
// Performance-sensitive code -> implemented without Linq.
|
// Performance-sensitive code -> implemented without Linq.
|
||||||
|
|
||||||
foreach (Submarine s in connectedSubs)
|
foreach (Submarine s in connectedSubs)
|
||||||
{
|
{
|
||||||
if (s == entity.Submarine && (allowDifferentTeam || entity.Submarine.TeamID == TeamID) && (allowDifferentType || entity.Submarine.Info.Type == Info.Type))
|
if (s == entity.Submarine && (allowDifferentTeam || entity.Submarine.TeamID == TeamID) && (allowDifferentType || entity.Submarine.Info.Type == Info.Type))
|
||||||
@@ -1642,7 +1643,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Stopwatch sw = Stopwatch.StartNew();
|
Stopwatch sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
connectedSubs = new HashSet<Submarine>(2)
|
connectedSubs = new ConcurrentBag<Submarine>
|
||||||
{
|
{
|
||||||
this
|
this
|
||||||
};
|
};
|
||||||
@@ -1829,7 +1830,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Screen.Selected is { IsEditor : false })
|
if (Screen.Selected is { IsEditor: false })
|
||||||
{
|
{
|
||||||
foreach (Identifier layer in Info.LayersHiddenByDefault)
|
foreach (Identifier layer in Info.LayersHiddenByDefault)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user