mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Renamed SpawnEntityAt to SpawnEntity.
SpawnEntity now throws an exception if an invalid GridID is passed in the coordinates.
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Robust.Client.Console.Commands
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
entityManager.SpawnEntityAt(args[0], player.ControlledEntity.Transform.GridPosition);
|
||||
entityManager.SpawnEntity(args[0], player.ControlledEntity.Transform.GridPosition);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,11 +109,13 @@ namespace Robust.Client.GameObjects
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName)
|
||||
{
|
||||
return CreateEntity(prototypeName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName, GenerateEntityUid());
|
||||
@@ -126,6 +128,7 @@ namespace Robust.Client.GameObjects
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, MapCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName, GenerateEntityUid());
|
||||
@@ -134,6 +137,7 @@ namespace Robust.Client.GameObjects
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntity(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEnt = CreateEntityUninitialized(protoName, coordinates);
|
||||
@@ -141,28 +145,21 @@ namespace Robust.Client.GameObjects
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
public override IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEnt = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)newEnt);
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
public override IEntity SpawnEntityAt(string entityType, GridCoordinates coordinates)
|
||||
{
|
||||
var newEnt = CreateEntityUninitialized(entityType, coordinates);
|
||||
InitializeAndStartEntity((Entity)newEnt);
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntityAt(string entityType, MapCoordinates coordinates)
|
||||
public override IEntity SpawnEntity(string protoName, MapCoordinates coordinates)
|
||||
{
|
||||
var entity = CreateEntityUninitialized(entityType, coordinates);
|
||||
var entity = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
return SpawnEntity(protoName, coordinates);
|
||||
}
|
||||
|
||||
|
||||
protected override EntityUid GenerateEntityUid()
|
||||
{
|
||||
return new EntityUid(_nextClientEntityUid++);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Robust.Server.Console.Commands
|
||||
var ent = IoCManager.Resolve<IServerEntityManager>();
|
||||
if (player?.AttachedEntity != null)
|
||||
{
|
||||
ent.SpawnEntityAt(args[0], player.AttachedEntity.Transform.GridPosition);
|
||||
ent.SpawnEntity(args[0], player.AttachedEntity.Transform.GridPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -29,11 +30,13 @@ namespace Robust.Server.GameObjects
|
||||
|
||||
private readonly List<(GameTick tick, EntityUid uid)> _deletionHistory = new List<(GameTick, EntityUid)>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName)
|
||||
{
|
||||
return CreateEntity(prototypeName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName);
|
||||
@@ -46,6 +49,7 @@ namespace Robust.Server.GameObjects
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, MapCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName);
|
||||
@@ -54,24 +58,13 @@ namespace Robust.Server.GameObjects
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntity(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
var entity = SpawnEntityNoMapInit(protoName, coordinates);
|
||||
entity.RunMapInit();
|
||||
return entity;
|
||||
}
|
||||
if(coordinates.GridID == GridId.Invalid)
|
||||
throw new InvalidOperationException($"Tried to spawn entity {protoName} onto invalid grid.");
|
||||
|
||||
public override IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEnt = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)newEnt);
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntityAt(string entityType, GridCoordinates coordinates)
|
||||
{
|
||||
var entity = CreateEntityUninitialized(entityType, coordinates);
|
||||
var entity = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)entity);
|
||||
var grid = _mapManager.GetGrid(coordinates.GridID);
|
||||
if (_pauseManager.IsMapInitialized(grid.ParentMapId))
|
||||
@@ -82,13 +75,21 @@ namespace Robust.Server.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntityAt(string entityType, MapCoordinates coordinates)
|
||||
public override IEntity SpawnEntity(string protoName, MapCoordinates coordinates)
|
||||
{
|
||||
var entity = CreateEntityUninitialized(entityType, coordinates);
|
||||
var entity = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEnt = CreateEntityUninitialized(protoName, coordinates);
|
||||
InitializeAndStartEntity((Entity)newEnt);
|
||||
return newEnt;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<EntityState> GetEntityStates(GameTick fromTick)
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Robust.Server.Placement
|
||||
*/
|
||||
if (!isTile)
|
||||
{
|
||||
var created = _entityManager.SpawnEntityAt(entityTemplateName, coordinates);
|
||||
var created = _entityManager.SpawnEntity(entityTemplateName, coordinates);
|
||||
|
||||
created.Transform.LocalRotation = dirRcv.ToAngle();
|
||||
}
|
||||
|
||||
@@ -93,19 +93,24 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
#region Entity Management
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity CreateEntityUninitialized(string prototypeName, MapCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntity(string protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntity(string protoName, MapCoordinates coordinates);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates);
|
||||
|
||||
public abstract IEntity SpawnEntityAt(string entityType, GridCoordinates coordinates);
|
||||
|
||||
public abstract IEntity SpawnEntityAt(string entityType, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -45,6 +44,14 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <returns>Newly created entity.</returns>
|
||||
IEntity SpawnEntity(string protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an entity at a specific position
|
||||
/// </summary>
|
||||
/// <param name="protoName"></param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns></returns>
|
||||
IEntity SpawnEntity(string protoName, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an initialized entity at the default location, using the given prototype.
|
||||
/// </summary>
|
||||
@@ -56,22 +63,6 @@ namespace Robust.Shared.Interfaces.GameObjects
|
||||
/// <returns>Newly created entity.</returns>
|
||||
IEntity SpawnEntityNoMapInit(string protoName, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an entity at a specific position
|
||||
/// </summary>
|
||||
/// <param name="entityType"></param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns></returns>
|
||||
IEntity SpawnEntityAt(string entityType, GridCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Spawns an entity at a specific position
|
||||
/// </summary>
|
||||
/// <param name="entityType"></param>
|
||||
/// <param name="coordinates"></param>
|
||||
/// <returns></returns>
|
||||
IEntity SpawnEntityAt(string entityType, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
/// </summary>
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
mapMan.CreateNewMapEntity(MapId.Nullspace);
|
||||
|
||||
// Act
|
||||
var newEntity = entMan.SpawnEntityAt(null, MapCoordinates.Nullspace);
|
||||
var newEntity = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
|
||||
// Assert
|
||||
Assert.That(newEntity.Transform.MapID, Is.EqualTo(MapId.Nullspace));
|
||||
|
||||
Reference in New Issue
Block a user