GridCoordinates API changes.
This commit is contained in:
@@ -109,9 +109,8 @@ namespace Content.Client.State
|
||||
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
|
||||
{
|
||||
// Find all the entities intersecting our click
|
||||
var worldCoords = coordinates.ToWorld(_mapManager);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(_mapManager.GetGrid(coordinates.GridID).ParentMapId,
|
||||
worldCoords.Position);
|
||||
var mapCoords = coordinates.ToMap(_mapManager);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(mapCoords.MapId, mapCoords.Position);
|
||||
|
||||
// Check the entities against whether or not we can click them
|
||||
var foundEntities = new List<(IEntity clicked, int drawDepth)>();
|
||||
|
||||
@@ -119,8 +119,6 @@ namespace Content.Server.Explosions
|
||||
// Knock back cameras of all players in the area.
|
||||
|
||||
var playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
//var selfPos = Owner.Transform.WorldPosition; //vec2
|
||||
var selfPos = coords.ToWorld(mapManager).Position;
|
||||
foreach (var player in playerManager.GetAllPlayers())
|
||||
{
|
||||
if (player.AttachedEntity == null
|
||||
@@ -131,7 +129,7 @@ namespace Content.Server.Explosions
|
||||
}
|
||||
|
||||
var playerPos = player.AttachedEntity.Transform.WorldPosition;
|
||||
var delta = selfPos - playerPos;
|
||||
var delta = coords.ToMapPos(mapManager) - playerPos;
|
||||
var distance = delta.LengthSquared;
|
||||
|
||||
var effect = 1 / (1 + 0.2f * distance);
|
||||
|
||||
@@ -86,8 +86,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
{
|
||||
if (_teleporterType == TeleporterType.Directed)
|
||||
{
|
||||
var userTarget = eventArgs.ClickLocation.ToWorld(_mapManager);
|
||||
TryDirectedTeleport(eventArgs.User, userTarget);
|
||||
TryDirectedTeleport(eventArgs.User, eventArgs.ClickLocation.ToMap(_mapManager));
|
||||
}
|
||||
|
||||
if (_teleporterType == TeleporterType.Random)
|
||||
@@ -96,10 +95,10 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
}
|
||||
}
|
||||
|
||||
public void TryDirectedTeleport(IEntity user, GridCoordinates grid)
|
||||
public void TryDirectedTeleport(IEntity user, MapCoordinates mapCoords)
|
||||
{
|
||||
// Checks
|
||||
if (user.Transform.GridPosition.Distance(_mapManager, grid) > _range)
|
||||
if ((user.Transform.WorldPosition - mapCoords.Position).LengthSquared > (_range * _range))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -110,7 +109,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
}
|
||||
if (_avoidCollidable)
|
||||
{
|
||||
foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(grid))
|
||||
foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(mapCoords))
|
||||
{
|
||||
// Added this component to avoid stacking portals and causing shenanigans
|
||||
// TODO: Doesn't do a great job of stopping stacking portals for directed
|
||||
@@ -132,7 +131,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
return;
|
||||
}
|
||||
|
||||
Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, new Vector2(grid.X, grid.Y)));
|
||||
Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, mapCoords.Position));
|
||||
StartCooldown();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GridID, out var grid))
|
||||
return;
|
||||
|
||||
var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation.ToWorld(_mapManager), SnapGridOffset.Center);
|
||||
var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center);
|
||||
var snapCell = grid.GetSnapGridCell(snapPos, SnapGridOffset.Center);
|
||||
|
||||
if(grid.GetTileRef(snapPos).Tile.IsEmpty)
|
||||
|
||||
@@ -83,8 +83,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
return;
|
||||
}
|
||||
var location = eventArgs.User.Transform.GridPosition;
|
||||
var angle = new Angle(eventArgs.ClickLocation.ToWorld(_mapManager).Position -
|
||||
location.ToWorld(_mapManager).Position);
|
||||
var angle = new Angle(eventArgs.ClickLocation.ToMapPos(_mapManager) - location.ToMapPos(_mapManager));
|
||||
|
||||
// This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes.
|
||||
var entities = ArcRayCast(eventArgs.User.Transform.WorldPosition, angle, eventArgs.User);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.Components.Timing;
|
||||
@@ -408,7 +408,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
// Check if ClickLocation is in object bounds here, if not lets log as warning and see why
|
||||
if (attacked.TryGetComponent(out ICollidableComponent collideComp))
|
||||
{
|
||||
if (!collideComp.WorldAABB.Contains(coordinates.ToWorld(_mapManager).Position))
|
||||
if (!collideComp.WorldAABB.Contains(coordinates.ToMapPos(_mapManager)))
|
||||
{
|
||||
Logger.WarningS("system.interaction",
|
||||
$"Player {player.Name} clicked {attacked.Name} outside of its bounding box component somehow");
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
projComp.IgnoreEntity(plyEnt);
|
||||
|
||||
var transform = plyEnt.Transform;
|
||||
var dirVec = (coords.ToWorld(_mapManager).Position - transform.WorldPosition).Normalized;
|
||||
var dirVec = (coords.ToMapPos(_mapManager) - transform.WorldPosition).Normalized;
|
||||
|
||||
if (!throwEnt.TryGetComponent(out PhysicsComponent physComp))
|
||||
physComp = throwEnt.AddComponent<PhysicsComponent>();
|
||||
|
||||
Submodule RobustToolbox updated: 9f956cef95...4eb29a9e80
Reference in New Issue
Block a user