Ghost command, some other stuff

This commit is contained in:
zumorica
2020-03-03 20:37:26 +01:00
parent 055f09d501
commit 7f19381bec
9 changed files with 119 additions and 7 deletions

View File

@@ -273,7 +273,7 @@ namespace Content.Server.GameTicking
private IEntity _spawnPlayerMob(Job job, bool lateJoin = true)
{
GridCoordinates coordinates = lateJoin ? _getLateJoinSpawnPoint() : _getJobSpawnPoint(job.Prototype.ID);
GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
if (entity.TryGetComponent(out InventoryComponent inventory))
{
@@ -299,11 +299,11 @@ namespace Content.Server.GameTicking
private IEntity _spawnObserverMob()
{
GridCoordinates coordinates = _getLateJoinSpawnPoint();
var coordinates = GetObserverSpawnPoint();
return _entityManager.SpawnEntity(ObserverPrototypeName, coordinates);
}
private GridCoordinates _getLateJoinSpawnPoint()
public GridCoordinates GetLateJoinSpawnPoint()
{
var location = _spawnPoint;
@@ -319,7 +319,7 @@ namespace Content.Server.GameTicking
return location;
}
private GridCoordinates _getJobSpawnPoint(string jobId)
public GridCoordinates GetJobSpawnPoint(string jobId)
{
var location = _spawnPoint;
@@ -336,6 +336,23 @@ namespace Content.Server.GameTicking
return location;
}
public GridCoordinates GetObserverSpawnPoint()
{
var location = _spawnPoint;
var possiblePoints = new List<GridCoordinates>();
foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent))))
{
var point = entity.GetComponent<SpawnPointComponent>();
if (point.SpawnType == SpawnPointType.Observer)
possiblePoints.Add(entity.Transform.GridPosition);
}
if (possiblePoints.Count != 0) location = _robustRandom.Pick(possiblePoints);
return location;
}
/// <summary>
/// Cleanup that has to run to clear up anything from the previous round.
/// Stuff like wiping the previous map clean.