mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix 3000 errors
This commit is contained in:
@@ -301,7 +301,7 @@ namespace {nameSpace}
|
||||
foreach (var candidateClass in receiver.CandidateClasses)
|
||||
{
|
||||
var model = compilation.GetSemanticModel(candidateClass.SyntaxTree);
|
||||
var typeSymbol = (INamedTypeSymbol) model.GetDeclaredSymbol(candidateClass);
|
||||
var typeSymbol = model.GetDeclaredSymbol(candidateClass);
|
||||
var relevantAttribute = typeSymbol.GetAttributes().FirstOrDefault(attr =>
|
||||
attr.AttributeClass != null &&
|
||||
attr.AttributeClass.Equals(attributeSymbol, SymbolEqualityComparer.Default));
|
||||
|
||||
@@ -21,13 +21,12 @@ namespace Robust.Client.Console.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
var entityUid = EntityUid.Parse(args[0]);
|
||||
var entity = EntityUid.Parse(args[0]);
|
||||
var componentName = args[1];
|
||||
|
||||
var compFactory = IoCManager.Resolve<IComponentFactory>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
var entity = entityManager.GetEntity(entityUid);
|
||||
var component = (Component) compFactory.GetComponent(componentName);
|
||||
|
||||
component.Owner = entity;
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Robust.Client.Console.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
||||
if (player?.ControlledEntity == null)
|
||||
if (player?.ControlledEntity == default)
|
||||
{
|
||||
shell.WriteLine("You don't have an attached entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(player.ControlledEntity.Value).Coordinates);
|
||||
entityManager.SpawnEntity(args[0], entityManager.GetComponent<TransformComponent>(player.ControlledEntity).Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Debugging;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -23,10 +22,8 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
@@ -43,7 +40,7 @@ namespace Robust.Client.Console.Commands
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
foreach (var e in entityManager.GetEntities().OrderBy(e => (EntityUid) e))
|
||||
foreach (var e in entityManager.GetEntities().OrderBy(e => e))
|
||||
{
|
||||
shell.WriteLine($"entity {e}, {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e).EntityPrototype?.ID}, {IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(e).Coordinates}.");
|
||||
}
|
||||
@@ -240,15 +237,15 @@ namespace Robust.Client.Console.Commands
|
||||
|
||||
var uid = EntityUid.Parse(args[0]);
|
||||
var entmgr = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entmgr.TryGetEntity(uid, out var entity))
|
||||
if (!entmgr.EntityExists(uid))
|
||||
{
|
||||
shell.WriteError("That entity does not exist. Sorry lad.");
|
||||
return;
|
||||
}
|
||||
var meta = entmgr.GetComponent<MetaDataComponent>(entity.Value);
|
||||
shell.WriteLine($"{entity}: {meta.EntityPrototype?.ID}/{meta.EntityName}");
|
||||
shell.WriteLine($"init/del/lmt: {(!entmgr.EntityExists(entity.Value) ? EntityLifeStage.Deleted : meta.EntityLifeStage) >= EntityLifeStage.Initialized}/{(!entmgr.EntityExists(entity.Value) ? EntityLifeStage.Deleted : meta.EntityLifeStage) >= EntityLifeStage.Deleted}/{meta.EntityLastModifiedTick}");
|
||||
foreach (var component in entmgr.GetComponents(entity.Value))
|
||||
var meta = entmgr.GetComponent<MetaDataComponent>(uid);
|
||||
shell.WriteLine($"{uid}: {meta.EntityPrototype?.ID}/{meta.EntityName}");
|
||||
shell.WriteLine($"init/del/lmt: {(!entmgr.EntityExists(uid) ? EntityLifeStage.Deleted : meta.EntityLifeStage) >= EntityLifeStage.Initialized}/{(!entmgr.EntityExists(uid) ? EntityLifeStage.Deleted : meta.EntityLifeStage) >= EntityLifeStage.Deleted}/{meta.EntityLastModifiedTick}");
|
||||
foreach (var component in entmgr.GetComponents(uid))
|
||||
{
|
||||
shell.WriteLine(component.ToString() ?? "");
|
||||
if (component is IComponentDebug debug)
|
||||
|
||||
@@ -79,13 +79,13 @@ namespace Robust.Client.Debugging
|
||||
|
||||
foreach (var ent in grid.GetAnchoredEntities(spot))
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(ent, out var entity))
|
||||
if (!EntityManager.EntityExists(ent))
|
||||
{
|
||||
text.AppendLine($"uid: {ent}, invalid");
|
||||
}
|
||||
else
|
||||
{
|
||||
text.AppendLine($"uid: {ent}, {EntityManager.GetComponent<MetaDataComponent>(entity.Value).EntityName}");
|
||||
text.AppendLine($"uid: {ent}, {EntityManager.GetComponent<MetaDataComponent>(ent).EntityName}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Robust.Client.GameObjects
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
EntityUid IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid? uid)
|
||||
EntityUid IClientEntityManagerInternal.CreateEntity(string? prototypeName, EntityUid uid)
|
||||
{
|
||||
return base.CreateEntity(prototypeName, uid);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -13,14 +12,11 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
|
||||
@@ -34,6 +30,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
[Dependency] private readonly IResourceCache resourceCache = default!;
|
||||
[Dependency] private readonly IPrototypeManager prototypes = default!;
|
||||
[Dependency] private readonly IEntityManager entities = default!;
|
||||
|
||||
[DataField("visible")]
|
||||
private bool _visible = true;
|
||||
@@ -47,7 +44,7 @@ namespace Robust.Client.GameObjects
|
||||
if (_visible == value) return;
|
||||
_visible = value;
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
entities.EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +300,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
if (_containerOccluded == value) return;
|
||||
_containerOccluded = value;
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
entities.EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1506,7 +1503,7 @@ namespace Robust.Client.GameObjects
|
||||
// Look this was an easy way to get bounds checks for layer updates.
|
||||
// If you really want it optimal you'll need to comb through all 2k lines of spritecomponent.
|
||||
EntityUid tempQualifier = Owner;
|
||||
if ((tempQualifier != null ? IoCManager.Resolve<IEntityManager>() : null)?.EventBus != null)
|
||||
if ((tempQualifier != default ? entities : null)?.EventBus != null)
|
||||
UpdateBounds();
|
||||
|
||||
if (_inertUpdateQueued)
|
||||
@@ -1516,7 +1513,7 @@ namespace Robust.Client.GameObjects
|
||||
// Yes that null check is valid because of that stupid fucking dummy IEntity.
|
||||
// Who thought that was a good idea.
|
||||
EntityUid tempQualifier1 = Owner;
|
||||
(tempQualifier1 != null ? IoCManager.Resolve<IEntityManager>() : null)?.EventBus?.RaiseEvent(EventSource.Local, new SpriteUpdateInertEvent {Sprite = this});
|
||||
(tempQualifier1 != default ? entities : null)?.EventBus?.RaiseEvent(EventSource.Local, new SpriteUpdateInertEvent {Sprite = this});
|
||||
}
|
||||
|
||||
internal void DoUpdateIsInert()
|
||||
@@ -1603,7 +1600,7 @@ namespace Robust.Client.GameObjects
|
||||
builder.AppendFormat(
|
||||
"vis/depth/scl/rot/ofs/col/norot/override/dir: {0}/{1}/{2}/{3}/{4}/{5}/{6}/{8}/{7}\n",
|
||||
Visible, DrawDepth, Scale, Rotation, Offset,
|
||||
Color, NoRotation, GetDir(RSI.State.DirectionType.Dir8, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).WorldRotation),
|
||||
Color, NoRotation, GetDir(RSI.State.DirectionType.Dir8, entities.GetComponent<TransformComponent>(Owner).WorldRotation),
|
||||
DirectionOverride
|
||||
);
|
||||
|
||||
@@ -1657,7 +1654,7 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
internal void UpdateBounds()
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
entities.EventBus.RaiseLocalEvent(((IComponent) this).Owner, new SpriteUpdateEvent());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Robust.Client.GameObjects
|
||||
/// </summary>
|
||||
public void Play(EntityUid uid, Animation animation, string key)
|
||||
{
|
||||
var component = EntityManager.EnsureComponent<AnimationPlayerComponent>(EntityManager.GetEntity(uid));
|
||||
var component = EntityManager.EnsureComponent<AnimationPlayerComponent>(uid);
|
||||
Play(component, animation, key);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Audio;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -123,15 +122,15 @@ namespace Robust.Client.GameObjects
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (stream.TrackingEntity != null)
|
||||
else if (stream.TrackingEntity != default)
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(stream.TrackingEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(stream.TrackingEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if ((!EntityManager.EntityExists(stream.TrackingEntity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(stream.TrackingEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
{
|
||||
StreamDone(stream);
|
||||
continue;
|
||||
}
|
||||
|
||||
mapPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(stream.TrackingEntity).MapPosition;
|
||||
mapPos = EntityManager.GetComponent<TransformComponent>(stream.TrackingEntity).MapPosition;
|
||||
}
|
||||
|
||||
// TODO Remove when coordinates can't be NaN
|
||||
@@ -211,7 +210,7 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
if (stream.TrackingEntity != null)
|
||||
if (stream.TrackingEntity != default)
|
||||
{
|
||||
stream.Source.SetVelocity(stream.TrackingEntity.GlobalLinearVelocity());
|
||||
}
|
||||
@@ -304,7 +303,7 @@ namespace Robust.Client.GameObjects
|
||||
AudioParams? audioParams = null)
|
||||
{
|
||||
var source = _clyde.CreateAudioSource(stream);
|
||||
if (!source.SetPosition(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition))
|
||||
if (!source.SetPosition(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition))
|
||||
{
|
||||
return Play(stream, fallbackCoordinates, fallbackCoordinates, audioParams);
|
||||
}
|
||||
@@ -452,7 +451,7 @@ namespace Robust.Client.GameObjects
|
||||
/// <inheritdoc />
|
||||
public IPlayingAudioStream? Play(Filter playerFilter, string filename, EntityUid entity, AudioParams? audioParams = null)
|
||||
{
|
||||
return Play(filename, entity, GetFallbackCoordinates(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapPosition), audioParams);
|
||||
return Play(filename, entity, GetFallbackCoordinates(EntityManager.GetComponent<TransformComponent>(entity).MapPosition), audioParams);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -123,16 +123,16 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
|
||||
// Add new entities.
|
||||
foreach (var entityUid in entityUids)
|
||||
foreach (var entity in entityUids)
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(entityUid, out var entity))
|
||||
if (!EntityManager.EntityExists(entity))
|
||||
{
|
||||
AddExpectedEntity(entityUid, container);
|
||||
AddExpectedEntity(entity, container);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!container.ContainedEntities.Contains(entity.Value))
|
||||
container.Insert(entity.Value);
|
||||
if (!container.ContainedEntities.Contains(entity))
|
||||
container.Insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
for (var i = 0; i < message.Entities.Count; i++)
|
||||
{
|
||||
var uid = message.Entities[i];
|
||||
var entity = message.Entities[i];
|
||||
|
||||
if (!EntityManager.TryGetEntity(uid, out var entity)) continue;
|
||||
if (!EntityManager.EntityExists(entity)) continue;
|
||||
|
||||
text.AppendLine((string) EntityManager.ToPrettyString(entity.Value));
|
||||
text.AppendLine((string) EntityManager.ToPrettyString(entity));
|
||||
}
|
||||
|
||||
_label.Text = text.ToString();
|
||||
|
||||
@@ -9,7 +9,6 @@ using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
#nullable enable
|
||||
|
||||
@@ -77,9 +76,16 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
var gridId = playerTransform.GridID;
|
||||
|
||||
var parent = gridId != GridId.Invalid && EntityManager.TryGetEntity(_mapManager.GetGrid(gridId).GridEntityId, out var gridEnt) ?
|
||||
EntityManager.GetComponent<TransformComponent>(gridEnt!.Value)
|
||||
: EntityManager.GetComponent<TransformComponent>(_mapManager.GetMapEntityId(playerTransform.MapID));
|
||||
TransformComponent parent;
|
||||
if (gridId != GridId.Invalid &&
|
||||
_mapManager.GetGrid(gridId).GridEntityId is var gridEnt &&
|
||||
EntityManager.EntityExists(gridEnt))
|
||||
parent = EntityManager.GetComponent<TransformComponent>(gridEnt);
|
||||
else
|
||||
{
|
||||
parent = EntityManager.GetComponent<TransformComponent>(
|
||||
_mapManager.GetMapEntityId(playerTransform.MapID));
|
||||
}
|
||||
|
||||
// Make sure that we don't fire the vomit carousel when we spawn in
|
||||
if (_lastParent is null)
|
||||
|
||||
@@ -64,9 +64,7 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(currentMap, viewport))
|
||||
{
|
||||
var gridEnt = _entityManager.GetEntity(grid.GridEntityId);
|
||||
|
||||
if (!_entityManager.TryGetComponent<PhysicsComponent>(gridEnt, out var body)) continue;
|
||||
if (!_entityManager.TryGetComponent<PhysicsComponent>(grid.GridEntityId, out var body)) continue;
|
||||
|
||||
var transform = body.GetTransform();
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using Robust.Shared.Input;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
@@ -118,14 +117,14 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetEntityContextActive(IInputManager inputMan, EntityUid entity)
|
||||
private void SetEntityContextActive(IInputManager inputMan, EntityUid entity)
|
||||
{
|
||||
if(entity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(entity))
|
||||
if(entity == default || !EntityManager.EntityExists(entity))
|
||||
throw new ArgumentNullException(nameof(entity));
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out InputComponent? inputComp))
|
||||
if (!EntityManager.TryGetComponent(entity, out InputComponent? inputComp))
|
||||
{
|
||||
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity}, entProto={IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityPrototype}. Setting default \"{InputContextContainer.DefaultContextName}\" context...");
|
||||
Logger.DebugS("input.context", $"AttachedEnt has no InputComponent: entId={entity}, entProto={EntityManager.GetComponent<MetaDataComponent>(entity).EntityPrototype}. Setting default \"{InputContextContainer.DefaultContextName}\" context...");
|
||||
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
|
||||
return;
|
||||
}
|
||||
@@ -136,7 +135,7 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorS("input.context", $"Unknown context: entId={entity}, entProto={IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityPrototype}, context={inputComp.ContextName}. . Setting default \"{InputContextContainer.DefaultContextName}\" context...");
|
||||
Logger.ErrorS("input.context", $"Unknown context: entId={entity}, entProto={EntityManager.GetComponent<MetaDataComponent>(entity).EntityPrototype}, context={inputComp.ContextName}. . Setting default \"{InputContextContainer.DefaultContextName}\" context...");
|
||||
inputMan.Contexts.SetActiveContext(InputContextContainer.DefaultContextName);
|
||||
}
|
||||
}
|
||||
@@ -146,12 +145,12 @@ namespace Robust.Client.GameObjects
|
||||
/// </summary>
|
||||
public void SetEntityContextActive()
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == null)
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == default)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetEntityContextActive(_inputManager, _playerManager.LocalPlayer.ControlledEntity.Value);
|
||||
SetEntityContextActive(_inputManager, _playerManager.LocalPlayer.ControlledEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,13 +162,13 @@ namespace Robust.Client.GameObjects
|
||||
/// <summary>
|
||||
/// New entity the player is attached to.
|
||||
/// </summary>
|
||||
public EntityUid? AttachedEntity { get; }
|
||||
public EntityUid AttachedEntity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="PlayerAttachSysMessage"/>.
|
||||
/// </summary>
|
||||
/// <param name="attachedEntity">New entity the player is attached to.</param>
|
||||
public PlayerAttachSysMessage(EntityUid? attachedEntity)
|
||||
public PlayerAttachSysMessage(EntityUid attachedEntity)
|
||||
{
|
||||
AttachedEntity = attachedEntity;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
private void HandleRemove(EntityUid uid, PointLightComponent component, ComponentRemove args)
|
||||
{
|
||||
var ent = EntityManager.GetEntity(uid);
|
||||
var map = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent).MapID;
|
||||
var map = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(uid).MapID;
|
||||
// TODO: Just make this update the tree directly and not allocate
|
||||
if (map != MapId.Nullspace)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Physics;
|
||||
using Robust.Shared;
|
||||
@@ -11,7 +9,6 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
{
|
||||
@@ -30,7 +27,7 @@ namespace Robust.Client.GameObjects
|
||||
private readonly List<SpriteComponent> _spriteQueue = new();
|
||||
private readonly List<PointLightComponent> _lightQueue = new();
|
||||
|
||||
private HashSet<EntityUid> _checkedChildren = new();
|
||||
private readonly HashSet<EntityUid> _checkedChildren = new();
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CVars.MaxLightRadius"/>
|
||||
@@ -246,7 +243,7 @@ namespace Robust.Client.GameObjects
|
||||
|
||||
private void MapManagerOnGridCreated(MapId mapId, GridId gridId)
|
||||
{
|
||||
EntityManager.GetEntity(_mapManager.GetGrid(gridId).GridEntityId).EnsureComponent<RenderingTreeComponent>();
|
||||
_mapManager.GetGrid(gridId).GridEntityId.EnsureComponent<RenderingTreeComponent>();
|
||||
}
|
||||
|
||||
internal static RenderingTreeComponent? GetRenderTree(EntityUid entity)
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
// These methods are used by the Game State Manager.
|
||||
|
||||
EntityUid CreateEntity(string? prototypeName, EntityUid? uid = null);
|
||||
EntityUid CreateEntity(string? prototypeName, EntityUid uid = default);
|
||||
|
||||
void InitializeEntity(EntityUid entity);
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ namespace Robust.Client.GameStates
|
||||
EntityState? nextState)
|
||||
{
|
||||
var compStateWork = new Dictionary<ushort, (ComponentState? curState, ComponentState? nextState)>();
|
||||
var entityUid = (EntityUid) entity;
|
||||
var entityUid = entity;
|
||||
|
||||
if (curState != null)
|
||||
{
|
||||
@@ -616,7 +616,7 @@ namespace Robust.Client.GameStates
|
||||
|
||||
foreach (var (netId, (cur, next)) in compStateWork)
|
||||
{
|
||||
if (_entityManager.TryGetComponent(entityUid, (ushort) netId, out var component))
|
||||
if (_entityManager.TryGetComponent(entityUid, netId, out var component))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using OpenToolkit.Audio.OpenAL;
|
||||
using OpenToolkit.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using OpenToolkit.Mathematics;
|
||||
using Robust.Client.Audio;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Log;
|
||||
using Vector2 = Robust.Shared.Maths.Vector2;
|
||||
|
||||
namespace Robust.Client.Graphics.Audio
|
||||
{
|
||||
@@ -51,7 +36,7 @@ namespace Robust.Client.Graphics.Audio
|
||||
// Clear out finalized audio buffers.
|
||||
while (_bufferDisposeQueue.TryDequeue(out var handle))
|
||||
{
|
||||
AL.DeleteBuffer((int) handle);
|
||||
AL.DeleteBuffer(handle);
|
||||
_checkAlError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@ using System.Runtime.InteropServices;
|
||||
using OpenToolkit.Graphics.OpenGL4;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using Color = Robust.Shared.Maths.Color;
|
||||
using TKStencilOp = OpenToolkit.Graphics.OpenGL4.StencilOp;
|
||||
|
||||
namespace Robust.Client.Graphics.Clyde
|
||||
@@ -449,7 +447,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
//function! If passing in textures as uniforms ever stops working it might be since someone made it use all the way up to Texture6 too.
|
||||
//Might change this in the future?
|
||||
TextureUnit cTarget = TextureUnit.Texture6 + textureUnitVal;
|
||||
SetTexture(cTarget, ((ClydeTexture) clydeTexture).TextureId);
|
||||
SetTexture(cTarget, clydeTexture.TextureId);
|
||||
program.SetUniformTexture(name, cTarget);
|
||||
textureUnitVal++;
|
||||
break;
|
||||
|
||||
@@ -8,7 +8,6 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Input;
|
||||
@@ -78,7 +77,7 @@ namespace Robust.Client.Input
|
||||
|
||||
public IEnumerable<BoundKeyFunction> DownKeyFunctions => _bindings
|
||||
.Where(x => x.State == BoundKeyState.Down)
|
||||
.Select(x => (BoundKeyFunction)x.Function)
|
||||
.Select(x => x.Function)
|
||||
.ToList();
|
||||
|
||||
public virtual string GetKeyName(Key key)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -34,8 +33,8 @@ namespace Robust.Client.Placement.Modes
|
||||
GridDistancing = SnapSize;
|
||||
|
||||
var mouselocal = new Vector2( //Round local coordinates onto the snap grid
|
||||
(float) MathF.Round(MouseCoords.X / SnapSize, MidpointRounding.AwayFromZero) * SnapSize,
|
||||
(float) MathF.Round(MouseCoords.Y / SnapSize, MidpointRounding.AwayFromZero) * SnapSize);
|
||||
MathF.Round(MouseCoords.X / SnapSize, MidpointRounding.AwayFromZero) * SnapSize,
|
||||
MathF.Round(MouseCoords.Y / SnapSize, MidpointRounding.AwayFromZero) * SnapSize);
|
||||
|
||||
//Convert back to original world and screen coordinates after applying offset
|
||||
MouseCoords =
|
||||
|
||||
@@ -15,7 +15,6 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Network.Messages;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -242,7 +241,7 @@ namespace Robust.Client.Placement
|
||||
return false;
|
||||
}
|
||||
|
||||
HandleDeletion(EntityManager.GetEntity(uid));
|
||||
HandleDeletion(uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -494,9 +493,9 @@ namespace Robust.Client.Placement
|
||||
// Try to get current map.
|
||||
var map = MapId.Nullspace;
|
||||
var ent = PlayerManager.LocalPlayer!.ControlledEntity;
|
||||
if (ent != null)
|
||||
if (ent != default)
|
||||
{
|
||||
map = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent.Value).MapID;
|
||||
map = EntityManager.GetComponent<TransformComponent>(ent).MapID;
|
||||
}
|
||||
|
||||
if (map == MapId.Nullspace || CurrentPermission == null || CurrentMode == null)
|
||||
@@ -512,14 +511,14 @@ namespace Robust.Client.Placement
|
||||
private bool CurrentEraserMouseCoordinates(out EntityCoordinates coordinates)
|
||||
{
|
||||
var ent = PlayerManager.LocalPlayer?.ControlledEntity;
|
||||
if (ent == null)
|
||||
if (ent == default)
|
||||
{
|
||||
coordinates = new EntityCoordinates();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var map = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent.Value).MapID;
|
||||
var map = EntityManager.GetComponent<TransformComponent>(ent.Value).MapID;
|
||||
if (map == MapId.Nullspace || !Eraser)
|
||||
{
|
||||
coordinates = new EntityCoordinates();
|
||||
@@ -638,7 +637,7 @@ namespace Robust.Client.Placement
|
||||
|| PlayerManager.LocalPlayer?.ControlledEntity == null)
|
||||
return;
|
||||
|
||||
var worldPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(PlayerManager.LocalPlayer.ControlledEntity.Value).WorldPosition;
|
||||
var worldPos = EntityManager.GetComponent<TransformComponent>(PlayerManager.LocalPlayer.ControlledEntity).WorldPosition;
|
||||
|
||||
handle.DrawCircle(worldPos, CurrentPermission.Range, new Color(1, 1, 1, 0.25f));
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Client.Placement
|
||||
@@ -88,9 +84,9 @@ namespace Robust.Client.Placement
|
||||
public virtual void Render(DrawingHandleWorld handle)
|
||||
{
|
||||
var sce = pManager.CurrentPlacementOverlayEntity;
|
||||
if (sce == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(sce.Value) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(sce.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if (sce == null || (!pManager.EntityManager.EntityExists(sce.Value) ? EntityLifeStage.Deleted : pManager.EntityManager.GetComponent<MetaDataComponent>(sce.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
return;
|
||||
var sc = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(sce!.Value);
|
||||
var sc = pManager.EntityManager.GetComponent<SpriteComponent>(sce!.Value);
|
||||
|
||||
IEnumerable<EntityCoordinates> locationcollection;
|
||||
switch (pManager.PlacementType)
|
||||
@@ -115,7 +111,7 @@ namespace Robust.Client.Placement
|
||||
if (!coordinate.IsValid(pManager.EntityManager))
|
||||
return; // Just some paranoia just in case
|
||||
var worldPos = coordinate.ToMapPos(pManager.EntityManager);
|
||||
var worldRot = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(coordinate.EntityId).WorldRotation + dirAng;
|
||||
var worldRot = pManager.EntityManager.GetComponent<TransformComponent>(coordinate.EntityId).WorldRotation + dirAng;
|
||||
|
||||
sc.Color = IsValidPosition(coordinate) ? ValidPlaceColor : InvalidPlaceColor;
|
||||
sc.Render(handle, pManager.eyeManager.CurrentEye.Rotation, worldRot, worldPos);
|
||||
@@ -199,13 +195,13 @@ namespace Robust.Client.Placement
|
||||
if (!RangeRequired)
|
||||
return true;
|
||||
|
||||
if (pManager.PlayerManager.LocalPlayer?.ControlledEntity == null)
|
||||
if (pManager.PlayerManager.LocalPlayer?.ControlledEntity == default)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var range = pManager.CurrentPermission!.Range;
|
||||
if (range > 0 && !IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pManager.PlayerManager.LocalPlayer.ControlledEntity.Value).Coordinates.InRange(pManager.EntityManager, coordinates, range))
|
||||
if (range > 0 && !pManager.EntityManager.GetComponent<TransformComponent>(pManager.PlayerManager.LocalPlayer.ControlledEntity).Coordinates.InRange(pManager.EntityManager, coordinates, range))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Robust.Client.Player
|
||||
public override Filter FromEntities(Filter filter, params EntityUid[] entities)
|
||||
{
|
||||
if (_playerManager.LocalPlayer is not { } localPlayer
|
||||
|| localPlayer.Session.AttachedEntityUid is not {} attachedUid)
|
||||
|| localPlayer.Session.AttachedEntity is not {Valid: true} attachedUid)
|
||||
return filter;
|
||||
|
||||
foreach (var uid in entities)
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Robust.Client.Player
|
||||
public event Action<EntityDetachedEventArgs>? EntityDetached;
|
||||
|
||||
/// <summary>
|
||||
/// Game entity that the local player is controlling. If this is null, the player is not attached to any
|
||||
/// Game entity that the local player is controlling. If this is default, the player is not attached to any
|
||||
/// entity at all.
|
||||
/// </summary>
|
||||
[ViewVariables] public EntityUid? ControlledEntity { get; private set; }
|
||||
[ViewVariables] public EntityUid ControlledEntity { get; private set; }
|
||||
|
||||
[ViewVariables] public NetUserId UserId { get; set; }
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Robust.Client.Player
|
||||
DetachEntity();
|
||||
|
||||
ControlledEntity = entity;
|
||||
InternalSession.AttachedEntityUid = entity;
|
||||
InternalSession.AttachedEntity = entity;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
@@ -86,20 +86,20 @@ namespace Robust.Client.Player
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var previous = ControlledEntity;
|
||||
if (previous != null && entMan.EntityExists(previous.Value))
|
||||
if (previous != default && entMan.EntityExists(previous))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<EyeComponent>(previous.Value).Current = false;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<EyeComponent>(previous).Current = false;
|
||||
|
||||
// notify ECS Systems
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseEvent(EventSource.Local, new PlayerAttachSysMessage(null));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(previous.Value, new PlayerDetachedEvent(previous.Value));
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(previous, new PlayerDetachedEvent(previous));
|
||||
}
|
||||
|
||||
ControlledEntity = null;
|
||||
ControlledEntity = default;
|
||||
|
||||
if (previous != null)
|
||||
if (previous != default)
|
||||
{
|
||||
EntityDetached?.Invoke(new EntityDetachedEventArgs(previous.Value));
|
||||
EntityDetached?.Invoke(new EntityDetachedEventArgs(previous));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace Robust.Client.Player
|
||||
{
|
||||
[Dependency] private readonly IClientNetManager _network = default!;
|
||||
[Dependency] private readonly IBaseClient _client = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Active sessions of connected clients to the server.
|
||||
@@ -151,7 +150,7 @@ namespace Robust.Client.Player
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPlayer.AttachEntity(_entityManager.GetEntity(entity.Value));
|
||||
LocalPlayer.AttachEntity(entity.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Robust.Client.Player
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EntityUid? AttachedEntityUid { get; set; }
|
||||
public EntityUid AttachedEntity { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public NetUserId UserId { get; }
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Robust.Client.Serialization
|
||||
throw new InvalidMappingException(
|
||||
$"Invalid type {typeValueDataNode.Value} specified for AppearanceVisualizer!");
|
||||
|
||||
var newNode = (MappingDataNode)node.Copy();
|
||||
var newNode = node.Copy();
|
||||
newNode.Remove("type");
|
||||
return serializationManager.Read(type, newNode, context, skipHook);
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace Robust.Client.UserInterface
|
||||
internal AttachedProperty(string name, Type owningType, T defaultValue,
|
||||
Func<T, bool>? validate = null, AttachedPropertyChangedCallback<T>? changed = null)
|
||||
: base(name, owningType, typeof(T), defaultValue,
|
||||
validate != null ? o => validate!((T) o!) : (Func<object?, bool>?) null,
|
||||
validate != null ? o => validate!((T) o!) : null,
|
||||
changed != null
|
||||
? (AttachedPropertyChangedCallback?) ((o, ev) => changed!(o, new AttachedPropertyChangedEventArgs<T>((T) ev.NewValue!, (T) ev.OldValue!)))
|
||||
? (o, ev) => changed!(o, new AttachedPropertyChangedEventArgs<T>((T) ev.NewValue!, (T) ev.OldValue!))
|
||||
: null)
|
||||
{
|
||||
Validate = validate;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Text;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Client.UserInterface.CustomControls
|
||||
@@ -90,17 +90,17 @@ Mouse Pos:
|
||||
tile, controlHovered);
|
||||
|
||||
stringBuilder.AppendLine("\nAttached Entity:");
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == null)
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == default)
|
||||
{
|
||||
stringBuilder.AppendLine("No attached entity.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var entityTransform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_playerManager.LocalPlayer.ControlledEntity.Value);
|
||||
var entityTransform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_playerManager.LocalPlayer.ControlledEntity);
|
||||
var playerWorldOffset = entityTransform.MapPosition;
|
||||
var playerScreen = _eyeManager.WorldToScreen(playerWorldOffset.Position);
|
||||
|
||||
var playerCoordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_playerManager.LocalPlayer.ControlledEntity.Value).Coordinates;
|
||||
var playerCoordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_playerManager.LocalPlayer.ControlledEntity).Coordinates;
|
||||
|
||||
stringBuilder.AppendFormat(@" Screen: {0}
|
||||
{1}
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
((IEnumerator) _enumerator).Reset();
|
||||
_enumerator.Reset();
|
||||
}
|
||||
|
||||
public Control Current => _enumerator.Current;
|
||||
|
||||
@@ -468,8 +468,7 @@ namespace Robust.Client.ViewVariables.Instances
|
||||
|
||||
var uid = (EntityUid) _membersBlob.MemberGroups.SelectMany(p => p.Item2).Single(p => p.Name == "Uid").Value;
|
||||
|
||||
var entity = _entityManager.GetEntity(uid);
|
||||
Initialize(window, entity);
|
||||
Initialize(window, uid);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
|
||||
@@ -83,14 +83,14 @@ namespace Robust.Client.ViewVariables
|
||||
}
|
||||
|
||||
// Entity.
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!EntityUid.TryParse(args[0], out var entity))
|
||||
{
|
||||
shell.WriteLine("Invalid specifier format.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entityManager.TryGetEntity(uid, out var entity))
|
||||
if (!entityManager.EntityExists(entity))
|
||||
{
|
||||
shell.WriteLine("That entity does not exist.");
|
||||
return;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Robust.Server.Bql
|
||||
var selectors = parsed.Value.Item1.ToArray();
|
||||
if (selectors.Length == 0)
|
||||
{
|
||||
return (entityManager.GetEntityUids(), parsed.Value.Item2);
|
||||
return (entityManager.GetEntities(), parsed.Value.Item2);
|
||||
}
|
||||
|
||||
var entities = _queriesByToken[selectors[0].Token]
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace Robust.Server.Bql
|
||||
.SelectMany(e =>
|
||||
entityLookup.GetEntitiesInRange(entityManager.GetComponent<TransformComponent>(e).Coordinates,
|
||||
radius))
|
||||
.Select(x => (EntityUid) x) // Sloth's fault.
|
||||
.Select(x => x) // Sloth's fault.
|
||||
.Distinct();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Robust.Server.Bql
|
||||
{
|
||||
@@ -55,7 +54,7 @@ namespace Robust.Server.Bql
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<EntityUid> DoInitialSelection(IReadOnlyList<object> arguments, bool isInverted, IEntityManager entityManager)
|
||||
{
|
||||
return DoSelection(entityManager.GetEntityUids(), arguments, isInverted, entityManager);
|
||||
return DoSelection(entityManager.GetEntities(), arguments, isInverted, entityManager);
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
|
||||
@@ -22,12 +22,11 @@ namespace Robust.Server.Bql
|
||||
}
|
||||
|
||||
var queryManager = IoCManager.Resolve<IBqlQueryManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var (entities, rest) = queryManager.SimpleParseAndExecute(argStr[6..]);
|
||||
|
||||
foreach (var ent in entities.ToList())
|
||||
{
|
||||
var cmds = SubstituteEntityDetails(shell, entityManager.GetEntity(ent), rest).Split(";");
|
||||
var cmds = SubstituteEntityDetails(shell, ent, rest).Split(";");
|
||||
foreach (var cmd in cmds)
|
||||
{
|
||||
shell.ExecuteCommand(cmd);
|
||||
|
||||
@@ -21,19 +21,19 @@ namespace Robust.Server.Console.Commands
|
||||
|
||||
var ent = IoCManager.Resolve<IServerEntityManager>();
|
||||
|
||||
if (!EntityUid.TryParse(args[0], out var uid))
|
||||
if (!EntityUid.TryParse(args[0], out var entity))
|
||||
{
|
||||
shell.WriteLine("Invalid entity UID.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ent.TryGetEntity(uid, out var entity))
|
||||
if (!ent.EntityExists(entity))
|
||||
{
|
||||
shell.WriteLine("That entity does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entity);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Robust.Server.Console.Commands
|
||||
shell.WriteError("Incorrect number of arguments. " + Help);
|
||||
}
|
||||
|
||||
var pAE = player == null ? EntityUid.Invalid : player.AttachedEntityUidOrInvalid;
|
||||
var pAE = player?.AttachedEntity ?? EntityUid.Invalid;
|
||||
|
||||
if (args.Length == 1 && player != null && pAE != EntityUid.Invalid)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Robust.Server.Console.Commands
|
||||
}
|
||||
else if (args.Length == 2)
|
||||
{
|
||||
var uid = ent.GetEntity(EntityUid.Parse(args[1]));
|
||||
var uid = EntityUid.Parse(args[1]);
|
||||
ent.SpawnEntity(args[0], ent.GetComponent<TransformComponent>(uid).Coordinates);
|
||||
}
|
||||
else if (player != null && pAE != EntityUid.Invalid)
|
||||
|
||||
@@ -114,18 +114,16 @@ namespace Robust.Server.GameObjects
|
||||
/// This returns true if the player wasn't attached to any entity.</returns>
|
||||
public bool Detach(IPlayerSession player)
|
||||
{
|
||||
var uid = player.AttachedEntityUid;
|
||||
return uid == null || Detach(uid.Value);
|
||||
var uid = player.AttachedEntity;
|
||||
return uid == default || Detach(uid);
|
||||
}
|
||||
|
||||
private void OnActorShutdown(EntityUid uid, ActorComponent component, ComponentShutdown args)
|
||||
private void OnActorShutdown(EntityUid entity, ActorComponent component, ComponentShutdown args)
|
||||
{
|
||||
component.PlayerSession.SetAttachedEntity(null);
|
||||
|
||||
var entity = EntityManager.GetEntity(uid);
|
||||
|
||||
// The player is fully detached now that the component has shut down.
|
||||
RaiseLocalEvent(uid, new PlayerDetachedEvent(entity, component.PlayerSession));
|
||||
RaiseLocalEvent(entity, new PlayerDetachedEvent(entity, component.PlayerSession));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Robust.Server.GameObjects
|
||||
{
|
||||
@@ -244,7 +243,7 @@ namespace Robust.Server.GameObjects
|
||||
#if DEBUG
|
||||
private void HandleRequest(RequestGridTileLookupMessage message, EntitySessionEventArgs args)
|
||||
{
|
||||
var entities = GetEntitiesIntersecting(message.GridId, message.Indices).Select(e => (EntityUid) e).ToList();
|
||||
var entities = GetEntitiesIntersecting(message.GridId, message.Indices).Select(e => e).ToList();
|
||||
RaiseNetworkEvent(new SendGridTileLookupMessage(message.GridId, message.Indices, entities), args.SenderSession.ConnectedClient);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Robust.Server.GameObjects
|
||||
// These methods are used by the map loader to do multi-stage entity construction during map load.
|
||||
// I would recommend you refer to the MapLoader for usage.
|
||||
|
||||
EntityUid AllocEntity(string? prototypeName, EntityUid? uid = null);
|
||||
EntityUid AllocEntity(string? prototypeName, EntityUid uid = default);
|
||||
|
||||
void FinishEntityLoad(EntityUid entity, IEntityLoadContext? context = null);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Robust.Server.GameObjects
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
EntityUid IServerEntityManagerInternal.AllocEntity(string? prototypeName, EntityUid? uid)
|
||||
EntityUid IServerEntityManagerInternal.AllocEntity(string? prototypeName, EntityUid uid)
|
||||
{
|
||||
return AllocEntity(prototypeName, uid);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Robust.Server.GameObjects
|
||||
StartEntity(entity);
|
||||
}
|
||||
|
||||
private protected override EntityUid CreateEntity(string? prototypeName, EntityUid? uid = null)
|
||||
private protected override EntityUid CreateEntity(string? prototypeName, EntityUid uid = default)
|
||||
{
|
||||
var entity = base.CreateEntity(prototypeName, uid);
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Robust.Server.GameObjects
|
||||
if (reg.NetID is not {} netId)
|
||||
return;
|
||||
|
||||
var uid = e.OwnerUid;
|
||||
var uid = e.Owner;
|
||||
|
||||
if (!_componentDeletionHistory.TryGetValue(uid, out var list))
|
||||
{
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using NetSerializer;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
@@ -191,7 +185,7 @@ internal partial class PVSSystem : EntitySystem
|
||||
// since elements are cached grid-/map-relative, we dont need to update a given grids/maps children
|
||||
if(_mapManager.IsGrid(uid) || _mapManager.IsMap(uid)) return;
|
||||
|
||||
foreach (var componentChild in transformComponent.ChildEntityUids)
|
||||
foreach (var componentChild in transformComponent.ChildEntities)
|
||||
{
|
||||
UpdateEntityRecursive(componentChild);
|
||||
}
|
||||
@@ -587,11 +581,11 @@ internal partial class PVSSystem : EntitySystem
|
||||
if (session.Status != SessionStatus.InGame)
|
||||
return viewers;
|
||||
|
||||
if(session.AttachedEntityUid.HasValue)
|
||||
viewers.Add(session.AttachedEntityUid.Value);
|
||||
if (session.AttachedEntity.Valid)
|
||||
viewers.Add(session.AttachedEntity);
|
||||
|
||||
// This is awful, but we're not gonna add the list of view subscriptions to common session.
|
||||
if (session is IPlayerSession playerSession)
|
||||
if (session is IPlayerSession playerSession)
|
||||
{
|
||||
foreach (var uid in playerSession.ViewSubscriptions)
|
||||
{
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace Robust.Server.Placement
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve<IEntityManager>().HasComponent<IMapGridComponent>(entity) || IoCManager.Resolve<IEntityManager>().HasComponent<ActorComponent>(entity))
|
||||
continue;
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entity);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Robust.Server.Player
|
||||
{
|
||||
@@ -55,7 +54,7 @@ namespace Robust.Server.Player
|
||||
/// Do NOT use this unless you know what you're doing, you probably want <see cref="AttachToEntity"/>
|
||||
/// and <see cref="DetachFromEntity"/> instead.
|
||||
/// </summary>
|
||||
internal void SetAttachedEntity(EntityUid? entity);
|
||||
internal void SetAttachedEntity(EntityUid entity);
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to add an entity Uid to <see cref="ViewSubscriptions"/>.
|
||||
|
||||
@@ -5,10 +5,10 @@ using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Logger = Robust.Shared.Log.Logger;
|
||||
|
||||
namespace Robust.Server.Player
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace Robust.Server.Player
|
||||
[ViewVariables] public INetChannel ConnectedClient { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables] public EntityUid? AttachedEntityUid { get; set; }
|
||||
[ViewVariables] public EntityUid AttachedEntity { get; set; }
|
||||
|
||||
private SessionStatus _status = SessionStatus.Connecting;
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Robust.Server.Player
|
||||
/// <inheritdoc />
|
||||
public void DetachFromEntity()
|
||||
{
|
||||
if (AttachedEntityUid == null)
|
||||
if (AttachedEntity == null)
|
||||
return;
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
@@ -151,9 +151,9 @@ namespace Robust.Server.Player
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntityUid.Value))
|
||||
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntity))
|
||||
{
|
||||
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntityUid}\"! Is it missing an ActorComponent?");
|
||||
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntity}\"! Is it missing an ActorComponent?");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,9 +177,9 @@ namespace Robust.Server.Player
|
||||
|
||||
private void SetAttachedEntityName()
|
||||
{
|
||||
if (Name != null && AttachedEntityUid != null)
|
||||
if (Name != null && AttachedEntity != default)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntityUid!.Value).EntityName = Name;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntity).EntityName = Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,9 +198,9 @@ namespace Robust.Server.Player
|
||||
public LoginType AuthType => ConnectedClient.AuthType;
|
||||
|
||||
/// <inheritdoc />
|
||||
void IPlayerSession.SetAttachedEntity(EntityUid? entity)
|
||||
void IPlayerSession.SetAttachedEntity(EntityUid entity)
|
||||
{
|
||||
AttachedEntityUid = entity;
|
||||
AttachedEntity = entity;
|
||||
UpdatePlayerState();
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Robust.Server.Player
|
||||
{
|
||||
PlayerState.Status = Status;
|
||||
PlayerState.Name = Name;
|
||||
PlayerState.ControlledEntity = AttachedEntityUid;
|
||||
PlayerState.ControlledEntity = AttachedEntity;
|
||||
|
||||
_playerManager.Dirty();
|
||||
}
|
||||
|
||||
@@ -131,13 +131,13 @@ namespace Robust.Server.ViewVariables
|
||||
break;
|
||||
case ViewVariablesEntitySelector entitySelector:
|
||||
{
|
||||
if (!_entityManager.TryGetEntity(entitySelector.Entity, out var entity))
|
||||
if (!_entityManager.EntityExists(entitySelector.Entity))
|
||||
{
|
||||
Deny(DenyReason.NoObject);
|
||||
return;
|
||||
}
|
||||
|
||||
theObject = entity;
|
||||
theObject = entitySelector.Entity;
|
||||
break;
|
||||
}
|
||||
case ViewVariablesSessionRelativeSelector sessionRelativeSelector:
|
||||
|
||||
@@ -666,7 +666,7 @@ namespace Robust.Shared.Maths
|
||||
var quaternion = new Quaternion();
|
||||
if (num8 > 0f)
|
||||
{
|
||||
var num = (float) MathF.Sqrt(num8 + 1f);
|
||||
var num = MathF.Sqrt(num8 + 1f);
|
||||
quaternion.w = num * 0.5f;
|
||||
num = 0.5f / num;
|
||||
quaternion.X = (m12 - m21) * num;
|
||||
@@ -677,7 +677,7 @@ namespace Robust.Shared.Maths
|
||||
|
||||
if (m00 >= m11 && m00 >= m22)
|
||||
{
|
||||
var num7 = (float) MathF.Sqrt(1f + m00 - m11 - m22);
|
||||
var num7 = MathF.Sqrt(1f + m00 - m11 - m22);
|
||||
var num4 = 0.5f / num7;
|
||||
quaternion.X = 0.5f * num7;
|
||||
quaternion.Y = (m01 + m10) * num4;
|
||||
@@ -688,7 +688,7 @@ namespace Robust.Shared.Maths
|
||||
|
||||
if (m11 > m22)
|
||||
{
|
||||
var num6 = (float) MathF.Sqrt(1f + m11 - m00 - m22);
|
||||
var num6 = MathF.Sqrt(1f + m11 - m00 - m22);
|
||||
var num3 = 0.5f / num6;
|
||||
quaternion.X = (m10 + m01) * num3;
|
||||
quaternion.Y = 0.5f * num6;
|
||||
@@ -697,7 +697,7 @@ namespace Robust.Shared.Maths
|
||||
return quaternion;
|
||||
}
|
||||
|
||||
var num5 = (float) MathF.Sqrt(1f + m22 - m00 - m11);
|
||||
var num5 = MathF.Sqrt(1f + m22 - m00 - m11);
|
||||
var num2 = 0.5f / num5;
|
||||
quaternion.X = (m20 + m02) * num2;
|
||||
quaternion.Y = (m21 + m12) * num2;
|
||||
@@ -725,7 +725,7 @@ namespace Robust.Shared.Maths
|
||||
if (test > 0.4995f * unit)
|
||||
{
|
||||
// singularity at north pole
|
||||
v.Y = (float) (2f * MathF.Atan2(rotation.y, rotation.x));
|
||||
v.Y = 2f * MathF.Atan2(rotation.y, rotation.x);
|
||||
v.X = (float) (Math.PI / 2);
|
||||
v.Z = 0;
|
||||
return NormalizeAngles(v * RadToDeg);
|
||||
@@ -734,16 +734,16 @@ namespace Robust.Shared.Maths
|
||||
if (test < -0.4995f * unit)
|
||||
{
|
||||
// singularity at south pole
|
||||
v.Y = (float) (-2f * MathF.Atan2(rotation.y, rotation.x));
|
||||
v.Y = -2f * MathF.Atan2(rotation.y, rotation.x);
|
||||
v.X = (float) (-Math.PI / 2);
|
||||
v.Z = 0;
|
||||
return NormalizeAngles(v * RadToDeg);
|
||||
}
|
||||
|
||||
var q = new Quaternion(rotation.w, rotation.z, rotation.x, rotation.y);
|
||||
v.Y = (float) MathF.Atan2(2f * q.x * q.w + 2f * q.y * q.z, 1 - 2f * (q.z * q.z + q.w * q.w)); // Yaw
|
||||
v.X = (float) MathF.Asin(2f * (q.x * q.z - q.w * q.y)); // Pitch
|
||||
v.Z = (float) MathF.Atan2(2f * q.x * q.y + 2f * q.z * q.w, 1 - 2f * (q.y * q.y + q.z * q.z)); // Roll
|
||||
v.Y = MathF.Atan2(2f * q.x * q.w + 2f * q.y * q.z, 1 - 2f * (q.z * q.z + q.w * q.w)); // Yaw
|
||||
v.X = MathF.Asin(2f * (q.x * q.z - q.w * q.y)); // Pitch
|
||||
v.Z = MathF.Atan2(2f * q.x * q.y + 2f * q.z * q.w, 1 - 2f * (q.y * q.y + q.z * q.z)); // Roll
|
||||
return NormalizeAngles(v * RadToDeg);
|
||||
}
|
||||
|
||||
|
||||
@@ -956,7 +956,7 @@ namespace Robust.Shared.Maths
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float CalculateAngle(Vector3 first, Vector3 second)
|
||||
{
|
||||
return (float) MathF.Acos(Dot(first, second) / (first.Length * second.Length));
|
||||
return MathF.Acos(Dot(first, second) / (first.Length * second.Length));
|
||||
}
|
||||
|
||||
/// <summary>Calculates the angle (in radians) between two vectors.</summary>
|
||||
@@ -968,7 +968,7 @@ namespace Robust.Shared.Maths
|
||||
public static void CalculateAngle(ref Vector3 first, ref Vector3 second, out float result)
|
||||
{
|
||||
Dot(ref first, ref second, out var temp);
|
||||
result = (float) MathF.Acos(temp / (first.Length * second.Length));
|
||||
result = MathF.Acos(temp / (first.Length * second.Length));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Robust.Shared.Containers
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
foreach (var entity in _containerList)
|
||||
{
|
||||
entMan.DeleteEntity((EntityUid) entity);
|
||||
entMan.DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Robust.Shared.Containers
|
||||
{
|
||||
if ((!entMan.EntityExists(ent) ? EntityLifeStage.Deleted : entMan.GetComponent<MetaDataComponent>(ent).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
|
||||
container.ForceRemove(ent);
|
||||
entMan.DeleteEntity((EntityUid) ent);
|
||||
entMan.DeleteEntity(ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -78,7 +77,7 @@ namespace Robust.Shared.Containers
|
||||
|
||||
for (var index = 0; index < container.ContainedEntities.Count; index++)
|
||||
{
|
||||
var iEntity = container.ContainedEntities[index];
|
||||
var EntityUid= container.ContainedEntities[index];
|
||||
uidArr[index] = iEntity;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// EntityUid of the entity this component belongs to.
|
||||
/// </summary>
|
||||
public EntityUid OwnerUid { get; }
|
||||
public EntityUid Owner { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="ComponentEventArgs"/>.
|
||||
/// </summary>
|
||||
/// <param name="component">The relevant component</param>
|
||||
/// <param name="ownerUid">EntityUid of the entity this component belongs to.</param>
|
||||
protected ComponentEventArgs(IComponent component, EntityUid ownerUid)
|
||||
/// <param name="Owner">EntityUid of the entity this component belongs to.</param>
|
||||
protected ComponentEventArgs(IComponent component, EntityUid Owner)
|
||||
{
|
||||
Component = component;
|
||||
OwnerUid = ownerUid;
|
||||
Owner = Owner;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Dynamics.Contacts;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -982,8 +981,8 @@ namespace Robust.Shared.GameObjects
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out JointComponent? jointComponentA) &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(other.Owner, out JointComponent? jointComponentB))
|
||||
{
|
||||
var aUid = (EntityUid) jointComponentA.Owner;
|
||||
var bUid = (EntityUid) jointComponentB.Owner;
|
||||
var aUid = jointComponentA.Owner;
|
||||
var bUid = jointComponentB.Owner;
|
||||
|
||||
foreach (var (_, joint) in jointComponentA.Joints)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -65,7 +64,7 @@ namespace Robust.Shared.GameObjects
|
||||
_mapIndex = state.MapId;
|
||||
LightingEnabled = state.LightingEnabled;
|
||||
|
||||
((TransformComponent) IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner)).ChangeMapId(_mapIndex);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).ChangeMapId(_mapIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@ using System;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
@@ -70,7 +68,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <inheritdoc />
|
||||
public bool AnchorEntity(TransformComponent transform)
|
||||
{
|
||||
var xform = (TransformComponent) transform;
|
||||
var xform = transform;
|
||||
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
|
||||
var result = Grid.AddToSnapGridCell(tileIndices, ((IComponent) transform).Owner);
|
||||
|
||||
@@ -100,7 +98,7 @@ namespace Robust.Shared.GameObjects
|
||||
if(GridIndex == GridId.Invalid)
|
||||
return;
|
||||
|
||||
var xform = (TransformComponent)transform;
|
||||
var xform = transform;
|
||||
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
|
||||
Grid.RemoveFromSnapGridCell(tileIndices, ((IComponent) transform).Owner);
|
||||
xform.SetAnchored(false);
|
||||
|
||||
@@ -4,10 +4,8 @@ using System.Linq;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -86,7 +84,7 @@ namespace Robust.Shared.GameObjects
|
||||
_gridId = value;
|
||||
foreach (var transformComponent in Children)
|
||||
{
|
||||
var child = (TransformComponent) transformComponent;
|
||||
var child = transformComponent;
|
||||
child.GridID = value;
|
||||
}
|
||||
}
|
||||
@@ -458,7 +456,7 @@ namespace Robust.Shared.GameObjects
|
||||
return IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(u);
|
||||
});
|
||||
|
||||
[ViewVariables] public IEnumerable<EntityUid> ChildEntityUids => _children;
|
||||
[ViewVariables] public IEnumerable<EntityUid> ChildEntities => _children;
|
||||
|
||||
[ViewVariables] public int ChildCount => _children.Count;
|
||||
|
||||
|
||||
@@ -272,12 +272,12 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
_subscriptionLock = true;
|
||||
|
||||
AddComponent(e.OwnerUid, e.Component.GetType());
|
||||
AddComponent(e.Owner, e.Component.GetType());
|
||||
}
|
||||
|
||||
private void OnComponentRemoved(object? sender, ComponentEventArgs e)
|
||||
{
|
||||
RemoveComponent(e.OwnerUid, e.Component.GetType());
|
||||
RemoveComponent(e.Owner, e.Component.GetType());
|
||||
}
|
||||
|
||||
private void AddSubscription(Type compType, Type eventType, DirectedRegistration registration)
|
||||
|
||||
@@ -3,22 +3,21 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
#if EXCEPTION_TOLERANCE
|
||||
using Robust.Shared.Exceptions;
|
||||
#endif
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
using DependencyAttribute = Robust.Shared.IoC.DependencyAttribute;
|
||||
#if EXCEPTION_TOLERANCE
|
||||
using Robust.Shared.Exceptions;
|
||||
#endif
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EntityManager
|
||||
{
|
||||
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
||||
[Dependency] private readonly IComponentDependencyManager _componentDependencyManager = default!;
|
||||
[IoC.Dependency] private readonly IComponentFactory _componentFactory = default!;
|
||||
[IoC.Dependency] private readonly IComponentDependencyManager _componentDependencyManager = default!;
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
|
||||
@@ -124,7 +123,7 @@ namespace Robust.Shared.GameObjects
|
||||
#endif
|
||||
DebugTools.Assert(metadata.EntityLifeStage == EntityLifeStage.Initializing);
|
||||
metadata.EntityLifeStage = EntityLifeStage.Initialized;
|
||||
EventBus.RaiseEvent(EventSource.Local, new EntityInitializedMessage(GetEntity(uid)));
|
||||
EventBus.RaiseEvent(EventSource.Local, new EntityInitializedMessage(uid));
|
||||
}
|
||||
|
||||
public void StartComponents(EntityUid uid)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Prometheus;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -42,11 +40,11 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// All entities currently stored in the manager.
|
||||
/// </summary>
|
||||
protected readonly Dictionary<EntityUid, EntityUid> Entities = new();
|
||||
protected readonly HashSet<EntityUid> Entities = new();
|
||||
|
||||
private EntityEventBus _eventBus = null!;
|
||||
|
||||
protected virtual int NextEntityUid { get; set; } = (int)EntityUid.FirstUid;
|
||||
protected virtual int NextEntityUid { get; set; } = (int) EntityUid.FirstUid;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEventBus EventBus => _eventBus;
|
||||
@@ -146,7 +144,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
#region Entity Management
|
||||
|
||||
public EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid? euid)
|
||||
public EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid euid)
|
||||
{
|
||||
return CreateEntity(prototypeName, euid);
|
||||
}
|
||||
@@ -203,43 +201,11 @@ namespace Robust.Shared.GameObjects
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <returns>Entity or throws if the entity doesn't exist</returns>
|
||||
public EntityUid GetEntity(EntityUid uid)
|
||||
{
|
||||
return Entities[uid];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to get an entity, returning whether or not an entity was gotten.
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
|
||||
/// <returns>True if a value was returned, false otherwise.</returns>
|
||||
public bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out EntityUid? entity)
|
||||
{
|
||||
if (Entities.TryGetValue(uid, out var cEntity) && !((!EntityExists(cEntity) ? EntityLifeStage.Deleted : GetComponent<MetaDataComponent>(cEntity).EntityLifeStage) >= EntityLifeStage.Deleted))
|
||||
{
|
||||
entity = cEntity;
|
||||
return true;
|
||||
}
|
||||
|
||||
// entity might get assigned if it's deleted but still found,
|
||||
// prevent somebody from being "smart".
|
||||
entity = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int EntityCount => Entities.Count;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<EntityUid> GetEntities() => Entities.Values;
|
||||
|
||||
public IEnumerable<EntityUid> GetEntityUids() => Entities.Keys;
|
||||
public IEnumerable<EntityUid> GetEntities() => Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Marks this entity as dirty so that it will be updated over the network.
|
||||
@@ -292,7 +258,7 @@ namespace Robust.Shared.GameObjects
|
||||
if((!EntityExists(entity) ? EntityLifeStage.Deleted : GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted) //TODO: Why was this still a child if it was already deleted?
|
||||
return;
|
||||
|
||||
var uid = (EntityUid) entity;
|
||||
var uid = entity;
|
||||
var transform = GetComponent<TransformComponent>(entity);
|
||||
var metadata = GetComponent<MetaDataComponent>(entity);
|
||||
GetComponent<MetaDataComponent>(entity).EntityLifeStage = EntityLifeStage.Terminating;
|
||||
@@ -353,7 +319,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Allocates an entity and stores it but does not load components or do initialization.
|
||||
/// </summary>
|
||||
private protected EntityUid AllocEntity(string? prototypeName, EntityUid? uid = null)
|
||||
private protected EntityUid AllocEntity(string? prototypeName, EntityUid uid = default)
|
||||
{
|
||||
EntityPrototype? prototype = null;
|
||||
if (!string.IsNullOrWhiteSpace(prototypeName))
|
||||
@@ -372,38 +338,37 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Allocates an entity and stores it but does not load components or do initialization.
|
||||
/// </summary>
|
||||
private protected EntityUid AllocEntity(EntityUid? uid = null)
|
||||
private protected EntityUid AllocEntity(EntityUid uid = default)
|
||||
{
|
||||
if (uid == null)
|
||||
if (uid == default)
|
||||
{
|
||||
uid = GenerateEntityUid();
|
||||
}
|
||||
|
||||
if (EntityExists(uid.Value))
|
||||
if (EntityExists(uid))
|
||||
{
|
||||
throw new InvalidOperationException($"UID already taken: {uid}");
|
||||
}
|
||||
|
||||
// we want this called before adding components
|
||||
EntityAdded?.Invoke(this, uid.Value);
|
||||
EntityAdded?.Invoke(this, uid);
|
||||
|
||||
// Create the MetaDataComponent and set it directly on the Entity to avoid a stack overflow in DEBUG.
|
||||
var metadata = new MetaDataComponent() { Owner = uid.Value };
|
||||
Entities[uid.Value] = uid.Value;
|
||||
var metadata = new MetaDataComponent { Owner = uid };
|
||||
Entities.Add(uid);
|
||||
// add the required MetaDataComponent directly.
|
||||
AddComponentInternal(uid.Value, metadata);
|
||||
AddComponentInternal(uid, metadata);
|
||||
|
||||
// allocate the required TransformComponent
|
||||
AddComponent<TransformComponent>(uid.Value);
|
||||
AddComponent<TransformComponent>(uid);
|
||||
|
||||
|
||||
return uid.Value;
|
||||
return uid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates an entity and loads components but does not do initialization.
|
||||
/// </summary>
|
||||
private protected virtual EntityUid CreateEntity(string? prototypeName, EntityUid? uid = null)
|
||||
private protected virtual EntityUid CreateEntity(string? prototypeName, EntityUid uid = default)
|
||||
{
|
||||
if (prototypeName == null)
|
||||
return AllocEntity(uid);
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Robust.Shared.GameObjects
|
||||
_uid = uid;
|
||||
}
|
||||
|
||||
public bool Valid => IsValid();
|
||||
|
||||
/// <summary>
|
||||
/// Creates an entity UID by parsing a string number.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using Prometheus;
|
||||
using Robust.Shared.Map;
|
||||
@@ -46,7 +45,7 @@ namespace Robust.Shared.GameObjects
|
||||
event EventHandler<EntityUid>? EntityStarted;
|
||||
event EventHandler<EntityUid>? EntityDeleted;
|
||||
|
||||
EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid? euid);
|
||||
EntityUid CreateEntityUninitialized(string? prototypeName, EntityUid euid);
|
||||
|
||||
EntityUid CreateEntityUninitialized(string? prototypeName);
|
||||
|
||||
@@ -70,21 +69,6 @@ namespace Robust.Shared.GameObjects
|
||||
/// <returns></returns>
|
||||
EntityUid SpawnEntity(string? protoName, MapCoordinates coordinates);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an entity by id
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <returns>Entity or throws if entity id doesn't exist</returns>
|
||||
EntityUid GetEntity(EntityUid uid);
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to get an entity, returning whether or not an entity was gotten.
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="entity">The requested entity or null if the entity couldn't be found.</param>
|
||||
/// <returns>True if a value was returned, false otherwise.</returns>
|
||||
bool TryGetEntity(EntityUid uid, [NotNullWhen(true)] out EntityUid? entity);
|
||||
|
||||
/// <summary>
|
||||
/// How many entities are currently active.
|
||||
/// </summary>
|
||||
@@ -96,12 +80,6 @@ namespace Robust.Shared.GameObjects
|
||||
/// <returns></returns>
|
||||
IEnumerable<EntityUid> GetEntities();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all entities by uid
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<EntityUid> GetEntityUids();
|
||||
|
||||
public void DirtyEntity(EntityUid uid);
|
||||
|
||||
public void QueueDeleteEntity(EntityUid uid);
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void HandleGridInit(GridInitializeEvent ev)
|
||||
{
|
||||
_entityManager.GetEntity(ev.EntityUid).EnsureComponent<EntityLookupComponent>();
|
||||
_entityManager.EnsureComponent<EntityLookupComponent>(ev.EntityUid);
|
||||
}
|
||||
|
||||
private void HandleLookupInit(EntityUid uid, EntityLookupComponent component, ComponentInit args)
|
||||
@@ -215,14 +215,13 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void HandleEntityDeleted(object? sender, EntityUid uid)
|
||||
{
|
||||
RemoveFromEntityTrees(_entityManager.GetEntity(uid));
|
||||
RemoveFromEntityTrees(uid);
|
||||
}
|
||||
|
||||
private void HandleEntityStarted(object? sender, EntityUid uid)
|
||||
{
|
||||
var entity = _entityManager.GetEntity(uid);
|
||||
if (_entityManager.GetComponent<TransformComponent>(entity).Anchored) return;
|
||||
UpdateEntityTree(entity);
|
||||
if (_entityManager.GetComponent<TransformComponent>(uid).Anchored) return;
|
||||
UpdateEntityTree(uid);
|
||||
}
|
||||
|
||||
private void HandleMapCreated(object? sender, MapEventArgs eventArgs)
|
||||
@@ -806,11 +805,11 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
if (!_entityManager.HasComponent<EntityLookupComponent>(entity))
|
||||
{
|
||||
foreach (var childTx in _entityManager.GetComponent<TransformComponent>(entity).ChildEntityUids)
|
||||
foreach (var childTx in _entityManager.GetComponent<TransformComponent>(entity).ChildEntities)
|
||||
{
|
||||
if (!_handledThisTick.Add(childTx)) continue;
|
||||
|
||||
if (UpdateEntityTree(_entityManager.GetEntity(childTx)))
|
||||
if (UpdateEntityTree(childTx))
|
||||
{
|
||||
++necessary;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void HandleGridInit(GridInitializeEvent ev)
|
||||
{
|
||||
EntityManager.GetEntity(ev.EntityUid).EnsureComponent<OccluderTreeComponent>();
|
||||
EntityManager.EnsureComponent<OccluderTreeComponent>(ev.EntityUid);
|
||||
}
|
||||
|
||||
private OccluderTreeComponent? GetOccluderTree(OccluderComponent component)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -122,9 +121,7 @@ namespace Robust.Shared.Map
|
||||
/// <exception cref="InvalidOperationException">If <see cref="entityUid"/> is not on the same map as the <see cref="coordinates"/>.</exception>
|
||||
public static EntityCoordinates FromMap(IEntityManager entityManager, EntityUid entityUid, MapCoordinates coordinates)
|
||||
{
|
||||
var entity = entityManager.GetEntity(entityUid);
|
||||
|
||||
return FromMap(entity, coordinates);
|
||||
return FromMap(entityUid, coordinates);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -88,11 +88,11 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
else if (_mapEntities.TryGetValue(MapId.Nullspace, out var mapEntId))
|
||||
{
|
||||
var mapEnt = _entityManager.GetEntity(mapEntId);
|
||||
var mapEnt = mapEntId;
|
||||
|
||||
foreach (var childTransform in _entityManager.GetComponent<TransformComponent>(mapEnt).Children.ToArray())
|
||||
{
|
||||
_entityManager.DeleteEntity((EntityUid) childTransform.Owner);
|
||||
_entityManager.DeleteEntity(childTransform.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,11 +137,8 @@ namespace Robust.Shared.Map
|
||||
|
||||
if (_mapEntities.TryGetValue(MapId.Nullspace, out var entId))
|
||||
{
|
||||
if (_entityManager.TryGetEntity(entId, out var entity))
|
||||
{
|
||||
Logger.InfoS("map", $"Deleting map entity {entId}");
|
||||
_entityManager.DeleteEntity((EntityUid) entity);
|
||||
}
|
||||
Logger.InfoS("map", $"Deleting map entity {entId}");
|
||||
_entityManager.DeleteEntity(entId);
|
||||
|
||||
if (_mapEntities.Remove(MapId.Nullspace))
|
||||
Logger.InfoS("map", "Removing nullspace map entity.");
|
||||
@@ -207,9 +204,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
if (_mapEntities.TryGetValue(mapID, out var ent))
|
||||
{
|
||||
if (_entityManager.TryGetEntity(ent, out var mapEnt))
|
||||
_entityManager.DeleteEntity((EntityUid) mapEnt);
|
||||
|
||||
_entityManager.DeleteEntity(ent);
|
||||
_mapEntities.Remove(mapID);
|
||||
}
|
||||
|
||||
@@ -218,10 +213,10 @@ namespace Robust.Shared.Map
|
||||
|
||||
public MapId CreateMap(MapId? mapID = null)
|
||||
{
|
||||
return CreateMap(mapID, null);
|
||||
return CreateMap(mapID, default);
|
||||
}
|
||||
|
||||
public MapId CreateMap(MapId? mapID, EntityUid? entityUid)
|
||||
public MapId CreateMap(MapId? mapID, EntityUid entityUid)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugTools.Assert(_dbgGuardRunning);
|
||||
@@ -332,8 +327,7 @@ namespace Robust.Shared.Map
|
||||
if (_mapEntities.TryGetValue(mapId, out var oldEntId))
|
||||
{
|
||||
//Note: This prevents setting a subgraph as the root, since the subgraph will be deleted
|
||||
var oldMapEnt = _entityManager.GetEntity(oldEntId);
|
||||
_entityManager.DeleteEntity(oldMapEnt);
|
||||
_entityManager.DeleteEntity(oldEntId);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -392,7 +386,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
public IMapGrid CreateGrid(MapId currentMapID, GridId? gridID = null, ushort chunkSize = 16)
|
||||
{
|
||||
return CreateGridImpl(currentMapID, gridID, chunkSize, true, null);
|
||||
return CreateGridImpl(currentMapID, gridID, chunkSize, true, default);
|
||||
}
|
||||
|
||||
public IMapGrid CreateGrid(MapId currentMapID, GridId gridID, ushort chunkSize, EntityUid euid)
|
||||
@@ -401,7 +395,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
private IMapGridInternal CreateGridImpl(MapId currentMapID, GridId? gridID, ushort chunkSize, bool createEntity,
|
||||
EntityUid? euid)
|
||||
EntityUid euid)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugTools.Assert(_dbgGuardRunning);
|
||||
@@ -483,7 +477,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
public IMapGridInternal CreateGridNoEntity(MapId currentMapID, GridId? gridID = null, ushort chunkSize = 16)
|
||||
{
|
||||
return CreateGridImpl(currentMapID, gridID, chunkSize, false, null);
|
||||
return CreateGridImpl(currentMapID, gridID, chunkSize, false, default);
|
||||
}
|
||||
|
||||
public IMapGrid GetGrid(GridId gridID)
|
||||
@@ -538,8 +532,7 @@ namespace Robust.Shared.Map
|
||||
// (though now we need some extra calcs up front).
|
||||
|
||||
// Doesn't use WorldBounds because it's just an AABB.
|
||||
var gridEnt = _entityManager.GetEntity(mapGrid.GridEntityId);
|
||||
var matrix = _entityManager.GetComponent<TransformComponent>(gridEnt).InvWorldMatrix;
|
||||
var matrix = _entityManager.GetComponent<TransformComponent>(mapGrid.GridEntityId).InvWorldMatrix;
|
||||
var localPos = matrix.Transform(worldPos);
|
||||
|
||||
var tile = new Vector2i((int) Math.Floor(localPos.X), (int) Math.Floor(localPos.Y));
|
||||
|
||||
@@ -2217,9 +2217,9 @@ namespace Robust.Shared.Noise
|
||||
int y3 = y1 + 2;
|
||||
int z3 = z1 + 2;
|
||||
|
||||
FN_DECIMAL xs = x - (FN_DECIMAL) x1;
|
||||
FN_DECIMAL ys = y - (FN_DECIMAL) y1;
|
||||
FN_DECIMAL zs = z - (FN_DECIMAL) z1;
|
||||
FN_DECIMAL xs = x - x1;
|
||||
FN_DECIMAL ys = y - y1;
|
||||
FN_DECIMAL zs = z - z1;
|
||||
|
||||
return CubicLerp(
|
||||
CubicLerp(
|
||||
@@ -2363,8 +2363,8 @@ namespace Robust.Shared.Noise
|
||||
int x3 = x1 + 2;
|
||||
int y3 = y1 + 2;
|
||||
|
||||
FN_DECIMAL xs = x - (FN_DECIMAL) x1;
|
||||
FN_DECIMAL ys = y - (FN_DECIMAL) y1;
|
||||
FN_DECIMAL xs = x - x1;
|
||||
FN_DECIMAL ys = y - y1;
|
||||
|
||||
return CubicLerp(
|
||||
CubicLerp(ValCoord2D(seed, x0, y0), ValCoord2D(seed, x1, y0), ValCoord2D(seed, x2, y0),
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Robust.Shared.Physics.Collision
|
||||
var NH = MathF.Abs(WX * SF) + MathF.Abs(WY * CF); //boundrect half-height
|
||||
var NW = MathF.Abs(WX * CF) + MathF.Abs(WY * SF); //boundrect half-width
|
||||
|
||||
return new Box2((float)(CX - NW), (float)(CY - NH), (float)(CX + NW), (float)(CY + NH)); //draw bound rectangle
|
||||
return new Box2(CX - NW, CY - NH, CX + NW, CY + NH); //draw bound rectangle
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -25,7 +25,6 @@ using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Maths;
|
||||
using Proxy = Robust.Shared.Physics.DynamicTree.Proxy;
|
||||
|
||||
namespace Robust.Shared.Physics
|
||||
{
|
||||
@@ -68,7 +67,7 @@ namespace Robust.Shared.Physics
|
||||
private readonly ExtractAabbDelegate _extractAabb;
|
||||
|
||||
// avoids "Collection was modified; enumeration operation may not execute."
|
||||
private Dictionary<T, Proxy> _nodeLookup;
|
||||
private Dictionary<T, DynamicTree.Proxy> _nodeLookup;
|
||||
public readonly B2DynamicTree<T> _b2Tree;
|
||||
|
||||
public DynamicTree(ExtractAabbDelegate extractAabbFunc, IEqualityComparer<T>? comparer = null, float aabbExtendSize = 1f / 32, int capacity = 256, Func<int, int>? growthFunc = null)
|
||||
@@ -77,7 +76,7 @@ namespace Robust.Shared.Physics
|
||||
|
||||
_extractAabb = extractAabbFunc;
|
||||
_equalityComparer = comparer ?? EqualityComparer<T>.Default;
|
||||
_nodeLookup = new Dictionary<T, Proxy>(_equalityComparer);
|
||||
_nodeLookup = new Dictionary<T, DynamicTree.Proxy>(_equalityComparer);
|
||||
_b2Tree = new B2DynamicTree<T>(aabbExtendSize, capacity, growthFunc);
|
||||
}
|
||||
|
||||
@@ -133,7 +132,7 @@ namespace Robust.Shared.Physics
|
||||
|
||||
if (CheckNaNs(aabb.Value))
|
||||
{
|
||||
_nodeLookup[item] = Proxy.Free;
|
||||
_nodeLookup[item] = DynamicTree.Proxy.Free;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -144,18 +143,18 @@ namespace Robust.Shared.Physics
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private bool TryGetProxy(in T item, out Proxy proxy)
|
||||
private bool TryGetProxy(in T item, out DynamicTree.Proxy proxy)
|
||||
=> _nodeLookup.TryGetValue(item, out proxy);
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Box2? GetNodeBounds(T item)
|
||||
=> TryGetProxy(item, out var proxy) ? _b2Tree.GetFatAabb(proxy) : (Box2?) null;
|
||||
=> TryGetProxy(item, out var proxy) ? _b2Tree.GetFatAabb(proxy) : null;
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Box2? GetNodeBounds(in T item)
|
||||
=> TryGetProxy(item, out var proxy) ? _b2Tree.GetFatAabb(proxy) : (Box2?) null;
|
||||
=> TryGetProxy(item, out var proxy) ? _b2Tree.GetFatAabb(proxy) : null;
|
||||
|
||||
|
||||
public bool Remove(in T item)
|
||||
@@ -165,7 +164,7 @@ namespace Robust.Shared.Physics
|
||||
return false;
|
||||
}
|
||||
|
||||
if (proxy != Proxy.Free)
|
||||
if (proxy != DynamicTree.Proxy.Free)
|
||||
{
|
||||
_b2Tree.DestroyProxy(proxy);
|
||||
}
|
||||
@@ -188,17 +187,17 @@ namespace Robust.Shared.Physics
|
||||
|
||||
if (CheckNaNs(newBox.Value))
|
||||
{
|
||||
if (proxy == Proxy.Free)
|
||||
if (proxy == DynamicTree.Proxy.Free)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_b2Tree.DestroyProxy(proxy);
|
||||
_nodeLookup[item] = Proxy.Free;
|
||||
_nodeLookup[item] = DynamicTree.Proxy.Free;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (proxy == Proxy.Free)
|
||||
if (proxy == DynamicTree.Proxy.Free)
|
||||
{
|
||||
_nodeLookup[item] = _b2Tree.CreateProxy(newBox.Value, item);
|
||||
return true;
|
||||
@@ -242,7 +241,7 @@ namespace Robust.Shared.Physics
|
||||
var tuple = (state, _b2Tree, callback, point, approx, _extractAabb);
|
||||
_b2Tree.Query(ref tuple,
|
||||
(ref (TState state, B2DynamicTree<T> tree, QueryCallbackDelegate<TState> callback, Vector2 point, bool approx, ExtractAabbDelegate extract) tuple,
|
||||
Proxy proxy) =>
|
||||
DynamicTree.Proxy proxy) =>
|
||||
{
|
||||
var item = tuple.tree.GetUserData(proxy)!;
|
||||
|
||||
@@ -283,7 +282,7 @@ namespace Robust.Shared.Physics
|
||||
state = tuple.state;
|
||||
}
|
||||
|
||||
private static bool AabbQueryStateCallback<TState>(ref (TState state, B2DynamicTree<T> tree, QueryCallbackDelegate<TState> callback, Box2 aabb, bool approx, ExtractAabbDelegate extract) tuple, Proxy proxy)
|
||||
private static bool AabbQueryStateCallback<TState>(ref (TState state, B2DynamicTree<T> tree, QueryCallbackDelegate<TState> callback, Box2 aabb, bool approx, ExtractAabbDelegate extract) tuple, DynamicTree.Proxy proxy)
|
||||
{
|
||||
var item = tuple.tree.GetUserData(proxy)!;
|
||||
if (!tuple.approx)
|
||||
@@ -298,7 +297,7 @@ namespace Robust.Shared.Physics
|
||||
return tuple.callback(ref tuple.state, item);
|
||||
}
|
||||
|
||||
private static bool RayQueryStateCallback<TState>(ref (TState state, RayQueryCallbackDelegate<TState> callback, B2DynamicTree<T> tree, ExtractAabbDelegate? extract, Ray srcRay) tuple, Proxy proxy, in Vector2 hitPos, float distance)
|
||||
private static bool RayQueryStateCallback<TState>(ref (TState state, RayQueryCallbackDelegate<TState> callback, B2DynamicTree<T> tree, ExtractAabbDelegate? extract, Ray srcRay) tuple, DynamicTree.Proxy proxy, in Vector2 hitPos, float distance)
|
||||
{
|
||||
var item = tuple.tree.GetUserData(proxy)!;
|
||||
var hit = hitPos;
|
||||
|
||||
@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -79,7 +78,7 @@ namespace Robust.Shared.Physics
|
||||
/* TODO: Literally only AllComponentsOneToOneDeleteTest fails on this so fuck it this is what we get.
|
||||
else
|
||||
{
|
||||
Logger.ErrorS("physics", $"Didn't find a {nameof(PhysicsComponent)} attached to {EntityManager.GetEntity(uid)}");
|
||||
Logger.ErrorS("physics", $"Didn't find a {nameof(PhysicsComponuid)}"
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Robust.Shared.Player
|
||||
/// </summary>
|
||||
public Filter AddWhereAttachedEntity(Predicate<EntityUid> predicate)
|
||||
{
|
||||
return AddWhere(session => session.AttachedEntityUid is { } uid && predicate(uid));
|
||||
return AddWhere(session => session.AttachedEntity is { } uid && predicate(uid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -155,8 +155,8 @@ namespace Robust.Shared.Player
|
||||
public Filter AddInRange(MapCoordinates position, float range, ISharedPlayerManager? playerMan = null)
|
||||
{
|
||||
return AddWhere(session =>
|
||||
session.AttachedEntityUid != null &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntityUid!.Value).MapPosition, range), playerMan);
|
||||
session.AttachedEntity.Valid &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity).MapPosition, range), playerMan);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,8 +165,8 @@ namespace Robust.Shared.Player
|
||||
public Filter RemoveByVisibility(uint flag)
|
||||
{
|
||||
return RemoveWhere(session =>
|
||||
session.AttachedEntityUid == null
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntityUid!.Value, out SharedEyeComponent? eye)
|
||||
session.AttachedEntity.Valid
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(session.AttachedEntity, out SharedEyeComponent? eye)
|
||||
|| (eye.VisibilityMask & flag) == 0);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace Robust.Shared.Player
|
||||
/// </summary>
|
||||
public Filter RemoveWhereAttachedEntity(Predicate<EntityUid> predicate)
|
||||
{
|
||||
_recipients.RemoveWhere(session => session.AttachedEntityUid is { } uid && predicate(uid));
|
||||
_recipients.RemoveWhere(session => session.AttachedEntity is { } uid && predicate(uid));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ namespace Robust.Shared.Player
|
||||
public Filter RemoveInRange(MapCoordinates position, float range)
|
||||
{
|
||||
return RemoveWhere(session =>
|
||||
session.AttachedEntityUid != null &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntityUid.Value!).MapPosition, range));
|
||||
session.AttachedEntity.Valid &&
|
||||
position.InRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(session.AttachedEntity).MapPosition, range));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Robust.Shared.Players
|
||||
{
|
||||
@@ -18,7 +18,7 @@ namespace Robust.Shared.Players
|
||||
/// <summary>
|
||||
/// Entity UID that this session is represented by in the world, if any.
|
||||
/// </summary>
|
||||
EntityUid? AttachedEntityUid { get; }
|
||||
EntityUid? AttachedEntity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The UID of this session.
|
||||
@@ -44,14 +44,9 @@ namespace Robust.Shared.Players
|
||||
/// </remarks>
|
||||
INetChannel ConnectedClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Porting convenience
|
||||
/// </summary>
|
||||
EntityUid AttachedEntityUidOrInvalid { get => AttachedEntityUid ?? EntityUid.Invalid; }
|
||||
|
||||
/// <summary>
|
||||
/// Porting convenience for admin commands which use such logic as "at the player's feet", etc: the transform component of the attached entity.
|
||||
/// </summary>
|
||||
TransformComponent? AttachedEntityTransform { get => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(AttachedEntityUidOrInvalid); }
|
||||
TransformComponent? AttachedEntityTransform => IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(AttachedEntity ?? default);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Robust.Shared.Utility
|
||||
rootSizeF = new Vector2((float)(minLeafSizeF.X * multiplier), (float)(minLeafSizeF.Y * multiplier));
|
||||
var center = new Vector2i((int)(bounds.Left + bounds.Width / 2), (int)(bounds.Top + bounds.Height / 2));
|
||||
var rootOrigin = new Vector2i((int)(center.X - rootSizeF.X / 2), (int)(center.Y - rootSizeF.Y / 2));
|
||||
root = new QuadNode(Box2.FromDimensions((Vector2)rootOrigin, rootSizeF));
|
||||
root = new QuadNode(Box2.FromDimensions(rootOrigin, rootSizeF));
|
||||
}
|
||||
|
||||
while (!root.Bounds.Encloses(bounds))
|
||||
@@ -140,7 +140,7 @@ namespace Robust.Shared.Utility
|
||||
double newY = (rootDiRectangleFion == DiRectangleFion.NW || rootDiRectangleFion == DiRectangleFion.NE)
|
||||
? root.Bounds.Top
|
||||
: root.Bounds.Top - root.Bounds.Height;
|
||||
var newRootBounds = Box2.FromDimensions((float)newX, (float)newY, (float)root.Bounds.Width * 2f, (float)root.Bounds.Height * 2f);
|
||||
var newRootBounds = Box2.FromDimensions((float)newX, (float)newY, root.Bounds.Width * 2f, root.Bounds.Height * 2f);
|
||||
QuadNode newRoot = new QuadNode(newRootBounds);
|
||||
SetupChildNodes(newRoot);
|
||||
newRoot[rootDiRectangleFion] = root;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
// ReSharper disable AccessToStaticMemberViaDerivedType
|
||||
|
||||
namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
{
|
||||
var sim = RobustServerSimulation
|
||||
.NewSimulation()
|
||||
.RegisterPrototypes(protoMan => protoMan.LoadString(PROTOTYPES))
|
||||
.RegisterPrototypes(protoMan => protoMan.LoadString(Prototypes))
|
||||
.InitializeInstance();
|
||||
|
||||
// Adds the map with id 1, and spawns entity 1 as the map entity.
|
||||
@@ -26,7 +26,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
return sim;
|
||||
}
|
||||
|
||||
const string PROTOTYPES = @"
|
||||
const string Prototypes = @"
|
||||
- type: entity
|
||||
name: dummy
|
||||
id: dummy
|
||||
@@ -39,7 +39,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entity, "dummy");
|
||||
var container = entity.CreateContainer<Container>("dummy");
|
||||
|
||||
Assert.That(container.ID, Is.EqualTo("dummy"));
|
||||
Assert.That(container.Owner, Is.EqualTo(entity));
|
||||
@@ -47,10 +47,10 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var manager = IoCManager.Resolve<IEntityManager>().GetComponent<IContainerManager>(entity);
|
||||
|
||||
Assert.That(container.Manager, Is.EqualTo(manager));
|
||||
Assert.That(() => ContainerHelpers.CreateContainer<Container>(entity, "dummy"), Throws.ArgumentException);
|
||||
Assert.That(() => entity.CreateContainer<Container>("dummy"), Throws.ArgumentException);
|
||||
|
||||
Assert.That(manager.HasContainer("dummy2"), Is.False);
|
||||
var container2 = ContainerHelpers.CreateContainer<Container>(entity, "dummy2");
|
||||
var container2 = entity.CreateContainer<Container>("dummy2");
|
||||
|
||||
Assert.That(container2.Manager, Is.EqualTo(manager));
|
||||
Assert.That(container2.Owner, Is.EqualTo(entity));
|
||||
@@ -64,7 +64,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
Assert.That(manager.GetContainer("dummy2"), Is.EqualTo(container2));
|
||||
Assert.That(() => manager.GetContainer("dummy3"), Throws.TypeOf<KeyNotFoundException>());
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entity);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
|
||||
|
||||
Assert.That(manager.Deleted, Is.True);
|
||||
Assert.That(container.Deleted, Is.True);
|
||||
@@ -80,11 +80,11 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var inserted = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(inserted);
|
||||
|
||||
var container = ContainerHelpers.CreateContainer<Container>(owner, "dummy");
|
||||
var container = owner.CreateContainer<Container>("dummy");
|
||||
Assert.That(container.Insert(inserted), Is.True);
|
||||
Assert.That(transform.Parent!.Owner, Is.EqualTo(owner));
|
||||
|
||||
var container2 = ContainerHelpers.CreateContainer<Container>(inserted, "dummy");
|
||||
var container2 = inserted.CreateContainer<Container>("dummy");
|
||||
Assert.That(container2.Insert(owner), Is.False);
|
||||
|
||||
var success = container.Remove(inserted);
|
||||
@@ -94,7 +94,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
Assert.That(success, Is.False);
|
||||
|
||||
container.Insert(inserted);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) owner);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(owner);
|
||||
// Make sure inserted was detached.
|
||||
Assert.That(transform.Deleted, Is.True);
|
||||
}
|
||||
@@ -109,11 +109,11 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(inserted);
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
|
||||
var container = ContainerHelpers.CreateContainer<Container>(owner, "dummy");
|
||||
var container = owner.CreateContainer<Container>("dummy");
|
||||
Assert.That(container.Insert(inserted), Is.True);
|
||||
Assert.That(transform.Parent!.Owner, Is.EqualTo(owner));
|
||||
|
||||
var container2 = ContainerHelpers.CreateContainer<Container>(inserted, "dummy");
|
||||
var container2 = inserted.CreateContainer<Container>("dummy");
|
||||
Assert.That(container2.Insert(entity), Is.True);
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Parent!.Owner, Is.EqualTo(inserted));
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
Assert.That(container.Contains(entity), Is.True);
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Parent!.Owner, Is.EqualTo(owner));
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) owner);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(owner);
|
||||
Assert.That(transform.Deleted, Is.True);
|
||||
}
|
||||
|
||||
@@ -136,9 +136,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var entityThree = sim.SpawnEntity("dummy", coordinates);
|
||||
var entityItem = sim.SpawnEntity("dummy", coordinates);
|
||||
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entityOne, "dummy");
|
||||
var container2 = ContainerHelpers.CreateContainer<ContainerOnlyContainer>(entityTwo, "dummy");
|
||||
var container3 = ContainerHelpers.CreateContainer<Container>(entityThree, "dummy");
|
||||
var container = entityOne.CreateContainer<Container>("dummy");
|
||||
var container2 = entityTwo.CreateContainer<ContainerOnlyContainer>("dummy");
|
||||
var container3 = entityThree.CreateContainer<Container>("dummy");
|
||||
|
||||
Assert.That(container.Insert(entityTwo), Is.True);
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entityTwo).Parent!.Owner, Is.EqualTo(entityOne));
|
||||
@@ -153,7 +153,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
Assert.That(container.Contains(entityItem), Is.True);
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entityItem).Parent!.Owner, Is.EqualTo(entityOne));
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entityOne);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entityOne);
|
||||
Assert.That((!IoCManager.Resolve<IEntityManager>().EntityExists(entityTwo) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entityTwo).EntityLifeStage) >= EntityLifeStage.Deleted, Is.True);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entity, "dummy");
|
||||
var container = entity.CreateContainer<Container>("dummy");
|
||||
|
||||
Assert.That(container.Insert(entity), Is.False);
|
||||
Assert.That(container.CanInsert(entity), Is.False);
|
||||
@@ -174,9 +174,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var mapEnt = sim.Resolve<IEntityManager>().GetEntity(new EntityUid(1));
|
||||
var mapEnt = new EntityUid(1);
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entity, "dummy");
|
||||
var container = entity.CreateContainer<Container>("dummy");
|
||||
|
||||
Assert.That(container.Insert(mapEnt), Is.False);
|
||||
Assert.That(container.CanInsert(mapEnt), Is.False);
|
||||
@@ -187,13 +187,12 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var grid = sim.Resolve<IMapManager>().CreateGrid(new MapId(1));
|
||||
var gridEntity = sim.Resolve<IEntityManager>().GetEntity(grid.GridEntityId);
|
||||
var grid = sim.Resolve<IMapManager>().CreateGrid(new MapId(1)).GridEntityId;
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entity, "dummy");
|
||||
var container = entity.CreateContainer<Container>("dummy");
|
||||
|
||||
Assert.That(container.Insert(gridEntity), Is.False);
|
||||
Assert.That(container.CanInsert(gridEntity), Is.False);
|
||||
Assert.That(container.Insert(grid), Is.False);
|
||||
Assert.That(container.CanInsert(grid), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -202,7 +201,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var containerEntity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(containerEntity, "dummy");
|
||||
var container = containerEntity.CreateContainer<Container>("dummy");
|
||||
var insertEntity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
|
||||
var result = container.Insert(insertEntity);
|
||||
@@ -211,7 +210,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
Assert.That(container.ContainedEntities.Count, Is.EqualTo(1));
|
||||
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(containerEntity).ChildCount, Is.EqualTo(1));
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(containerEntity).ChildEntityUids.First(), Is.EqualTo(insertEntity));
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(containerEntity).ChildEntities.First(), Is.EqualTo(insertEntity));
|
||||
|
||||
result = insertEntity.TryGetContainerMan(out var resultContainerMan);
|
||||
Assert.That(result, Is.True);
|
||||
@@ -224,7 +223,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var containerEntity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(containerEntity, "dummy");
|
||||
var container = containerEntity.CreateContainer<Container>("dummy");
|
||||
var insertEntity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
|
||||
var result = container.Remove(insertEntity);
|
||||
@@ -238,9 +237,9 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var entity1 = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container1 = ContainerHelpers.CreateContainer<Container>(entity1, "dummy");
|
||||
var container1 = entity1.CreateContainer<Container>("dummy");
|
||||
var entity2 = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container2 = ContainerHelpers.CreateContainer<Container>(entity2, "dummy");
|
||||
var container2 = entity2.CreateContainer<Container>("dummy");
|
||||
var transferEntity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
container1.Insert(transferEntity);
|
||||
|
||||
@@ -257,7 +256,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
var sim = SimulationFactory();
|
||||
|
||||
var entity = sim.SpawnEntity("dummy", new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
var container = ContainerHelpers.CreateContainer<Container>(entity, "dummy");
|
||||
var container = entity.CreateContainer<Container>("dummy");
|
||||
var childEnt = sim.SpawnEntity(null, new EntityCoordinates(new EntityUid(1), (0, 0)));
|
||||
|
||||
container.OccludesLight = true;
|
||||
@@ -317,7 +316,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
|
||||
|
||||
foreach (var entity in _containerList)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) entity);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.GameObjects
|
||||
{
|
||||
public class ContainerTests : RobustIntegrationTest
|
||||
@@ -76,7 +65,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var item = entMan.SpawnEntity(null, mapPos);
|
||||
item.Name = "Item";
|
||||
itemUid = item.Uid;
|
||||
Assert.That(entMan.TryGetEntity(entityUid, out var entity));
|
||||
Assert.That(entMan.EntityExists(entityUid);
|
||||
var container = entity!.EnsureContainer<Container>("dummy");
|
||||
container.Insert(item);
|
||||
|
||||
@@ -91,7 +80,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetEntity(entityUid, out var entity)
|
||||
if (!entMan.EntityExists(entityUid)
|
||||
|| !entity.TryGetComponent<ContainerManagerComponent>(out var containerManagerComp))
|
||||
{
|
||||
Assert.Fail();
|
||||
@@ -122,7 +111,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetEntity(entityUid, out var entity)
|
||||
if (!entMan.EntityExists(entityUid)
|
||||
|| !entity.TryGetComponent<ContainerManagerComponent>(out var containerManagerComp))
|
||||
{
|
||||
Assert.Fail();
|
||||
@@ -202,7 +191,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
var item = entMan.SpawnEntity(null, mapPos);
|
||||
item.Name = "Item";
|
||||
itemUid = item.Uid;
|
||||
Assert.That(entMan.TryGetEntity(entityUid, out var entity));
|
||||
Assert.That(entMan.EntityExists(entityUid);
|
||||
var container = entity!.EnsureContainer<Container>("dummy");
|
||||
container.Insert(item);
|
||||
|
||||
@@ -217,7 +206,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetEntity(entityUid, out var entity)
|
||||
if (!entMan.EntityExists(entityUid)
|
||||
|| !entity.TryGetComponent<ContainerManagerComponent>(out var containerManagerComp))
|
||||
{
|
||||
Assert.Fail();
|
||||
@@ -239,7 +228,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
|
||||
// If possible it'd be best to only have the DeleteEntity, but right now
|
||||
// the entity deleted event is not played on the client if the entity does not exist on the client.
|
||||
if (entMan.TryGetEntity(itemUid, out var item)
|
||||
if (entMan.EntityExists(itemUid)
|
||||
&& ContainerHelpers.TryGetContainer(item, out var container))
|
||||
container.ForceRemove(item);
|
||||
entMan.DeleteEntity(itemUid);
|
||||
@@ -251,7 +240,7 @@ namespace Robust.UnitTesting.Shared.GameObjects
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetEntity(entityUid, out var entity)
|
||||
if (!entMan.EntityExists(entityUid)
|
||||
|| !entity.TryGetComponent<ContainerManagerComponent>(out var containerManagerComp))
|
||||
{
|
||||
Assert.Fail();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
@@ -7,9 +6,10 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
// ReSharper disable AccessToStaticMemberViaDerivedType
|
||||
|
||||
namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
{
|
||||
[TestFixture, Parallelizable]
|
||||
@@ -168,7 +168,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
Assert.That(grid.GetAnchoredEntities(tileIndices).First(), Is.EqualTo(ent1));
|
||||
Assert.That(grid.GetTileRef(tileIndices).Tile, Is.Not.EqualTo(Tile.Empty));
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<PhysicsComponent>(ent1), Is.False);
|
||||
var tempQualifier = entMan.GetEntity(grid.GridEntityId);
|
||||
var tempQualifier = grid.GridEntityId;
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().HasComponent<PhysicsComponent>(tempQualifier), Is.True);
|
||||
}
|
||||
|
||||
@@ -308,8 +308,8 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Anchored = true;
|
||||
|
||||
// Act
|
||||
var gridEnt = entMan.GetEntity(grid.GridEntityId); // we purposefully use the grid as container so parent stays the same, reparent will unanchor
|
||||
var containerMan = IoCManager.Resolve<IEntityManager>().AddComponent<ContainerManagerComponent>(gridEnt);
|
||||
// We purposefully use the grid as container so parent stays the same, reparent will unanchor
|
||||
var containerMan = IoCManager.Resolve<IEntityManager>().AddComponent<ContainerManagerComponent>(grid.GridEntityId);
|
||||
var container = containerMan.MakeContainer<Container>("TestContainer");
|
||||
container.Insert(ent1);
|
||||
|
||||
@@ -427,8 +427,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
|
||||
var gridEnt = entMan.GetEntity(grid.GridEntityId);
|
||||
var containerMan = IoCManager.Resolve<IEntityManager>().AddComponent<ContainerManagerComponent>(gridEnt);
|
||||
var containerMan = IoCManager.Resolve<IEntityManager>().AddComponent<ContainerManagerComponent>(grid.GridEntityId);
|
||||
var container = containerMan.MakeContainer<Container>("TestContainer");
|
||||
container.Insert(ent1);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Broadphase;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
|
||||
@@ -84,7 +83,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
|
||||
Assert.That(result, Is.True);
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) mapEntity);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(mapEntity);
|
||||
|
||||
result = coords.IsValid(entityManager);
|
||||
|
||||
@@ -163,8 +162,8 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, Vector2.Zero));
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(gridEnt, Vector2.Zero));
|
||||
|
||||
// Grids aren't parented to other grids.
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridEnt).Coordinates.GetGridId(entityManager), Is.EqualTo(GridId.Invalid));
|
||||
@@ -194,8 +193,8 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, Vector2.Zero));
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(gridEnt, Vector2.Zero));
|
||||
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(gridEnt).Coordinates.GetMapId(entityManager), Is.EqualTo(mapId));
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(newEnt).Coordinates.GetMapId(entityManager), Is.EqualTo(mapId));
|
||||
@@ -210,7 +209,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var mapEnt = mapManager.GetMapEntityId(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, Vector2.Zero));
|
||||
|
||||
Assert.That(entityManager.GetComponent<TransformComponent>(mapEnt).Coordinates.EntityId, Is.EqualTo(mapEnt));
|
||||
@@ -232,7 +231,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var mapEnt = mapManager.GetMapEntityId(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, Vector2.Zero));
|
||||
|
||||
var mapCoords = entityManager.GetComponent<TransformComponent>(mapEnt).Coordinates;
|
||||
@@ -256,14 +255,14 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
Assert.That(newEntCoords2.EntityId, Is.EqualTo(mapEnt));
|
||||
|
||||
// Deleting the parent should make TryGetParent return false.
|
||||
entityManager.DeleteEntity((EntityUid)mapEnt);
|
||||
entityManager.DeleteEntity(mapEnt);
|
||||
|
||||
// These shouldn't be valid anymore.
|
||||
Assert.That((!entityManager.EntityExists(newEnt) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(newEnt).EntityLifeStage) >= EntityLifeStage.Deleted, Is.True);
|
||||
Assert.That((!entityManager.EntityExists(gridEnt) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(gridEnt).EntityLifeStage) >= EntityLifeStage.Deleted, Is.True);
|
||||
Assert.That((!entityManager.EntityExists(newEnt) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(newEnt).EntityLifeStage), Is.GreaterThanOrEqualTo(EntityLifeStage.Deleted));
|
||||
Assert.That((!entityManager.EntityExists(gridEnt) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(gridEnt).EntityLifeStage), Is.GreaterThanOrEqualTo(EntityLifeStage.Deleted));
|
||||
|
||||
Assert.That((!entityManager.EntityExists(newEntCoords.EntityId) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(newEntCoords.EntityId).EntityLifeStage) >= EntityLifeStage.Deleted, Is.True);
|
||||
Assert.That((!entityManager.EntityExists(gridCoords.EntityId) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(gridCoords.EntityId).EntityLifeStage) >= EntityLifeStage.Deleted, Is.True);
|
||||
Assert.That((!entityManager.EntityExists(newEntCoords.EntityId) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(newEntCoords.EntityId).EntityLifeStage), Is.GreaterThanOrEqualTo(EntityLifeStage.Deleted));
|
||||
Assert.That((!entityManager.EntityExists(gridCoords.EntityId) ? EntityLifeStage.Deleted : entityManager.GetComponent<MetaDataComponent>(gridCoords.EntityId).EntityLifeStage), Is.GreaterThanOrEqualTo(EntityLifeStage.Deleted));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -282,7 +281,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, entPos));
|
||||
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(newEnt).Coordinates.ToMap(entityManager), Is.EqualTo(new MapCoordinates(entPos, mapId)));
|
||||
@@ -301,7 +300,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
var mapId = mapManager.CreateMap();
|
||||
var mapEnt = mapManager.GetMapEntityId(mapId);
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var gridEnt = entityManager.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var newEnt = entityManager.CreateEntityUninitialized("dummy", new EntityCoordinates(grid.GridEntityId, Vector2.Zero));
|
||||
|
||||
Assert.That(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(newEnt).Coordinates.WithEntityId(mapEnt).Position, Is.EqualTo(Vector2.Zero));
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
mapId = mapManager.CreateMap();
|
||||
gridId1 = mapManager.CreateGrid(mapId);
|
||||
gridId2 = mapManager.CreateGrid(mapId);
|
||||
gridEnt1 = entManager.GetEntity(gridId1.GridEntityId);
|
||||
gridEnt2 = entManager.GetEntity(gridId2.GridEntityId);
|
||||
gridEnt1 = gridId1.GridEntityId;
|
||||
gridEnt2 = gridId2.GridEntityId;
|
||||
physics1 = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(gridEnt1.Value);
|
||||
physics2 = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(gridEnt2.Value);
|
||||
// Can't collide static bodies and grids (at time of this writing) start as static
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -24,7 +23,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapManager.CreateGrid(mapId);
|
||||
var gridEntity = entManager.GetEntity(grid.GridEntityId);
|
||||
var gridEntity = grid.GridEntityId;
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -36,7 +35,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
grid.SetTile(new Vector2i(i, 0), Tile.Empty);
|
||||
}
|
||||
|
||||
Assert.That((!IoCManager.Resolve<IEntityManager>().EntityExists(gridEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(gridEntity).EntityLifeStage) >= EntityLifeStage.Deleted);
|
||||
Assert.That((!entManager.EntityExists(gridEntity) ? EntityLifeStage.Deleted : entManager.GetComponent<MetaDataComponent>(gridEntity).EntityLifeStage) >= EntityLifeStage.Deleted);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,8 +72,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
grid.SetTile(new Vector2i(i, 0), Tile.Empty);
|
||||
}
|
||||
|
||||
EntityUid tempQualifier = entManager.GetEntity(grid.GridEntityId);
|
||||
Assert.That(!((!IoCManager.Resolve<IEntityManager>().EntityExists(tempQualifier) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
Assert.That(!((!entManager.EntityExists(grid.GridEntityId) ? EntityLifeStage.Deleted : entManager.GetComponent<MetaDataComponent>(grid.GridEntityId).EntityLifeStage) >= EntityLifeStage.Deleted));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Physics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -31,7 +30,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
{
|
||||
var mapId = mapMan.CreateMap();
|
||||
var grid = mapMan.CreateGrid(mapId);
|
||||
var gridEnt = entMan.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var coordinates = new EntityCoordinates(gridEnt, new Vector2(10, 0));
|
||||
|
||||
// if no rotation and 0,0 position should just be the same coordinate.
|
||||
@@ -69,7 +68,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
{
|
||||
var mapId = mapMan.CreateMap();
|
||||
var grid = mapMan.CreateGrid(mapId);
|
||||
var gridEnt = entMan.GetEntity(grid.GridEntityId);
|
||||
var gridEnt = grid.GridEntityId;
|
||||
var gridInternal = (IMapGridInternal) grid;
|
||||
|
||||
/* Test for map chunk rotations */
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Robust.UnitTesting.Shared.Physics
|
||||
Assert.That(physics.Awake, Is.EqualTo(false));
|
||||
Assert.That(physics.CanCollide, Is.EqualTo(true));
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(physics.Owner).AttachParent(entManager.GetEntity(grid.GridEntityId));
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(physics.Owner).AttachParent(grid.GridEntityId);
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Robust.UnitTesting.Shared.Physics
|
||||
// Check that the newly parented entity's velocity is correct
|
||||
// it should retain its previous velocity despite new parent
|
||||
var grid2 = mapManager.CreateGrid(mapId);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(dummy).AttachParent(entityManager.GetEntity(grid2.GridEntityId));
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(dummy).AttachParent(grid2.GridEntityId);
|
||||
|
||||
Assert.That(body.MapLinearVelocity, Is.EqualTo(Vector2.One));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user