Fixed character getting spawned at a random spawnpoint in any sub if no spawpoint that fits the character's job is found, making it possible for them to spawn inside the respawn shuttle. Closes #408
This commit is contained in:
@@ -281,7 +281,7 @@ namespace Barotrauma
|
|||||||
listBox.ClearChildren();
|
listBox.ClearChildren();
|
||||||
characters.Clear();
|
characters.Clear();
|
||||||
|
|
||||||
WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub, false);
|
WayPoint[] waypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub);
|
||||||
|
|
||||||
for (int i = 0; i < waypoints.Length; i++)
|
for (int i = 0; i < waypoints.Length; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ namespace Barotrauma
|
|||||||
return wayPoints[Rand.Int(wayPoints.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))];
|
return wayPoints[Rand.Int(wayPoints.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew, Submarine submarine, bool tryAssignWayPoint = true)
|
public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew, Submarine submarine)
|
||||||
{
|
{
|
||||||
List<WayPoint> subWayPoints = WayPointList.FindAll(wp => wp.Submarine == submarine);
|
List<WayPoint> subWayPoints = WayPointList.FindAll(wp => wp.Submarine == submarine);
|
||||||
|
|
||||||
@@ -524,29 +524,24 @@ namespace Barotrauma
|
|||||||
assignedWayPoints[i] = wp;
|
assignedWayPoints[i] = wp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assignedWayPoints[i] != null) continue;
|
if (assignedWayPoints[i] != null) continue;
|
||||||
|
|
||||||
if (tryAssignWayPoint)
|
//try to assign a spawnpoint that isn't meant for any specific job
|
||||||
|
var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
|
||||||
|
if (nonJobSpecificPoints.Any())
|
||||||
{
|
{
|
||||||
//try to assign a spawnpoint that isn't meant for any specific job
|
assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, Rand.RandSync.Server)];
|
||||||
var nonJobSpecificPoints = subWayPoints.FindAll(wp => wp.spawnType == SpawnType.Human && wp.assignedJob == null);
|
|
||||||
|
|
||||||
if (nonJobSpecificPoints.Any())
|
|
||||||
{
|
|
||||||
assignedWayPoints[i] = nonJobSpecificPoints[Rand.Int(nonJobSpecificPoints.Count, Rand.RandSync.Server)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assignedWayPoints[i] != null) continue;
|
if (assignedWayPoints[i] != null) continue;
|
||||||
|
|
||||||
//everything else failed -> just give a random spawnpoint
|
//everything else failed -> just give a random spawnpoint inside the sub
|
||||||
assignedWayPoints[i] = GetRandom(SpawnType.Human);
|
assignedWayPoints[i] = GetRandom(SpawnType.Human, null, submarine, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < assignedWayPoints.Length; i++ )
|
for (int i = 0; i < assignedWayPoints.Length; i++)
|
||||||
{
|
{
|
||||||
if (assignedWayPoints[i]==null)
|
if (assignedWayPoints[i] == null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Couldn't find a waypoint for " + crew[i].Name + "!");
|
DebugConsole.ThrowError("Couldn't find a waypoint for " + crew[i].Name + "!");
|
||||||
assignedWayPoints[i] = WayPointList[0];
|
assignedWayPoints[i] = WayPointList[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user