SnapGridComponent Removal (#3884)
* Removed SnapGridOffset, there is only center now. * SnapGridComponent methods are now static. * Removed SnapGridComponent.OnPositionChanged. * Refactored static functions off SnapGridComponent to MapGrid. Refactored away usages of SnapGridComponent.Position. * Added Transform.Anchored for checking if an entity is a tile entity. More refactoring for static MapGrid functions. * Static snapgrid methods on MapGrid are no longer static. * Add setter to ITransformComponent.Anchored. Removed direct references to SnapGridComponent from content. * Grid functions now deal with EntityUids instead of SnapGridComponents. Began renaming public API functions from SnapGrid to Anchor. * Remove the SnapGridComponent 'Offset' field from all yaml files. This was removed in code previously, so the yaml linter was upset. * Update engine submodule to v0.4.46.
This commit is contained in:
@@ -62,7 +62,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
|
||||
// Required for airtight components.
|
||||
EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
|
||||
SubscribeLocalEvent<RotateEvent>(RotateEvent);
|
||||
SubscribeLocalEvent<AirtightComponent, SnapGridPositionChangedEvent>(HandleSnapGridMove);
|
||||
|
||||
_cfg.OnValueChanged(CCVars.SpaceWind, OnSpaceWindChanged, true);
|
||||
_cfg.OnValueChanged(CCVars.MonstermosEqualization, OnMonstermosEqualizationChanged, true);
|
||||
@@ -72,6 +73,11 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
_cfg.OnValueChanged(CCVars.ExcitedGroupsSpaceIsAllConsuming, OnExcitedGroupsSpaceIsAllConsumingChanged, true);
|
||||
}
|
||||
|
||||
private static void HandleSnapGridMove(EntityUid uid, AirtightComponent component, SnapGridPositionChangedEvent args)
|
||||
{
|
||||
component.OnTransformMove();
|
||||
}
|
||||
|
||||
public bool SpaceWind { get; private set; }
|
||||
public bool MonstermosEqualization { get; private set; }
|
||||
public bool Superconduction { get; private set; }
|
||||
@@ -115,7 +121,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
|
||||
_mapManager.MapCreated -= OnMapCreated;
|
||||
|
||||
EntityManager.EventBus.UnsubscribeEvent<RotateEvent>(EventSource.Local, this);
|
||||
UnsubscribeLocalEvent<RotateEvent>();
|
||||
UnsubscribeLocalEvent<AirtightComponent, SnapGridPositionChangedEvent>(HandleSnapGridMove);
|
||||
}
|
||||
|
||||
private void RotateEvent(RotateEvent ev)
|
||||
|
||||
@@ -3,34 +3,41 @@ using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class PuddleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
mapManager.TileChanged += HandleTileChanged;
|
||||
_mapManager.TileChanged += HandleTileChanged;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
mapManager.TileChanged -= HandleTileChanged;
|
||||
_mapManager.TileChanged -= HandleTileChanged;
|
||||
}
|
||||
|
||||
//TODO: Replace all this with an Unanchored event that deletes the puddle
|
||||
private void HandleTileChanged(object? sender, TileChangedEventArgs eventArgs)
|
||||
{
|
||||
// If this gets hammered you could probably queue up all the tile changes every tick but I doubt that would ever happen.
|
||||
foreach (var (puddle, snapGrid) in ComponentManager.EntityQuery<PuddleComponent, SnapGridComponent>(true))
|
||||
foreach (var puddle in ComponentManager.EntityQuery<PuddleComponent>(true))
|
||||
{
|
||||
// If the tile becomes space then delete it (potentially change by design)
|
||||
var puddleTransform = puddle.Owner.Transform;
|
||||
if(!puddleTransform.Anchored)
|
||||
continue;
|
||||
|
||||
var grid = _mapManager.GetGrid(puddleTransform.GridID);
|
||||
if (eventArgs.NewTile.GridIndex == puddle.Owner.Transform.GridID &&
|
||||
snapGrid.Position == eventArgs.NewTile.GridIndices &&
|
||||
grid.TileIndicesFor(puddleTransform.Coordinates) == eventArgs.NewTile.GridIndices &&
|
||||
eventArgs.NewTile.Tile.IsEmpty)
|
||||
{
|
||||
puddle.Owner.Delete();
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Utility;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -70,12 +69,10 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
if (component.RemoveOnInteract && component.Owner.TryGetComponent(out stack) && !stack.Use(1))
|
||||
return;
|
||||
|
||||
EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid, SnapGridOffset.Center));
|
||||
EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid));
|
||||
|
||||
if (component.RemoveOnInteract && stack == null && !component.Owner.Deleted)
|
||||
component.Owner.Delete();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user