Fix inflatable position (#3788)

This commit is contained in:
ShadowCommander
2021-04-01 14:34:35 -07:00
committed by GitHub
parent b5b90d353f
commit faae4c2456
2 changed files with 19 additions and 4 deletions

View File

@@ -36,12 +36,14 @@ namespace Content.Server.GameObjects.EntitySystems
{
if (string.IsNullOrEmpty(component.Prototype))
return;
if (!args.ClickLocation.TryGetTileRef(out var tileRef, EntityManager, _mapManager))
if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridId(EntityManager), out var grid))
return;
if (!grid.TryGetTileRef(args.ClickLocation, out var tileRef))
return;
bool IsTileClear()
{
return tileRef.Value.Tile.IsEmpty == false && args.User.InRangeUnobstructed(args.ClickLocation, popup: true);
return tileRef.Tile.IsEmpty == false && args.User.InRangeUnobstructed(args.ClickLocation, popup: true);
}
if (!IsTileClear())
@@ -68,7 +70,7 @@ namespace Content.Server.GameObjects.EntitySystems
if (component.RemoveOnInteract && component.Owner.TryGetComponent(out stack) && !stack.Use(1))
return;
EntityManager.SpawnEntity(component.Prototype, tileRef.Value.GridPosition(_mapManager));
EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid, SnapGridOffset.Center));
if (component.RemoveOnInteract && stack == null && !component.Owner.Deleted)
component.Owner.Delete();