Revert some grid/map related changes (#4809)

This commit is contained in:
Leon Friedrich
2024-01-04 21:48:43 -05:00
committed by GitHub
parent 31e2a3efe4
commit 1758fced75
8 changed files with 26 additions and 11 deletions

View File

@@ -1,9 +1,12 @@
using Robust.Client.Graphics;
using Robust.Client.Map;
using Robust.Client.Physics;
using Robust.Client.ResourceManagement;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Dynamics;
namespace Robust.Client.GameObjects;
@@ -24,4 +27,9 @@ public sealed class MapSystem : SharedMapSystem
base.Shutdown();
_overlayManager.RemoveOverlay<TileEdgeOverlay>();
}
protected override void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args)
{
EnsureComp<PhysicsMapComponent>(uid);
}
}

View File

@@ -31,6 +31,11 @@ namespace Robust.Server.GameObjects
_cfg.OnValueChanged(CVars.GameDeleteEmptyGrids, SetGridDeletion, true);
}
protected override void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args)
{
EnsureComp<PhysicsMapComponent>(uid);
}
private void SetGridDeletion(bool value)
{
_deleteEmptyGrids = value;

View File

@@ -117,6 +117,7 @@ public sealed partial class EntityLookupSystem : EntitySystem
SubscribeLocalEvent<BroadphaseComponent, EntityTerminatingEvent>(OnBroadphaseTerminating);
SubscribeLocalEvent<BroadphaseComponent, ComponentAdd>(OnBroadphaseAdd);
SubscribeLocalEvent<GridAddEvent>(OnGridAdd);
SubscribeLocalEvent<MapChangedEvent>(OnMapChange);
_transform.OnGlobalMoveEvent += OnMove;
@@ -195,6 +196,12 @@ public sealed partial class EntityLookupSystem : EntitySystem
}
}
private void OnGridAdd(GridAddEvent ev)
{
// Must be done before initialization as that's when broadphase data starts getting set.
EnsureComp<BroadphaseComponent>(ev.EntityUid);
}
private void OnBroadphaseAdd(EntityUid uid, BroadphaseComponent component, ComponentAdd args)
{
component.StaticSundriesTree = new DynamicTree<EntityUid>(

View File

@@ -10,6 +10,7 @@ public abstract partial class SharedMapSystem
{
private void InitializeMap()
{
SubscribeLocalEvent<MapComponent, ComponentAdd>(OnMapAdd);
SubscribeLocalEvent<MapComponent, ComponentInit>(OnMapInit);
SubscribeLocalEvent<MapComponent, ComponentShutdown>(OnMapRemoved);
SubscribeLocalEvent<MapComponent, ComponentHandleState>(OnMapHandleState);
@@ -42,6 +43,8 @@ public abstract partial class SharedMapSystem
args.State = new MapComponentState(component.MapId, component.LightingEnabled, component.MapPaused);
}
protected abstract void OnMapAdd(EntityUid uid, MapComponent component, ComponentAdd args);
private void OnMapInit(EntityUid uid, MapComponent component, ComponentInit args)
{
EnsureComp<GridTreeComponent>(uid);

View File

@@ -4,8 +4,6 @@ using System.Diagnostics.CodeAnalysis;
using Robust.Shared.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
// All the obsolete warnings about GridId are probably useless here.
@@ -161,9 +159,6 @@ internal partial class MapManager
var grid = EntityManager.AddComponent<MapGridComponent>(gridEnt);
grid.ChunkSize = chunkSize;
EntityManager.AddComponent<PhysicsComponent>(gridEnt);
EntityManager.AddComponent<FixturesComponent>(gridEnt);
EntityManager.AddComponent<BroadphaseComponent>(gridEnt);
_sawmill.Debug($"Binding new grid {gridEnt}");

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Utility;
namespace Robust.Shared.Map;
@@ -234,7 +233,6 @@ internal partial class MapManager
var mapComp = EntityManager.AddComponent<MapComponent>(newEnt);
mapComp.MapId = actualId;
EntityManager.AddComponent<PhysicsMapComponent>(newEnt);
var meta = EntityManager.GetComponent<MetaDataComponent>(newEnt);
EntityManager.System<MetaDataSystem>().SetEntityName(newEnt, $"map {actualId}", meta);
EntityManager.Dirty(newEnt, mapComp, meta);

View File

@@ -1,5 +1,4 @@
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.BroadPhase;
namespace Robust.Shared.Physics
@@ -7,7 +6,7 @@ namespace Robust.Shared.Physics
/// <summary>
/// Stores the broadphase structure for the relevant grid / map.
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent]
public sealed partial class BroadphaseComponent : Component
{
/// <summary>

View File

@@ -81,7 +81,7 @@ namespace Robust.Shared.Physics.Systems
PhysMapQuery = GetEntityQuery<PhysicsMapComponent>();
MapQuery = GetEntityQuery<MapComponent>();
SubscribeLocalEvent<GridInitializeEvent>(OnGridAdd);
SubscribeLocalEvent<GridAddEvent>(OnGridAdd);
SubscribeLocalEvent<CollisionChangeEvent>(OnCollisionChange);
SubscribeLocalEvent<PhysicsComponent, EntGotRemovedFromContainerMessage>(HandleContainerRemoved);
SubscribeLocalEvent<EntParentChangedMessage>(OnParentChange);
@@ -231,7 +231,7 @@ namespace Robust.Shared.Physics.Systems
}
}
private void OnGridAdd(GridInitializeEvent ev)
private void OnGridAdd(GridAddEvent ev)
{
var guid = ev.EntityUid;