fix some errors

This commit is contained in:
Mister_Nebula 2021-03-31 15:43:55 +01:00
parent 7d6aa70d6e
commit 1824a5481c
4 changed files with 22 additions and 14 deletions

View File

@ -125,10 +125,16 @@ namespace QSB.DeathSync
}
private SpawnPoint GetSpawnPoint(bool isShip = false)
=> _playerSpawner
.GetValue<SpawnPoint[]>("_spawnList")
.FirstOrDefault(spawnPoint =>
{
var spawnList = _playerSpawner.GetValue<SpawnPoint[]>("_spawnList");
if (spawnList == null)
{
DebugLog.ToConsole($"Warning - _spawnList was null for player spawner!", MessageType.Warning);
return null;
}
return spawnList.FirstOrDefault(spawnPoint =>
spawnPoint.GetSpawnLocation() == SpawnLocation.TimberHearth
&& spawnPoint.IsShipSpawn() == isShip);
}
}
}

View File

@ -146,10 +146,13 @@ namespace QSB
}
var offset3 = 10f;
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current closest sector :");
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current synced sector :");
offset3 += _debugLineSpacing;
var sector = PlayerTransformSync.LocalInstance.SectorSync.GetClosestSector(Locator.GetPlayerTransform());
GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {sector.AttachedObject.name} : {sector.IsFakeSector}");
var sector = PlayerTransformSync.LocalInstance.ReferenceSector;
var text = sector == null
? "NULL SECTOR"
: $"{sector.AttachedObject.name} : {sector.IsFakeSector}";
GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {text}");
offset3 += _debugLineSpacing;
var offset2 = 10f;

View File

@ -92,9 +92,7 @@ namespace QSB.SectorSync
&& sector.ShouldSyncTo());
if (activeNotNullNotBlacklisted.Count() == 0)
{
DebugLog.ToConsole(
$"Error - Zero available sectors for {trans.name} to sync to! Current QSBSector count : {QSBWorldSync.GetWorldObjects<QSBSector>().Count()}",
MessageType.Error);
return default;
}
var ordered = activeNotNullNotBlacklisted
.OrderBy(sector => Vector3.Distance(sector.Position, trans.position))

View File

@ -34,16 +34,17 @@ namespace QSB.SectorSync.WorldObjects
public bool ShouldSyncTo()
{
if (!AttachedObject.gameObject.activeInHierarchy)
{
return false;
}
if (AttachedObject == null)
{
DebugLog.ToConsole($"Warning - AttachedObject for sector id:{ObjectId} is null!", MessageType.Warning);
return false;
}
if (!AttachedObject.gameObject.activeInHierarchy)
{
return false;
}
if (Type == Sector.Name.Ship)
{
return false;