mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Arch related engine changes (#4806)
This commit is contained in:
@@ -35,7 +35,7 @@ END TEMPLATE-->
|
||||
|
||||
### Breaking changes
|
||||
|
||||
*None yet*
|
||||
* Various entity manager methods now have a new `where T : IComponent` constraint.
|
||||
|
||||
### New features
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public sealed class ProfileEntitySpawningCommand : IConsoleCommand
|
||||
|
||||
GC.Collect();
|
||||
|
||||
Span<EntityUid> ents = stackalloc EntityUid[amount];
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
@@ -50,12 +51,17 @@ public sealed class ProfileEntitySpawningCommand : IConsoleCommand
|
||||
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
_entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
|
||||
ents[i] = _entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
|
||||
}
|
||||
|
||||
MeasureProfiler.SaveData();
|
||||
|
||||
shell.WriteLine($"Client: Profiled spawning {amount} entities in {stopwatch.Elapsed.TotalMilliseconds:N3} ms");
|
||||
|
||||
foreach (var ent in ents)
|
||||
{
|
||||
_entities.DeleteEntity(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Map;
|
||||
using Robust.Client.Physics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Client.GameObjects;
|
||||
|
||||
@@ -27,9 +24,4 @@ public sealed class MapSystem : SharedMapSystem
|
||||
base.Shutdown();
|
||||
_overlayManager.RemoveOverlay<TileEdgeOverlay>();
|
||||
}
|
||||
|
||||
protected override void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args)
|
||||
{
|
||||
EnsureComp<PhysicsMapComponent>(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Robust.Client.Placement.Modes
|
||||
|
||||
var closestEntity = snapToEntities[0];
|
||||
var closestTransform = pManager.EntityManager.GetComponent<TransformComponent>(closestEntity);
|
||||
if (!pManager.EntityManager.TryGetComponent<SpriteComponent?>(closestEntity, out var component) || component.BaseRSI == null)
|
||||
if (!pManager.EntityManager.TryGetComponent(closestEntity, out SpriteComponent? component) || component.BaseRSI == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public sealed class ProfileEntitySpawningCommand : IConsoleCommand
|
||||
|
||||
GC.Collect();
|
||||
|
||||
Span<EntityUid> ents = stackalloc EntityUid[amount];
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
@@ -50,12 +51,17 @@ public sealed class ProfileEntitySpawningCommand : IConsoleCommand
|
||||
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
_entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
|
||||
ents[i] = _entities.SpawnEntity(prototype, MapCoordinates.Nullspace);
|
||||
}
|
||||
|
||||
MeasureProfiler.SaveData();
|
||||
|
||||
shell.WriteLine($"Server: Profiled spawning {amount} entities in {stopwatch.Elapsed.TotalMilliseconds:N3} ms");
|
||||
|
||||
foreach (var ent in ents)
|
||||
{
|
||||
_entities.DeleteEntity(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -31,11 +31,6 @@ namespace Robust.Server.GameObjects
|
||||
_cfg.OnValueChanged(CVars.GameDeleteEmptyGrids, SetGridDeletion, true);
|
||||
}
|
||||
|
||||
protected override void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args)
|
||||
{
|
||||
EnsureComp<PhysicsMapComponent>(uid);
|
||||
}
|
||||
|
||||
private void SetGridDeletion(bool value)
|
||||
{
|
||||
_deleteEmptyGrids = value;
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Robust.Server.Placement
|
||||
/// </summary>
|
||||
public void SendPlacementBegin(EntityUid mob, int range, string objectType, string alignOption)
|
||||
{
|
||||
if (!_entityManager.TryGetComponent<ActorComponent?>(mob, out var actor))
|
||||
if (!_entityManager.TryGetComponent(mob, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
var playerConnection = actor.PlayerSession.Channel;
|
||||
@@ -276,7 +276,7 @@ namespace Robust.Server.Placement
|
||||
/// </summary>
|
||||
public void SendPlacementBeginTile(EntityUid mob, int range, string tileType, string alignOption)
|
||||
{
|
||||
if (!_entityManager.TryGetComponent<ActorComponent?>(mob, out var actor))
|
||||
if (!_entityManager.TryGetComponent(mob, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
var playerConnection = actor.PlayerSession.Channel;
|
||||
@@ -297,7 +297,7 @@ namespace Robust.Server.Placement
|
||||
/// </summary>
|
||||
public void SendPlacementCancel(EntityUid mob)
|
||||
{
|
||||
if (!_entityManager.TryGetComponent<ActorComponent?>(mob, out var actor))
|
||||
if (!_entityManager.TryGetComponent(mob, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
var playerConnection = actor.PlayerSession.Channel;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Completion;
|
||||
@@ -294,9 +295,9 @@ namespace Robust.Server.Scripting
|
||||
loader: TextLoader.From(TextAndVersion.Create(SourceText.From(message.Code), VersionStamp.Create()))
|
||||
));
|
||||
|
||||
var results = await CompletionService
|
||||
.GetService(document)
|
||||
.GetCompletionsAsync(document, message.Cursor);
|
||||
var results = await (CompletionService
|
||||
.GetService(document)?
|
||||
.GetCompletionsAsync(document, message.Cursor) ?? Task.FromResult<CompletionList?>(null));
|
||||
|
||||
if (results is not null)
|
||||
{
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace Robust.Shared.Scripting
|
||||
public bool TryComp<T>(EntityUid uid, out T? comp) where T : IComponent
|
||||
=> ent.TryGetComponent(uid, out comp);
|
||||
|
||||
public bool HasComp<T>(EntityUid uid)
|
||||
public bool HasComp<T>(EntityUid uid) where T : IComponent
|
||||
=> ent.HasComponent<T>(uid);
|
||||
|
||||
public EntityUid Spawn(string? prototype, EntityCoordinates position)
|
||||
|
||||
@@ -55,17 +55,4 @@ namespace Robust.Shared.GameObjects
|
||||
Meta = meta;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct DeletedComponentEventArgs
|
||||
{
|
||||
public readonly ComponentEventArgs BaseArgs;
|
||||
|
||||
public readonly bool Terminating;
|
||||
|
||||
public DeletedComponentEventArgs(ComponentEventArgs baseArgs, bool terminating)
|
||||
{
|
||||
BaseArgs = baseArgs;
|
||||
Terminating = terminating;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool HasComponent<T>(EntityUid uid)
|
||||
public bool HasComponent<T>(EntityUid uid) where T : IComponent
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
|
||||
@@ -635,7 +635,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool HasComponent<T>(EntityUid? uid)
|
||||
public bool HasComponent<T>(EntityUid? uid) where T : IComponent
|
||||
{
|
||||
return uid.HasValue && HasComponent<T>(uid.Value);
|
||||
}
|
||||
@@ -804,7 +804,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T? component)
|
||||
public bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T? component) where T : IComponent?
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
DebugTools.Assert(dict != null, $"Unknown component: {typeof(T).Name}");
|
||||
@@ -822,7 +822,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent<T>([NotNullWhen(true)] EntityUid? uid, [NotNullWhen(true)] out T? component)
|
||||
public bool TryGetComponent<T>([NotNullWhen(true)] EntityUid? uid, [NotNullWhen(true)] out T? component) where T : IComponent?
|
||||
{
|
||||
if (!uid.HasValue)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,16 @@ public partial class EntityManager
|
||||
return ents;
|
||||
}
|
||||
|
||||
public EntityUid[] SpawnEntities(MapCoordinates coordinates, string? prototype, int count)
|
||||
{
|
||||
var ents = new EntityUid[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
ents[i] = Spawn(prototype, coordinates);
|
||||
}
|
||||
return ents;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EntityUid[] SpawnEntitiesAttachedTo(EntityCoordinates coordinates, List<string?> protoNames)
|
||||
{
|
||||
|
||||
@@ -540,7 +540,7 @@ public partial class EntitySystem
|
||||
/// Retrieves whether the entity has the specified component or not.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool HasComp<T>(EntityUid uid)
|
||||
protected bool HasComp<T>(EntityUid uid) where T : IComponent
|
||||
{
|
||||
return EntityManager.HasComponent<T>(uid);
|
||||
}
|
||||
@@ -558,7 +558,7 @@ public partial class EntitySystem
|
||||
/// Retrieves whether the entity has the specified component or not.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool HasComp<T>([NotNullWhen(true)] EntityUid? uid)
|
||||
protected bool HasComp<T>([NotNullWhen(true)] EntityUid? uid) where T : IComponent
|
||||
{
|
||||
return EntityManager.HasComponent<T>(uid);
|
||||
}
|
||||
@@ -629,13 +629,6 @@ public partial class EntitySystem
|
||||
return EntityManager.RemoveComponentDeferred(uid, type);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponentDeferred(EntityUid, Component)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void RemCompDeferred(EntityUid uid, Component component)
|
||||
{
|
||||
EntityManager.RemoveComponentDeferred(uid, component);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponentDeferred(EntityUid, IComponent)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void RemCompDeferred(EntityUid uid, IComponent component)
|
||||
@@ -678,13 +671,6 @@ public partial class EntitySystem
|
||||
return EntityManager.RemoveComponent(uid, type);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponent(EntityUid, Component)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void RemComp(EntityUid uid, Component component)
|
||||
{
|
||||
EntityManager.RemoveComponent(uid, component);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.RemoveComponent(EntityUid, IComponent)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void RemComp(EntityUid uid, IComponent component)
|
||||
@@ -955,6 +941,12 @@ public partial class EntitySystem
|
||||
return EntityManager.IsClientSide(entity, meta);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool IsClientSide(Entity<MetaDataComponent> entity)
|
||||
{
|
||||
return EntityManager.IsClientSide(entity, entity.Comp);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool TryGetEntity(NetEntity nEntity, [NotNullWhen(true)] out EntityUid? entity)
|
||||
{
|
||||
|
||||
@@ -136,14 +136,6 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="component">Component to remove.</param>
|
||||
void RemoveComponentDeferred(EntityUid uid, IComponent component);
|
||||
|
||||
/// <summary>
|
||||
/// Immediately shuts down a component, but defers the removal and deletion until the end of the tick.
|
||||
/// Throws if the given component does not belong to the entity.
|
||||
/// </summary>
|
||||
/// <param name="uid">Entity UID to modify.</param>
|
||||
/// <param name="component">Component to remove.</param>
|
||||
void RemoveComponentDeferred(EntityUid uid, Component component);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all components from an entity, except the required components.
|
||||
/// </summary>
|
||||
@@ -164,7 +156,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <typeparam name="T">Component reference type to check for.</typeparam>
|
||||
/// <param name="uid">Entity UID to check.</param>
|
||||
/// <returns>True if the entity has the component type, otherwise false.</returns>
|
||||
bool HasComponent<T>(EntityUid uid);
|
||||
bool HasComponent<T>(EntityUid uid) where T : IComponent;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the entity has a component type.
|
||||
@@ -172,7 +164,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <typeparam name="T">Component reference type to check for.</typeparam>
|
||||
/// <param name="uid">Entity UID to check.</param>
|
||||
/// <returns>True if the entity has the component type, otherwise false.</returns>
|
||||
bool HasComponent<T>(EntityUid? uid);
|
||||
bool HasComponent<T>(EntityUid? uid) where T : IComponent;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the entity has a component type.
|
||||
@@ -281,7 +273,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid">Entity UID to check.</param>
|
||||
/// <param name="component">Component of the specified type (if exists).</param>
|
||||
/// <returns>If the component existed in the entity.</returns>
|
||||
bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T? component);
|
||||
bool TryGetComponent<T>(EntityUid uid, [NotNullWhen(true)] out T? component) where T : IComponent?;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component of a specific type.
|
||||
@@ -290,7 +282,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="uid">Entity UID to check.</param>
|
||||
/// <param name="component">Component of the specified type (if exists).</param>
|
||||
/// <returns>If the component existed in the entity.</returns>
|
||||
bool TryGetComponent<T>([NotNullWhen(true)] EntityUid? uid, [NotNullWhen(true)] out T? component);
|
||||
bool TryGetComponent<T>([NotNullWhen(true)] EntityUid? uid, [NotNullWhen(true)] out T? component) where T : IComponent?;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component of a specific type.
|
||||
|
||||
@@ -19,6 +19,7 @@ public partial interface IEntityManager
|
||||
EntityUid SpawnEntity(string? protoName, MapCoordinates coordinates, ComponentRegistry? overrides = null);
|
||||
|
||||
EntityUid[] SpawnEntities(MapCoordinates coordinates, params string?[] protoNames);
|
||||
EntityUid[] SpawnEntities(MapCoordinates coordinates, string? prototype, int count);
|
||||
EntityUid[] SpawnEntities(MapCoordinates coordinates, List<string?> protoNames);
|
||||
EntityUid[] SpawnEntitiesAttachedTo(EntityCoordinates coordinates, List<string?> protoNames);
|
||||
EntityUid[] SpawnEntitiesAttachedTo(EntityCoordinates coordinates, params string?[] protoNames);
|
||||
@@ -52,7 +53,7 @@ public partial interface IEntityManager
|
||||
EntityUid containerUid,
|
||||
string containerId,
|
||||
[NotNullWhen(true)] out EntityUid? uid,
|
||||
ContainerManagerComponent? containerComp = null,
|
||||
ContainerManagerComponent? containerComp = null,
|
||||
ComponentRegistry? overrides = null);
|
||||
|
||||
/// <summary>
|
||||
@@ -64,7 +65,7 @@ public partial interface IEntityManager
|
||||
EntityUid containerUid,
|
||||
string containerId,
|
||||
TransformComponent? xform = null,
|
||||
ContainerManagerComponent? containerComp = null,
|
||||
ContainerManagerComponent? containerComp = null,
|
||||
ComponentRegistry? overrides = null);
|
||||
|
||||
/// <summary>
|
||||
@@ -84,8 +85,8 @@ public partial interface IEntityManager
|
||||
/// instead attempt to spawn the entity next to the target's parent.
|
||||
/// </summary>
|
||||
EntityUid SpawnNextToOrDrop(
|
||||
string? protoName,
|
||||
EntityUid target,
|
||||
TransformComponent? xform = null,
|
||||
string? protoName,
|
||||
EntityUid target,
|
||||
TransformComponent? xform = null,
|
||||
ComponentRegistry? overrides = null);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ public sealed partial class EntityLookupSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<BroadphaseComponent, EntityTerminatingEvent>(OnBroadphaseTerminating);
|
||||
SubscribeLocalEvent<BroadphaseComponent, ComponentAdd>(OnBroadphaseAdd);
|
||||
SubscribeLocalEvent<GridAddEvent>(OnGridAdd);
|
||||
SubscribeLocalEvent<MapChangedEvent>(OnMapChange);
|
||||
|
||||
_transform.OnGlobalMoveEvent += OnMove;
|
||||
@@ -193,12 +192,6 @@ public sealed partial class EntityLookupSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGridAdd(GridAddEvent ev)
|
||||
{
|
||||
// Must be done before initialization as that's when broadphase data starts getting set.
|
||||
EnsureComp<BroadphaseComponent>(ev.EntityUid);
|
||||
}
|
||||
|
||||
private void OnBroadphaseAdd(EntityUid uid, BroadphaseComponent component, ComponentAdd args)
|
||||
{
|
||||
component.StaticSundriesTree = new DynamicTree<EntityUid>(
|
||||
|
||||
@@ -439,8 +439,7 @@ public abstract partial class SharedMapSystem
|
||||
|
||||
private void OnGridInit(EntityUid uid, MapGridComponent component, ComponentInit args)
|
||||
{
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var xform = xformQuery.GetComponent(uid);
|
||||
var xform = _xformQuery.GetComponent(uid);
|
||||
|
||||
// Force networkedmapmanager to send it due to non-ECS legacy code.
|
||||
var curTick = _timing.CurTick;
|
||||
@@ -453,7 +452,7 @@ public abstract partial class SharedMapSystem
|
||||
component.LastTileModifiedTick = curTick;
|
||||
|
||||
if (xform.MapUid != null && xform.MapUid != uid)
|
||||
_transform.SetParent(uid, xform, xform.MapUid.Value, xformQuery);
|
||||
_transform.SetParent(uid, xform, xform.MapUid.Value);
|
||||
|
||||
if (!HasComp<MapComponent>(uid))
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@ public abstract partial class SharedMapSystem
|
||||
{
|
||||
private void InitializeMap()
|
||||
{
|
||||
SubscribeLocalEvent<MapComponent, ComponentAdd>(OnMapAdd);
|
||||
SubscribeLocalEvent<MapComponent, ComponentInit>(OnMapInit);
|
||||
SubscribeLocalEvent<MapComponent, ComponentShutdown>(OnMapRemoved);
|
||||
SubscribeLocalEvent<MapComponent, ComponentHandleState>(OnMapHandleState);
|
||||
@@ -43,8 +42,6 @@ public abstract partial class SharedMapSystem
|
||||
args.State = new MapComponentState(component.MapId, component.LightingEnabled, component.MapPaused);
|
||||
}
|
||||
|
||||
protected abstract void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args);
|
||||
|
||||
private void OnMapInit(EntityUid uid, MapComponent component, ComponentInit args)
|
||||
{
|
||||
EnsureComp<GridTreeComponent>(uid);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Robust.Shared.Localization
|
||||
|
||||
private bool TryGetEntityLocAttrib(EntityUid entity, string attribute, [NotNullWhen(true)] out string? value)
|
||||
{
|
||||
if (_entMan.TryGetComponent<GrammarComponent?>(entity, out var grammar) &&
|
||||
if (_entMan.TryGetComponent(entity, out GrammarComponent? grammar) &&
|
||||
grammar.Attributes.TryGetValue(attribute, out value))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Robust.Shared.Localization
|
||||
{
|
||||
EntityUid entity = (EntityUid)entity0.Value;
|
||||
|
||||
if (_entMan.TryGetComponent<GrammarComponent?>(entity, out var grammar) && grammar.Gender.HasValue)
|
||||
if (_entMan.TryGetComponent(entity, out GrammarComponent? grammar) && grammar.Gender.HasValue)
|
||||
{
|
||||
return new LocValueString(grammar.Gender.Value.ToString().ToLowerInvariant());
|
||||
}
|
||||
@@ -307,7 +307,7 @@ namespace Robust.Shared.Localization
|
||||
{
|
||||
EntityUid entity = (EntityUid)entity0.Value;
|
||||
|
||||
if (_entMan.TryGetComponent<GrammarComponent?>(entity, out var grammar) && grammar.ProperNoun.HasValue)
|
||||
if (_entMan.TryGetComponent(entity, out GrammarComponent? grammar) && grammar.ProperNoun.HasValue)
|
||||
{
|
||||
return new LocValueString(grammar.ProperNoun.Value.ToString().ToLowerInvariant());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ namespace Robust.Shared.Map
|
||||
/// </summary>
|
||||
public float Y => Position.Y;
|
||||
|
||||
public EntityCoordinates()
|
||||
{
|
||||
EntityId = EntityUid.Invalid;
|
||||
Position = Vector2.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="EntityCoordinates"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
// All the obsolete warnings about GridId are probably useless here.
|
||||
@@ -159,6 +161,9 @@ internal partial class MapManager
|
||||
|
||||
var grid = EntityManager.AddComponent<MapGridComponent>(gridEnt);
|
||||
grid.ChunkSize = chunkSize;
|
||||
EntityManager.AddComponent<PhysicsComponent>(gridEnt);
|
||||
EntityManager.AddComponent<FixturesComponent>(gridEnt);
|
||||
EntityManager.AddComponent<BroadphaseComponent>(gridEnt);
|
||||
|
||||
_sawmill.Debug($"Binding new grid {gridEnt}");
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.Map;
|
||||
@@ -233,6 +234,7 @@ internal partial class MapManager
|
||||
|
||||
var mapComp = EntityManager.AddComponent<MapComponent>(newEnt);
|
||||
mapComp.MapId = actualId;
|
||||
EntityManager.AddComponent<PhysicsMapComponent>(newEnt);
|
||||
var meta = EntityManager.GetComponent<MetaDataComponent>(newEnt);
|
||||
EntityManager.System<MetaDataSystem>().SetEntityName(newEnt, $"map {actualId}", meta);
|
||||
EntityManager.Dirty(newEnt, mapComp, meta);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.BroadPhase;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
@@ -6,7 +7,7 @@ namespace Robust.Shared.Physics
|
||||
/// <summary>
|
||||
/// Stores the broadphase structure for the relevant grid / map.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class BroadphaseComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -322,7 +322,7 @@ public partial class SharedPhysicsSystem
|
||||
body.AngularVelocity = value;
|
||||
|
||||
if (dirty)
|
||||
Dirty(body);
|
||||
Dirty(uid, body);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -347,7 +347,7 @@ public partial class SharedPhysicsSystem
|
||||
body.LinearVelocity = velocity;
|
||||
|
||||
if (dirty)
|
||||
Dirty(body);
|
||||
Dirty(uid, body);
|
||||
}
|
||||
|
||||
public void SetAngularDamping(PhysicsComponent body, float value, bool dirty = true)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
PhysMapQuery = GetEntityQuery<PhysicsMapComponent>();
|
||||
MapQuery = GetEntityQuery<MapComponent>();
|
||||
|
||||
SubscribeLocalEvent<GridAddEvent>(OnGridAdd);
|
||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridAdd);
|
||||
SubscribeLocalEvent<CollisionChangeEvent>(OnCollisionChange);
|
||||
SubscribeLocalEvent<PhysicsComponent, EntGotRemovedFromContainerMessage>(HandleContainerRemoved);
|
||||
SubscribeLocalEvent<EntParentChangedMessage>(OnParentChange);
|
||||
@@ -183,14 +183,12 @@ namespace Robust.Shared.Physics.Systems
|
||||
/// </summary>
|
||||
private void HandleMapChange(EntityUid uid, TransformComponent xform, PhysicsComponent? body, MapId oldMapId, MapId newMapId)
|
||||
{
|
||||
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var jointQuery = GetEntityQuery<JointComponent>();
|
||||
|
||||
PhysMapQuery.TryGetComponent(_mapManager.GetMapEntityId(oldMapId), out var oldMap);
|
||||
PhysMapQuery.TryGetComponent(_mapManager.GetMapEntityId(newMapId), out var newMap);
|
||||
|
||||
RecursiveMapUpdate(uid, xform, body, newMap, oldMap, bodyQuery, xformQuery, jointQuery);
|
||||
RecursiveMapUpdate(uid, xform, body, newMap, oldMap, jointQuery);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -202,8 +200,6 @@ namespace Robust.Shared.Physics.Systems
|
||||
PhysicsComponent? body,
|
||||
PhysicsMapComponent? newMap,
|
||||
PhysicsMapComponent? oldMap,
|
||||
EntityQuery<PhysicsComponent> bodyQuery,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<JointComponent> jointQuery)
|
||||
{
|
||||
DebugTools.Assert(!Deleted(uid));
|
||||
@@ -227,15 +223,15 @@ namespace Robust.Shared.Physics.Systems
|
||||
|
||||
foreach (var child in xform._children)
|
||||
{
|
||||
if (xformQuery.TryGetComponent(child, out var childXform))
|
||||
if (_xformQuery.TryGetComponent(child, out var childXform))
|
||||
{
|
||||
bodyQuery.TryGetComponent(child, out var childBody);
|
||||
RecursiveMapUpdate(child, childXform, childBody, newMap, oldMap, bodyQuery, xformQuery, jointQuery);
|
||||
PhysicsQuery.TryGetComponent(child, out var childBody);
|
||||
RecursiveMapUpdate(child, childXform, childBody, newMap, oldMap, jointQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGridAdd(GridAddEvent ev)
|
||||
private void OnGridAdd(GridInitializeEvent ev)
|
||||
{
|
||||
var guid = ev.EntityUid;
|
||||
|
||||
|
||||
@@ -935,11 +935,13 @@ namespace Robust.UnitTesting
|
||||
// use server side uids on the client and vice versa. This can sometimes accidentally work if the
|
||||
// entities get created in the same order. For that reason we arbitrarily increment the queued Uid by
|
||||
// some arbitrary quantity.
|
||||
var e = (EntityManager) EntMan;
|
||||
|
||||
/* TODO: End my suffering and fix this because entmanager hasn't started up yet.
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
e.GenerateEntityUid();
|
||||
EntMan.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
}
|
||||
*/
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entManager = sim.Resolve<IEntityManager>();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
|
||||
var container = containerSys.MakeContainer<Container>(entity, "dummy");
|
||||
|
||||
@@ -75,8 +75,8 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entManager = sim.Resolve<IEntityManager>();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var owner = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var inserted = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var owner = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var inserted = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var transform = entManager.GetComponent<TransformComponent>(inserted);
|
||||
|
||||
var container = containerSys.MakeContainer<Container>(owner, "dummy");
|
||||
@@ -105,10 +105,10 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entManager = sim.Resolve<IEntityManager>();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var owner = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var inserted = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var owner = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var inserted = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var transform = entManager.GetComponent<TransformComponent>(inserted);
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
|
||||
var container = containerSys.MakeContainer<Container>(owner, "dummy");
|
||||
Assert.That(containerSys.Insert(inserted, container), Is.True);
|
||||
@@ -133,7 +133,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var coordinates = new EntityCoordinates(new EntityUid(1), new Vector2(0, 0));
|
||||
var coordinates = new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0));
|
||||
var entityOne = sim.SpawnEntity(null, coordinates);
|
||||
var entityTwo = sim.SpawnEntity(null, coordinates);
|
||||
var entityThree = sim.SpawnEntity(null, coordinates);
|
||||
@@ -166,7 +166,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(entity, "dummy");
|
||||
|
||||
Assert.That(containerSys.Insert(entity, container), Is.False);
|
||||
@@ -179,8 +179,8 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var mapEnt = new EntityUid(1);
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var mapEnt = EntityUid.FirstUid;
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(entity, "dummy");
|
||||
|
||||
Assert.That(containerSys.Insert(mapEnt, container), Is.False);
|
||||
@@ -194,7 +194,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var grid = sim.Resolve<IMapManager>().CreateGridEntity(new MapId(1)).Owner;
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(entity, "dummy");
|
||||
|
||||
Assert.That(containerSys.Insert(grid, container), Is.False);
|
||||
@@ -208,9 +208,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entManager = sim.Resolve<IEntityManager>();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var containerEntity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var containerEntity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(containerEntity, "dummy");
|
||||
var insertEntity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var insertEntity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
|
||||
var result = containerSys.Insert(insertEntity, container);
|
||||
|
||||
@@ -231,9 +231,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var containerEntity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var containerEntity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(containerEntity, "dummy");
|
||||
var insertEntity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var insertEntity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
|
||||
var result = containerSys.Remove(insertEntity, container);
|
||||
|
||||
@@ -246,11 +246,11 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
var containerSys = sim.Resolve<IEntitySystemManager>().GetEntitySystem<ContainerSystem>();
|
||||
|
||||
var entity1 = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity1 = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container1 = containerSys.MakeContainer<Container>(entity1, "dummy");
|
||||
var entity2 = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity2 = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container2 = containerSys.MakeContainer<Container>(entity2, "dummy");
|
||||
var transferEntity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var transferEntity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
containerSys.Insert(transferEntity, container1);
|
||||
|
||||
var result = containerSys.Insert(transferEntity, container2);
|
||||
@@ -267,9 +267,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entManager = sim.Resolve<IEntityManager>();
|
||||
var containerSys = entManager.System<ContainerSystem>();
|
||||
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var entity = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
var container = containerSys.MakeContainer<Container>(entity, "dummy");
|
||||
var childEnt = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), new Vector2(0, 0)));
|
||||
var childEnt = sim.SpawnEntity(null, new EntityCoordinates(EntityUid.FirstUid, new Vector2(0, 0)));
|
||||
|
||||
container.OccludesLight = true;
|
||||
container.ShowContents = true;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
private MapId MapB;
|
||||
private Entity<MapGridComponent> GridB;
|
||||
|
||||
private static readonly EntityCoordinates InitialPos = new(new EntityUid(1), new Vector2(0, 0));
|
||||
private static readonly EntityCoordinates InitialPos = new(EntityUid.FirstUid, new Vector2(0, 0));
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
[TestFixture, Parallelizable ,TestOf(typeof(EntityManager))]
|
||||
public sealed partial class EntityManager_Components_Tests
|
||||
{
|
||||
private static readonly EntityCoordinates DefaultCoords = new(new EntityUid(1), Vector2.Zero);
|
||||
private static readonly EntityCoordinates DefaultCoords = new(EntityUid.FirstUid, Vector2.Zero);
|
||||
|
||||
[Test]
|
||||
public void AddComponentTest()
|
||||
@@ -82,7 +82,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.HasComponent<DummyComponent>(entity);
|
||||
@@ -91,6 +91,22 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HasComponentNoGenericTest()
|
||||
{
|
||||
// Arrange
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.HasComponent(entity, typeof(DummyComponent));
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HasNetComponentTest()
|
||||
{
|
||||
@@ -102,7 +118,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.HasComponent(entity, netId.Value);
|
||||
@@ -122,7 +138,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.GetComponent(entity, netId.Value);
|
||||
@@ -138,7 +154,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.TryGetComponent<DummyComponent>(entity, out var comp);
|
||||
@@ -159,7 +175,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.TryGetComponent(entity, netId.Value, out var comp);
|
||||
@@ -176,7 +192,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
entMan.RemoveComponent<DummyComponent>(entity);
|
||||
@@ -214,7 +230,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
entMan.RemoveComponent(entity, netId.Value);
|
||||
@@ -231,7 +247,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.GetComponents<DummyComponent>(entity);
|
||||
@@ -249,7 +265,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var sim = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.EntityQuery<DummyComponent>(true);
|
||||
@@ -268,7 +284,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var fac = sim.Resolve<IComponentFactory>();
|
||||
var entity = entMan.SpawnEntity(null, DefaultCoords);
|
||||
var component = IoCManager.Resolve<IEntityManager>().AddComponent<DummyComponent>(entity);
|
||||
var component = entMan.AddComponent<DummyComponent>(entity);
|
||||
|
||||
// Act
|
||||
var result = entMan.GetComponents(entity);
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
void MoveEventHandler(ref MoveEvent ev)
|
||||
{
|
||||
calledCount++;
|
||||
Assert.That(ev.OldPosition, Is.EqualTo(new EntityCoordinates(new EntityUid(1), Vector2.Zero)));
|
||||
Assert.That(ev.NewPosition, Is.EqualTo(new EntityCoordinates(new EntityUid(1), Vector2.One)));
|
||||
Assert.That(ev.OldPosition, Is.EqualTo(new EntityCoordinates(EntityUid.FirstUid, Vector2.Zero)));
|
||||
Assert.That(ev.NewPosition, Is.EqualTo(new EntityCoordinates(EntityUid.FirstUid, Vector2.One)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ public sealed partial class ComponentStateTests : RobustIntegrationTest
|
||||
var clientEntA = client.EntMan.GetEntity(serverNetA);
|
||||
var clientEntB = client.EntMan.GetEntity(serverNetB);
|
||||
Assert.That(client.EntMan.EntityExists(clientEntB), Is.True);
|
||||
Assert.That(client.EntMan.EntityExists(client.EntMan.GetEntity(serverNetA)), Is.False);
|
||||
Assert.That(client.EntMan.EntityExists(clientEntA), Is.False);
|
||||
|
||||
Assert.That(client.EntMan.TryGetComponent(clientEntB, out UnknownEntityTestComponent? cmp));
|
||||
Assert.That(cmp?.Other, Is.EqualTo(clientEntA));
|
||||
|
||||
@@ -160,8 +160,8 @@ public sealed class GridSplit_Tests
|
||||
grid.SetTile(new Vector2i(2, 0), Tile.Empty);
|
||||
Assert.That(mapManager.GetAllGrids(mapId).Count(), Is.EqualTo(2));
|
||||
|
||||
var newGrid = mapManager.GetAllGrids(mapId).Last();
|
||||
var newGridXform = entManager.GetComponent<TransformComponent>(newGrid);
|
||||
var newGrid = mapManager.GetAllMapGrids(mapId).First(x => x != grid);
|
||||
var newGridXform = entManager.GetComponent<TransformComponent>(newGrid.Owner);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the map manager is restarted, Nullspace is recreated.
|
||||
/// When entities are flushed check nullsapce is also culled.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void Restart_NullspaceMap_IsEmptied()
|
||||
@@ -64,9 +64,8 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var oldEntity = entMan.CreateEntityUninitialized(null, MapCoordinates.Nullspace);
|
||||
entMan.InitializeComponents(oldEntity);
|
||||
entMan.Shutdown();
|
||||
entMan.FlushEntities();
|
||||
Assert.That(entMan.Deleted(oldEntity), Is.True);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user