Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove startup traversal entirely #5365

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions Robust.Shared/GameObjects/EntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ public virtual EntityUid CreateEntityUninitialized(string? prototypeName, MapCoo
throw new ArgumentException($"Attempted to spawn entity on an invalid map. Coordinates: {coordinates}");

EntityCoordinates coords;
if (transform.Anchored && _mapManager.TryFindGridAt(coordinates, out var gridUid, out var grid))
if (_mapManager.TryFindGridAt(coordinates, out var gridUid, out var grid))
{
coords = new EntityCoordinates(gridUid, _mapSystem.WorldToLocal(gridUid, grid, coordinates.Position));
_xforms.SetCoordinates(newEntity, transform, coords, rotation, unanchor: false);
_xforms.SetCoordinates(newEntity, transform, coords, rotation, unanchor: !transform.Anchored);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ internal sealed class SharedGridTraversalSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TransformStartupEvent>(OnStartup);
}

private void OnStartup(ref TransformStartupEvent ev)
{
CheckTraverse(ev.Entity);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to be a massively breaking change and the corresponding spawn code needs to be adjusted to handle this.

Copy link
Author

Choose a reason for hiding this comment

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

so if im understanding what each usecase for the different spawn functions are, here's how this should look like:

(1) base Spawn: spawn in nullspace
(2) Spawn with MapCoordinates overload: spawn on map, reparent to grid if overlap
(3) SpawnAttachedTo: spawn with parent and position provided by EntitiyCoordinates
(4) SpawnAtPosition: same as (2) but transforms provided EntityCoordinates to MapCoordinates first
(5) TrySpawnInContainer, SpawnInContainerOrDrop, TrySpawnNextTo, SpawnNextToOrDrop: as their names imply

ignoring (1) since trivial case, and (5) since those functions are built up from (1..4). (2) and (4) just need to make sure they check for overlapping grids and reparent if one is found. is it fine to do have it implemented with the changes i've made to the MapCoordinates overload of CreateEntityUninitialized? (3) uses the EntityCoordinates overload of CreateEntityUninitialized which doesn't check for grids so no need to worry about traversing in that case

Copy link
Author

Choose a reason for hiding this comment

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

but now im confused because this is just making traversal implicitly built into certain spawn functions rather than relying on the system for it; is that what we want?


internal void CheckTraverse(Entity<TransformComponent> entity)
Expand Down
Loading