Skip to content
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
6 changes: 3 additions & 3 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ END TEMPLATE-->

### Breaking changes

*None yet*
- 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

*None yet*
- SpawnNextToOrDrop methods can now offset their spawns by passing in a Vector2. This offset is always relative to the target.

### Bugfixes

*None yet*
- 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);
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 @@ -969,12 +970,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 @@ -1044,12 +1045,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 @@ -861,7 +861,7 @@
}
else
{
xform.Anchored = newState.Anchored;

Check warning on line 864 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Windows)

'TransformComponent.Anchored.set' is obsolete: 'Use the SharedTransformSystem.AnchorEntity/Unanchor methods instead.'

Check warning on line 864 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (MacOS)

'TransformComponent.Anchored.set' is obsolete: 'Use the SharedTransformSystem.AnchorEntity/Unanchor methods instead.'

Check warning on line 864 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Linux)

'TransformComponent.Anchored.set' is obsolete: 'Use the SharedTransformSystem.AnchorEntity/Unanchor methods instead.'
}

if (oldAnchored != newState.Anchored && xform.Initialized)
Expand Down Expand Up @@ -1193,7 +1193,7 @@
{
var current = GetWorldRotation(component);
var diff = angle - current;
SetLocalRotation(component, component.LocalRotation + diff);

Check warning on line 1196 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Windows)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'

Check warning on line 1196 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (MacOS)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'

Check warning on line 1196 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Linux)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -1207,7 +1207,7 @@
{
var current = GetWorldRotation(component, xformQuery);
var diff = angle - current;
SetLocalRotation(component, component.LocalRotation + diff);

Check warning on line 1210 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Windows)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'

Check warning on line 1210 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (MacOS)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'

Check warning on line 1210 in Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs

View workflow job for this annotation

GitHub Actions / build (Linux)

'SharedTransformSystem.SetLocalRotation(TransformComponent, Angle)' is obsolete: 'use override with EntityUid'
}

#endregion
Expand Down Expand Up @@ -1634,7 +1634,7 @@
/// 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 @@
return;
}

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

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