Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ END TEMPLATE-->
### Breaking changes

* Remove the duplicate serialization copy of components kept on ComponentRegistryEntry; now it only stores the deserialized component. To get the raw MappingDataNode for EntityPrototypes use PrototypeManager. This is expected to significantly reduce memory usage.
* SpawnNextToOrDrop methods have been changed to take `EntProtoId?, Entity<TransformComponent?>, Vector2 = default` instead of `string?, EntityUid, TransformComponent? null`. Because of this, some `Entity<T>`s will need to first be explicity converted into `EntityUid`s.

### New features

* Add a BoundUserInterfaceMessageReceivedEvent that will be raised whenever a BoundUserInterfaceMessage is received regardless of validation.
* SpawnNextToOrDrop methods can now offset their spawns by passing in a Vector2. This offset is always relative to the target.

### Bugfixes

* Windows will stay at relative position not absolute pixel position on window resize.
* SpawnNextToOrDrop no longer runs mapinit on entities in nullspace.

### Other

Expand Down
5 changes: 3 additions & 2 deletions Robust.Client/GameObjects/ClientEntityManager.Spawn.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
Expand Down Expand Up @@ -69,9 +70,9 @@ public override bool PredictedTrySpawnInContainer(
return true;
}

public override EntityUid PredictedSpawnNextToOrDrop(string? protoName, EntityUid target, TransformComponent? xform = null, ComponentRegistry? overrides = null)
public override EntityUid PredictedSpawnNextToOrDrop(EntProtoId? protoName, Entity<TransformComponent?> target, Vector2 offset = default, ComponentRegistry? overrides = null)
{
var ent = SpawnNextToOrDrop(protoName, target, xform, overrides);
var ent = SpawnNextToOrDrop(protoName, target, offset, overrides);
FlagPredicted(ent);
return ent;
}
Expand Down
28 changes: 15 additions & 13 deletions Robust.Shared/GameObjects/EntityManager.Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using Robust.Shared.Collections;
using Robust.Shared.Containers;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;

namespace Robust.Shared.GameObjects;

Expand Down Expand Up @@ -141,9 +141,9 @@ public bool TrySpawnNextTo(
if (!xform.ParentUid.IsValid())
return false;

if (!_containers.TryGetContainingContainer(target, out var container))
if (!_containers.TryGetContainingContainer((target, xform), out var container))
{
uid = SpawnNextToOrDrop(protoName, target, xform, overrides);
uid = SpawnNextToOrDrop(protoName, (target, xform), overrides: overrides);
return true;
}

Expand Down Expand Up @@ -183,15 +183,17 @@ public bool TrySpawnInContainer(
return false;
}

public EntityUid SpawnNextToOrDrop(string? protoName, EntityUid target, TransformComponent? xform = null, ComponentRegistry? overrides = null)
public EntityUid SpawnNextToOrDrop(EntProtoId? protoName, Entity<TransformComponent?> target, Vector2 offset = default, ComponentRegistry? overrides = null)
{
xform ??= TransformQuery.GetComponent(target);
if (!xform.ParentUid.IsValid())
return Spawn(protoName);

var doMapInit = _mapSystem.IsInitialized(xform.MapUid);
var uid = Spawn(protoName, overrides, doMapInit);
_xforms.DropNextTo(uid, target);
if (!TransformQuery.Resolve(target, ref target.Comp) ||
!target.Comp.ParentUid.IsValid())
return Spawn(protoName, overrides);

var uid = CreateEntityUninitialized(protoName, out var meta, overrides);
InitializeAndStartEntity((uid, meta), false);
_xforms.DropNextTo(uid, target, offset);
Comment on lines +192 to +194

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to initialize the entity at its target spot as it will make the spawn 2x faster by skipping all of the transform events for a 2nd time.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can end up raising container events on it before it's initialised though, an issue that was first raised in LegacyRT#6192(Comment).

if (_mapSystem.IsInitialized(target.Comp.MapUid))
RunMapInit(uid, meta);
return uid;
}

Expand Down Expand Up @@ -275,9 +277,9 @@ public virtual bool PredictedTrySpawnInContainer(
return TrySpawnInContainer(protoName, containerUid, containerId, out uid, containerComp, overrides);
}

public virtual EntityUid PredictedSpawnNextToOrDrop(string? protoName, EntityUid target, TransformComponent? xform = null, ComponentRegistry? overrides = null)
public virtual EntityUid PredictedSpawnNextToOrDrop(EntProtoId? protoName, Entity<TransformComponent?> target, Vector2 offset = default, ComponentRegistry? overrides = null)
{
return SpawnNextToOrDrop(protoName, target, xform, overrides);
return SpawnNextToOrDrop(protoName, target, offset, overrides);
}

public virtual EntityUid PredictedSpawnInContainerOrDrop(
Expand Down
17 changes: 9 additions & 8 deletions Robust.Shared/GameObjects/EntitySystem.Proxy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Robust.Shared.Containers;
Expand Down Expand Up @@ -1013,12 +1014,12 @@ protected bool TrySpawnNextTo(
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ProxyFor(typeof(EntityManager))]
protected EntityUid SpawnNextToOrDrop(
string? protoName,
EntityUid target,
TransformComponent? xform = null,
EntProtoId? protoName,
Entity<TransformComponent?> target,
Vector2 offset = default,
ComponentRegistry? overrides = null)
{
return EntityManager.SpawnNextToOrDrop(protoName, target, xform, overrides);
return EntityManager.SpawnNextToOrDrop(protoName, target, offset, overrides);
}

/// <inheritdoc cref="IEntityManager.SpawnInContainerOrDrop" />
Expand Down Expand Up @@ -1088,12 +1089,12 @@ protected bool PredictedTrySpawnNextTo(
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ProxyFor(typeof(EntityManager))]
protected EntityUid PredictedSpawnNextToOrDrop(
string? protoName,
EntityUid target,
TransformComponent? xform = null,
EntProtoId? protoName,
Entity<TransformComponent?> target,
Vector2 offset = default,
ComponentRegistry? overrides = null)
{
return EntityManager.PredictedSpawnNextToOrDrop(protoName, target, xform, overrides);
return EntityManager.PredictedSpawnNextToOrDrop(protoName, target, offset, overrides);
}

/// <inheritdoc cref="IEntityManager.SpawnInContainerOrDrop" />
Expand Down
8 changes: 4 additions & 4 deletions Robust.Shared/GameObjects/IEntityManager.Spawn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.Collections;
using System.Numerics;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Maths;
Expand Down Expand Up @@ -100,8 +100,8 @@ bool TrySpawnNextTo(
/// instead attempt to spawn the entity next to the target's parent.
/// </summary>
EntityUid SpawnNextToOrDrop(
string? protoName,
EntityUid target,
TransformComponent? xform = null,
EntProtoId? protoName,
Entity<TransformComponent?> target,
Vector2 offset = default,
ComponentRegistry? overrides = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ private void OnGridAdd(EntityUid uid, TransformComponent component, GridAddEvent
/// this will attempt to insert that entity into the same container. Otherwise it will attach the entity to the
/// grid or map at the same world-position as the target entity.
/// </summary>
public void DropNextTo(Entity<TransformComponent?> entity, Entity<TransformComponent?> target)
public void DropNextTo(Entity<TransformComponent?> entity, Entity<TransformComponent?> target, Vector2 offset = default)
{
var xform = entity.Comp;
if (!XformQuery.Resolve(entity, ref xform))
Expand All @@ -1647,7 +1647,7 @@ public void DropNextTo(Entity<TransformComponent?> entity, Entity<TransformCompo
return;
}

var coords = targetXform.Coordinates;
var coords = new EntityCoordinates(target, offset);

// recursively check for containers.
var targetUid = target.Owner;
Expand Down