Add a check for construction ghosts beeing present to ConstructionSystem/SpawnGhost (#1642)
This commit is contained in:
@@ -153,6 +153,11 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
/// </summary>
|
||||
public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir)
|
||||
{
|
||||
if (GhostPresent(loc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ghost = _entityManager.SpawnEntity("constructionghost", loc);
|
||||
var comp = ghost.GetComponent<ConstructionGhostComponent>();
|
||||
comp.Prototype = prototype;
|
||||
@@ -167,6 +172,22 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
sprite.LayerSetVisible(0, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any construction ghosts are present at the given position
|
||||
/// </summary>
|
||||
private bool GhostPresent(GridCoordinates loc)
|
||||
{
|
||||
foreach (KeyValuePair<int, ConstructionGhostComponent> ghost in _ghosts)
|
||||
{
|
||||
if (ghost.Value.Owner.Transform.GridPosition.Equals(loc))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void TryStartConstruction(int ghostId)
|
||||
{
|
||||
var ghost = _ghosts[ghostId];
|
||||
|
||||
Reference in New Issue
Block a user