* Resolve `'TransformComponent.MapPosition' is obsolete: 'Use TransformSystem.GetMapCoordinates'` in content
* build?
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
+using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
-
+ private readonly SharedTransformSystem _transform = default!;
private readonly SpawnExplosionEui _eui;
private List<MapId> _mapData = new();
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
+ _transform = _entMan.System<TransformSystem>();
_eui = eui;
ExplosionOption.OnItemSelected += ExplosionSelected;
_pausePreview = true;
MapOptions.Select(_mapData.IndexOf(transform.MapID));
- (MapX.Value, MapY.Value) = transform.MapPosition.Position;
+ (MapX.Value, MapY.Value) = _transform.GetMapCoordinates(_playerManager.LocalEntity!.Value, xform: transform).Position;
_pausePreview = false;
UpdatePreview();
using Content.Client.GPS.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
+using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
private readonly RichTextLabel _label;
private float _updateDif;
private readonly IEntityManager _entMan;
+ private readonly SharedTransformSystem _transform;
public HandheldGpsStatusControl(Entity<HandheldGPSComponent> parent)
{
_parent = parent;
_entMan = IoCManager.Resolve<IEntityManager>();
+ _transform = _entMan.System<TransformSystem>();
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
UpdateGpsDetails();
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
- var pos = transComp.MapPosition;
+ var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int) pos.X;
var y = (int) pos.Y;
posText = $"({x}, {y})";
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
+using Robust.Client.Replays.Loading;
using Robust.Shared.Map;
using Robust.Shared.Timing;
if (mapPos.MapId == MapId.Nullspace)
return;
- var angle = (mapPos.Position - xform.MapPosition.Position).ToWorldAngle();
+ var angle = (mapPos.Position - _transform.GetMapCoordinates(player.Value, xform: xform).Position).ToWorldAngle();
var curRot = _transform.GetWorldRotation(xform);
using System.Numerics;
using Content.Shared.Radiation.Components;
+using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Graphics;
using Robust.Shared.Map;
+using Robust.Shared.Physics;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
+ private TransformSystem? _transform;
private const float MaxDist = 15.0f;
//Queries all pulses on the map and either adds or removes them from the list of rendered pulses based on whether they should be drawn (in range? on the same z-level/map? pulse entity still exists?)
private void RadiationQuery(IEye? currentEye)
{
+ _transform ??= _entityManager.System<TransformSystem>();
+
if (currentEye == null)
{
_pulses.Clear();
(
_baseShader.Duplicate(),
new RadiationShaderInstance(
- _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition,
+ _transform.GetMapCoordinates(pulseEntity),
pulse.VisualRange,
pulse.StartTime,
pulse.VisualDuration
_entityManager.TryGetComponent(pulseEntity, out RadiationPulseComponent? pulse))
{
var shaderInstance = _pulses[pulseEntity];
- shaderInstance.instance.CurrentMapCoords = _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition;
+ shaderInstance.instance.CurrentMapCoords = _transform.GetMapCoordinates(pulseEntity);
shaderInstance.instance.Range = pulse.VisualRange;
} else {
_pulses[pulseEntity].shd.Dispose();
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.State;
+using Robust.Shared.Physics;
namespace Content.Client.Sprite;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly HashSet<FadingSpriteComponent> _comps = new();
spriteQuery.TryGetComponent(player, out var playerSprite))
{
var fadeQuery = GetEntityQuery<SpriteFadeComponent>();
- var mapPos = playerXform.MapPosition;
+ var mapPos = _transform.GetMapCoordinates(_playerManager.LocalEntity!.Value, xform: playerXform);
// Also want to handle large entities even if they may not be clickable.
foreach (var ent in state.GetClickableEntities(mapPos))
// Set the dragging player on the component to noone
if (broadcast && _draggedEntity != null && EntityManager.HasComponent<TabletopDraggableComponent>(_draggedEntity.Value))
{
- RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transform(_draggedEntity.Value).MapPosition, GetNetEntity(_table!.Value)));
+ RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transforms.GetMapCoordinates(_draggedEntity.Value), GetNetEntity(_table!.Value)));
RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(GetNetEntity(_draggedEntity.Value), false));
}
if (coordinates == MapCoordinates.Nullspace) return MapCoordinates.Nullspace;
var eye = viewport.Eye;
- if (eye == null) return MapCoordinates.Nullspace;
+ if (eye == null)
+ return MapCoordinates.Nullspace;
var size = (Vector2) viewport.ViewportSize / EyeManager.PixelsPerMeter; // Convert to tiles instead of pixels
var eyePosition = eye.Position.Position;
[UISystemDependency] private readonly GhostSystem? _ghost = default;
[UISystemDependency] private readonly TypingIndicatorSystem? _typingIndicator = default;
[UISystemDependency] private readonly ChatSystem? _chatSys = default;
+ [UISystemDependency] private readonly TransformSystem? _transform = default;
[ValidatePrototypeId<ColorPalettePrototype>]
private const string ChatNamePalette = "ChatNames";
var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data)
=> uid == data.compOwner || uid == data.attachedEntity;
var playerPos = player != null
- ? EntityManager.GetComponent<TransformComponent>(player.Value).MapPosition
+ ? _transform?.GetMapCoordinates(player.Value) ?? MapCoordinates.Nullspace
: MapCoordinates.Nullspace;
var occluded = player != null && _examine.IsOccluded(player.Value);
continue;
}
- var otherPos = EntityManager.GetComponent<TransformComponent>(ent).MapPosition;
+ var otherPos = _transform?.GetMapCoordinates(ent) ?? MapCoordinates.Nullspace;
if (occluded && !_examine.InRangeUnOccluded(
playerPos,
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
if ((visibility & MenuVisibility.NoFov) == 0)
{
var xformQuery = GetEntityQuery<TransformComponent>();
- var playerPos = xformQuery.GetComponent(player.Value).MapPosition;
+ var playerPos = _transform.GetMapCoordinates(player.Value, xform: xformQuery.GetComponent(player.Value));
for (var i = entities.Count - 1; i >= 0; i--)
{
if (!_examine.InRangeUnOccluded(
playerPos,
- xformQuery.GetComponent(entity).MapPosition,
+ _transform.GetMapCoordinates(entity, xform: xformQuery.GetComponent(entity)),
ExamineSystemShared.ExamineRange,
null))
{
private readonly IPlayerManager _playerManager;
private readonly MeleeWeaponSystem _melee;
private readonly SharedCombatModeSystem _combatMode;
+ private readonly SharedTransformSystem _transform = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
- public MeleeArcOverlay(IEntityManager entManager, IEyeManager eyeManager, IInputManager inputManager, IPlayerManager playerManager, MeleeWeaponSystem melee, SharedCombatModeSystem combatMode)
+ public MeleeArcOverlay(IEntityManager entManager, IEyeManager eyeManager, IInputManager inputManager, IPlayerManager playerManager, MeleeWeaponSystem melee, SharedCombatModeSystem combatMode, SharedTransformSystem transform)
{
_entManager = entManager;
_eyeManager = eyeManager;
_playerManager = playerManager;
_melee = melee;
_combatMode = combatMode;
+ _transform = transform;
}
protected override void Draw(in OverlayDrawArgs args)
if (mapPos.MapId != args.MapId)
return;
- var playerPos = xform.MapPosition;
+ var playerPos = _transform.GetMapCoordinates(player.Value, xform: xform);
if (mapPos.MapId != playerPos.MapId)
return;
collection.Resolve<IInputManager>(),
collection.Resolve<IPlayerManager>(),
sysManager.GetEntitySystem<MeleeWeaponSystem>(),
- sysManager.GetEntitySystem<SharedCombatModeSystem>()));
+ sysManager.GetEntitySystem<SharedCombatModeSystem>(),
+ sysManager.GetEntitySystem<SharedTransformSystem>()));
}
}
// Light attack
if (useDown == BoundKeyState.Down)
{
- var attackerPos = Transform(entity).MapPosition;
+ var attackerPos = TransformSystem.GetMapCoordinates(entity);
if (mousePos.MapId != attackerPos.MapId ||
(attackerPos.Position - mousePos.Position).Length() > weapon.Range)
private readonly IInputManager _input;
private readonly IPlayerManager _player;
private readonly GunSystem _guns;
+ private readonly SharedTransformSystem _transform;
- public GunSpreadOverlay(IEntityManager entManager, IEyeManager eyeManager, IGameTiming timing, IInputManager input, IPlayerManager player, GunSystem system)
+ public GunSpreadOverlay(IEntityManager entManager, IEyeManager eyeManager, IGameTiming timing, IInputManager input, IPlayerManager player, GunSystem system, SharedTransformSystem transform)
{
_entManager = entManager;
_eye = eyeManager;
_timing = timing;
_player = player;
_guns = system;
+ _transform = transform;
}
protected override void Draw(in OverlayDrawArgs args)
return;
}
- var mapPos = xform.MapPosition;
+ var mapPos = _transform.GetMapCoordinates(player.Value, xform: xform);
if (mapPos.MapId == MapId.Nullspace)
return;
Timing,
_inputManager,
_player,
- this));
+ this,
+ TransformSystem));
}
else
{
// Sloth: Okay I'm sorry but I hate having to rewrite tests for every refactor
// If you see this yell at me in discord so I can continue to pretend this didn't happen.
// REMINDER THAT I STILL HAVE TO FIX THIS TEST EVERY OTHER PHYSICS PR
- // Assert.That(AirlockPhysicsDummy.Transform.MapPosition.X, Is.GreaterThan(AirlockPhysicsDummyStartingX));
+ // _transform.GetMapCoordinates(UID HERE, xform: Assert.That(AirlockPhysicsDummy.Transform).X, Is.GreaterThan(AirlockPhysicsDummyStartingX));
// Blocked by the airlock
await server.WaitAssertion(() =>
using System.Linq;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
+using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
var playerMan = server.ResolveDependency<IPlayerManager>();
var mapMan = server.ResolveDependency<IMapManager>();
var sys = entMan.System<SharedHandsSystem>();
+ var tSys = entMan.System<TransformSystem>();
var data = await pair.CreateTestMap();
await pair.RunTicksSync(5);
{
player = playerMan.Sessions.First().AttachedEntity!.Value;
var xform = entMan.GetComponent<TransformComponent>(player);
- item = entMan.SpawnEntity("Crowbar", xform.MapPosition);
+ item = entMan.SpawnEntity("Crowbar", tSys.GetMapCoordinates(player, xform: xform));
hands = entMan.GetComponent<HandsComponent>(player);
sys.TryPickup(player, item, hands.ActiveHand!);
});
using System.Numerics;
using Content.Shared.Interaction;
+using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
var sEntities = server.ResolveDependency<IEntityManager>();
var mapManager = server.ResolveDependency<IMapManager>();
var conSystem = sEntities.EntitySysManager.GetEntitySystem<SharedContainerSystem>();
+ var tSystem = sEntities.EntitySysManager.GetEntitySystem<TransformSystem>();
EntityUid origin = default;
EntityUid other = default;
origin = sEntities.SpawnEntity(HumanId, coordinates);
other = sEntities.SpawnEntity(HumanId, coordinates);
conSystem.EnsureContainer<Container>(other, "InRangeUnobstructedTestOtherContainer");
- mapCoordinates = sEntities.GetComponent<TransformComponent>(other).MapPosition;
+ mapCoordinates = tSystem.GetMapCoordinates(other);
});
await server.WaitIdleAsync();
using Robust.Shared.Prototypes;
using System.Linq;
using System.Numerics;
+using Robust.Server.GameObjects;
namespace Content.Server.Administration.Commands;
if (args.Length > 4)
coords = new MapCoordinates(new Vector2(x, y), xform.MapID);
else
- coords = xform.MapPosition;
+ coords = entMan.System<TransformSystem>().GetMapCoordinates(shell.Player.AttachedEntity.Value, xform: xform);
}
ExplosionPrototype? type;
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")),
Act = () =>
{
- var coords = Transform(args.Target).MapPosition;
+ var coords = _transformSystem.GetMapCoordinates(args.Target);
Timer.Spawn(_gameTiming.TickPeriod,
() => _explosionSystem.QueueExplosion(coords, ExplosionSystem.DefaultExplosionPrototypeId,
4, 1, 2, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
var damage = (int) (elec.MaxElectrocuteDamage * anom.Severity);
var duration = elec.MaxElectrocuteDuration * anom.Severity;
- foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(xform.MapPosition, range))
+ foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(_transform.GetMapCoordinates(uid, xform), range))
{
_electrocution.TryDoElectrocution(ent, uid, damage, duration, true, statusEffects: comp, ignoreInsulation: true);
}
using Content.Shared.Anomaly.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using System.Linq;
+using Robust.Server.GameObjects;
namespace Content.Server.Anomaly.Effects;
/// <summary>
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
private EntityQuery<InjectableSolutionComponent> _injectableQuery;
//We get all the entity in the radius into which the reagent will be injected.
var xformQuery = GetEntityQuery<TransformComponent>();
var xform = xformQuery.GetComponent(entity);
- var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(xform.MapPosition, injectRadius)
+ var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(_transform.GetMapCoordinates(entity, xform: xform), injectRadius)
.Select(x => x.Owner).ToList();
//for each matching entity found
using Content.Shared.Beam;
using Content.Shared.Beam.Components;
using Content.Shared.Physics;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
public sealed class BeamSystem : SharedBeamSystem
{
[Dependency] private readonly FixtureSystem _fixture = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
if (Deleted(user) || Deleted(target))
return;
- var userMapPos = Transform(user).MapPosition;
- var targetMapPos = Transform(target).MapPosition;
+ var userMapPos = _transform.GetMapCoordinates(user);
+ var targetMapPos = _transform.GetMapCoordinates(target);
//The distance between the target and the user.
var calculatedDistance = targetMapPos.Position - userMapPos.Position;
using Content.Shared.FixedPoint;
using Content.Shared.Maps;
using JetBrains.Annotations;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
var splitSolution = args.Source.SplitSolution(args.Source.Volume);
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
var mapManager = IoCManager.Resolve<IMapManager>();
+ var mapSys = args.EntityManager.System<MapSystem>();
+ var sys = args.EntityManager.System<TransformSystem>();
+ var mapCoords = sys.GetMapCoordinates(args.SolutionEntity, xform: transform);
- if (!mapManager.TryFindGridAt(transform.MapPosition, out _, out var grid) ||
- !grid.TryGetTileRef(transform.Coordinates, out var tileRef) ||
+ if (!mapManager.TryFindGridAt(mapCoords, out var gridUid, out var grid) ||
+ !mapSys.TryGetTileRef(gridUid, grid, transform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace())
{
return;
}
- var coords = grid.MapToGrid(transform.MapPosition);
+ var coords = mapSys.MapToGrid(gridUid, mapCoords);
var ent = args.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid());
var smoke = args.EntityManager.System<SmokeSystem>();
for (var i = 0; i < quantity; i++)
{
- var uid = args.EntityManager.SpawnEntity(Entity, transform.MapPosition);
+ var uid = args.EntityManager.SpawnEntity(Entity, transformSystem.GetMapCoordinates(args.SolutionEntity, xform: transform));
transformSystem.AttachToGridOrMap(uid);
// TODO figure out how to properly spawn inside of containers
using Content.Server.Emp;
using Content.Shared.Chemistry.Reagent;
+using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReactionEffects;
public override void Effect(ReagentEffectArgs args)
{
+ var tSys = args.EntityManager.System<TransformSystem>();
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
var range = MathF.Min((float) (args.Quantity*EmpRangePerUnit), EmpMaxRange);
- args.EntityManager.System<EmpSystem>().EmpPulse(
- transform.MapPosition,
+ args.EntityManager.System<EmpSystem>()
+ .EmpPulse(tSys.GetMapCoordinates(args.SolutionEntity, xform: transform),
range,
EnergyConsumption,
DisableDuration);
}
// end of genetic damage checks
- var mob = Spawn(speciesPrototype.Prototype, Transform(uid).MapPosition);
+ var mob = Spawn(speciesPrototype.Prototype, _transformSystem.GetMapCoordinates(uid));
_humanoidSystem.CloneAppearance(bodyToClone, mob);
var ev = new CloningEvent(bodyToClone, mob);
}
}
- var pos = Transform(user).MapPosition;
+ var pos = _transformSystem.GetMapCoordinates(user);
foreach (var near in _lookupSystem.GetEntitiesInRange(pos, 2f, LookupFlags.Contained | LookupFlags.Dynamic | LookupFlags.Sundries | LookupFlags.Approximate))
{
using Content.Server.Stack;
using Content.Shared.Prototypes;
using Content.Shared.Stacks;
+using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
- var position = system.EntityManager.GetComponent<TransformComponent>(owner).MapPosition;
+ var tSys = system.EntityManager.System<TransformSystem>();
+ var position = tSys.GetMapCoordinates(owner);
var getRandomVector = () => new Vector2(system.Random.NextFloat(-Offset, Offset), system.Random.NextFloat(-Offset, Offset));
? minMax.Min
: system.Random.Next(minMax.Min, minMax.Max + 1);
- if (count == 0) continue;
+ if (count == 0)
+ continue;
if (EntityPrototypeHelpers.HasComponent<StackComponent>(entityId, system.PrototypeManager, system.ComponentFactory))
{
[Dependency] private readonly DisposableSystem _disposableSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
return false;
var xform = Transform(uid);
- var holder = Spawn(DisposalEntryComponent.HolderPrototypeId, xform.MapPosition);
+ var holder = Spawn(DisposalEntryComponent.HolderPrototypeId, _transform.GetMapCoordinates(uid, xform: xform));
var holderComponent = Comp<DisposalHolderComponent>(holder);
foreach (var entity in from.Container.ContainedEntities.ToArray())
return;
}
- var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
+ var carpUid = Spawn(component.RiftPrototype, _transform.GetMapCoordinates(uid, xform: xform));
component.Rifts.Add(carpUid);
Comp<DragonRiftComponent>(carpUid).Dragon = uid;
}
using Content.Server.SurveillanceCamera;
using Content.Shared.Emp;
using Content.Shared.Examine;
+using Robust.Server.GameObjects;
using Robust.Shared.Map;
namespace Content.Server.Emp;
public sealed class EmpSystem : SharedEmpSystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public const string EmpPulseEffectPrototype = "EffectEmpPulse";
private void HandleEmpTrigger(EntityUid uid, EmpOnTriggerComponent comp, TriggerEvent args)
{
- EmpPulse(Transform(uid).MapPosition, comp.Range, comp.EnergyConsumption, comp.DisableDuration);
+ EmpPulse(_transform.GetMapCoordinates(uid), comp.Range, comp.EnergyConsumption, comp.DisableDuration);
args.Handled = true;
}
using Content.Shared.Chemistry.Components;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.Maps;
+using Robust.Server.GameObjects;
using Robust.Shared.Map;
namespace Content.Server.Explosion.EntitySystems;
{
[Dependency] private readonly IMapManager _mapMan = default!;
[Dependency] private readonly SmokeSystem _smoke = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
private void OnTrigger(EntityUid uid, SmokeOnTriggerComponent comp, TriggerEvent args)
{
var xform = Transform(uid);
- if (!_mapMan.TryFindGridAt(xform.MapPosition, out _, out var grid) ||
+ var mapCoords = _transform.GetMapCoordinates(uid, xform);
+ if (!_mapMan.TryFindGridAt(mapCoords, out _, out var grid) ||
!grid.TryGetTileRef(xform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace())
{
return;
}
- var coords = grid.MapToGrid(xform.MapPosition);
+ var coords = grid.MapToGrid(mapCoords);
var ent = Spawn(comp.SmokePrototype, coords.SnapToGrid());
if (!TryComp<SmokeComponent>(ent, out var smoke))
{
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Content.Shared.Verbs;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Collections;
using Robust.Shared.Prototypes;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
puddles.Clear();
- foreach (var entity in _lookup.GetEntitiesInRange(xform.MapPosition, drain.Range))
+ foreach (var entity in _lookup.GetEntitiesInRange(_transform.GetMapCoordinates(uid, xform), drain.Range))
{
// No InRangeUnobstructed because there's no collision group that fits right now
// and these are placed by mappers and not buildable/movable so shouldnt really be a problem...
using Content.Server.Station.Systems;
using Content.Shared.Points;
using Content.Shared.Storage;
+using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Utility;
[Dependency] private readonly RespawnRuleSystem _respawn = default!;
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
_point.AdjustPointValue(assist.PlayerId, 1, uid, point);
var spawns = EntitySpawnCollection.GetSpawns(dm.RewardSpawns).Cast<string?>().ToList();
- EntityManager.SpawnEntities(Transform(ev.Entity).MapPosition, spawns);
+ EntityManager.SpawnEntities(_transform.GetMapCoordinates(ev.Entity), spawns);
}
}
using Content.Shared.Interaction;
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee.Events;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
[Dependency] private readonly DestructibleSystem _destructible = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
if (component.MappedLoot == null)
return;
- var pos = Transform(gatheredUid).MapPosition;
+ var pos = _transform.GetMapCoordinates(gatheredUid);
foreach (var (tag, table) in component.MappedLoot)
{
var hostXform = Transform(args.Args.Target.Value);
var host = EnsureComp<GuardianHostComponent>(args.Args.Target.Value);
// Use map position so it's not inadvertantly parented to the host + if it's in a container it spawns outside I guess.
- var guardian = Spawn(component.GuardianProto, hostXform.MapPosition);
+ var guardian = Spawn(component.GuardianProto, _transform.GetMapCoordinates(args.Args.Target.Value, xform: hostXform));
_container.Insert(guardian, host.GuardianContainer);
host.HostedGuardian = guardian;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Containers;
+using Robust.Server.GameObjects;
using Robust.Shared.Random;
using Robust.Shared.Utility;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
}
var spawnEntities = EntitySpawnCollection.GetSpawns(butcher.SpawnedEntities, _robustRandom);
- var coords = Transform(args.Args.Target.Value).MapPosition;
+ var coords = _transform.GetMapCoordinates(args.Args.Target.Value);
EntityUid popupEnt = default!;
foreach (var proto in spawnEntities)
{
using Content.Server.Beam.Components;
using Content.Server.Lightning.Components;
using Content.Shared.Lightning;
+using Robust.Server.GameObjects;
using Robust.Shared.Random;
namespace Content.Server.Lightning;
[Dependency] private readonly BeamSystem _beam = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
//To Do: This is still pretty bad for perf but better than before and at least it doesn't re-allocate
// several hashsets every time
- var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(Transform(user).MapPosition, range).ToList();
+ var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(_transform.GetMapCoordinates(user), range).ToList();
_random.Shuffle(targets);
targets.Sort((x, y) => y.Priority.CompareTo(x.Priority));
using Content.Server.Lightning;
using Content.Server.Lightning.Components;
using Content.Shared.Damage;
+using Robust.Server.GameObjects;
namespace Content.Server.Tesla.EntitySystems;
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
if (uid.Comp.LightningExplode)
{
_explosionSystem.QueueExplosion(
- Transform(uid).MapPosition,
+ _transform.GetMapCoordinates(uid),
uid.Comp.ExplosionPrototype,
uid.Comp.TotalIntensity, uid.Comp.Dropoff,
uid.Comp.MaxTileIntensity,
}
var targetPos = steering.Coordinates.ToMap(EntityManager, _transform);
- var ourPos = xform.MapPosition;
+ var ourPos = _transform.GetMapCoordinates(uid, xform: xform);
PrunePath(uid, ourPos, targetPos.Position - ourPos.Position, result.Path);
steering.CurrentPath = new Queue<PathPoly>(result.Path);
if (compQuery.Components.Count == 0)
return;
- var mapPos = _xformQuery.GetComponent(owner).MapPosition;
+ var mapPos = _transform.GetMapCoordinates(owner, xform: _xformQuery.GetComponent(owner));
_compTypes.Clear();
var i = -1;
EntityPrototype.ComponentRegistryEntry compZero = default!;
if (stationUid != null)
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);
- var pos = nukeXform.MapPosition;
+ var pos = _transform.GetMapCoordinates(uid, xform: nukeXform);
var x = (int) pos.X;
var y = (int) pos.Y;
var posText = $"({x}, {y})";
using Robust.Shared.Audio.Systems;
using Robust.Shared.Utility;
using System.Linq;
+using Robust.Server.GameObjects;
namespace Content.Server.Nutrition.EntitySystems;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly StomachSystem _stomach = default!;
[Dependency] private readonly UtensilSystem _utensil = default!;
return (false, true);
// TODO make do-afters account for fixtures in the range check.
- if (!Transform(user).MapPosition.InRange(Transform(target).MapPosition, MaxFeedDistance))
+ if (!_transform.GetMapCoordinates(user).InRange(_transform.GetMapCoordinates(target), MaxFeedDistance))
{
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
_popup.PopupEntity(message, user, user);
}
//We're empty. Become trash.
- var position = Transform(food).MapPosition;
+ var position = _transform.GetMapCoordinates(food);
var finisher = Spawn(component.Trash, position);
// If the user is holding the item
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
private readonly Dictionary<NetUserId, TimeSpan> _lastSetRingtoneAt = new();
_audio.PlayEntity(
GetSound(ringer.Ringtone[ringer.NoteCount]),
- Filter.Empty().AddInRange(ringerXform.MapPosition, ringer.Range),
+ Filter.Empty().AddInRange(_transform.GetMapCoordinates(uid, ringerXform), ringer.Range),
uid,
true,
AudioParams.Default.WithMaxDistance(ringer.Range).WithVolume(ringer.Volume)
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Utility;
using System.Linq;
+using Robust.Server.GameObjects;
namespace Content.Server.Payload.EntitySystems;
{
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
var solStringB = SolutionContainerSystem.ToPrettyString(solutionB);
_adminLogger.Add(LogType.ChemicalReaction,
- $"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {Transform(entity.Owner).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
+ $"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {_transform.GetMapCoordinates(entity.Owner):location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
solutionA.MaxVolume += solutionB.MaxVolume;
_solutionContainerSystem.TryAddSolution(solnA.Value, solutionB);
(eyeComp.VisibilityMask & layer) == 0)
return false;
- return Transform(ent).MapPosition.InRange(Transform(player).MapPosition, PointingRange);
+ return _transform.GetMapCoordinates(ent).InRange(_transform.GetMapCoordinates(player), PointingRange);
}
var viewers = Filter.Empty()
{
var xform = Transform(entityGridUid.Value);
var pos = xform.Coordinates;
- var mapPos = xform.MapPosition;
+ var mapPos = _transform.GetMapCoordinates(entityGridUid.Value, xform: xform);
var circle = new Circle(mapPos.Position, 2);
var found = false;
var range2 = range * range;
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var epicenter = _xformSystem.GetWorldPosition(xform, xformQuery);
- foreach (var entity in _lookup.GetEntitiesInRange(xform.MapPosition, range, flags: LookupFlags.Uncontained))
+ foreach (var entity in _lookup.GetEntitiesInRange(_xformSystem.GetMapCoordinates(uid, xform), range, flags: LookupFlags.Uncontained))
{
if (entity == uid)
continue;
if (!Resolve(uid, ref xform) || !Resolve(uid, ref eventHorizon))
return;
- var mapPos = xform.MapPosition;
+ var mapPos = _xformSystem.GetMapCoordinates(uid, xform: xform);
var box = Box2.CenteredAround(mapPos.Position, new Vector2(range, range));
var circle = new Circle(mapPos.Position, range);
var grids = new List<Entity<MapGridComponent>>();
using Content.Server.Emp;
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
+using Robust.Server.GameObjects;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class EmpArtifactSystem : EntitySystem
{
[Dependency] private readonly EmpSystem _emp = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
/// <inheritdoc/>
public override void Initialize()
private void OnActivate(EntityUid uid, EmpArtifactComponent component, ArtifactActivatedEvent args)
{
- _emp.EmpPulse(Transform(uid).MapPosition, component.Range, component.EnergyConsumption, component.DisableDuration);
+ _emp.EmpPulse(_transform.GetMapCoordinates(uid), component.Range, component.EnergyConsumption, component.DisableDuration);
}
-}
\ No newline at end of file
+}
if (component.Spawns is not {} spawns)
return;
- var artifactCord = Transform(uid).MapPosition;
+ var artifactCord = _transform.GetMapCoordinates(uid);
foreach (var spawn in EntitySpawnCollection.GetSpawns(spawns, _random))
{
var dx = _random.NextFloat(-component.Range, component.Range);
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Throwing;
+using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly TileSystem _tile = default!;
+ [Dependency] private readonly TransformSystem _transform = default!;
/// <inheritdoc/>
public override void Initialize()
var tempXform = Transform(ent);
- var foo = tempXform.MapPosition.Position - xform.MapPosition.Position;
+ var foo = _transform.GetMapCoordinates(ent, xform: tempXform).Position - _transform.GetMapCoordinates(uid, xform: xform).Position;
_throwing.TryThrow(ent, foo*2, component.ThrowStrength, uid, 0);
}
}
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
public const string InvokedPort = "link_port";
private bool InRange(EntityUid sourceUid, EntityUid sinkUid, float range)
{
// TODO: This should be using an existing method and also coordinates inrange instead.
- return Transform(sourceUid).MapPosition.InRange(Transform(sinkUid).MapPosition, range);
+ return _transform.GetMapCoordinates(sourceUid).InRange(_transform.GetMapCoordinates(sinkUid), range);
}
private void SendNewLinkEvent(EntityUid? user, EntityUid sourceUid, string source, EntityUid sinkUid, string sink)
public bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
- var otherPos = entMan.GetComponent<TransformComponent>(other).MapPosition;
+ var originPos = _transform.GetMapCoordinates(origin);
+ var otherPos = _transform.GetMapCoordinates(other);
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}
public bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
+ var originPos = _transform.GetMapCoordinates(origin);
var otherPos = other.ToMap(entMan, _transform);
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
public bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
+ var originPos = _transform.GetMapCoordinates(origin);
return InRangeUnOccluded(originPos, other, range, predicate, ignoreInsideBlocker);
}
var xform = Transform(uid);
var coordinateEntity = xform.ParentUid.IsValid() ? xform.ParentUid : uid;
var itemXform = Transform(entity);
- var itemPos = itemXform.MapPosition;
+ var itemPos = TransformSystem.GetMapCoordinates(entity, xform: itemXform);
if (itemPos.MapId == xform.MapID
- && (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange
+ && (itemPos.Position - TransformSystem.GetMapCoordinates(uid, xform: xform).Position).Length() <= MaxAnimationRange
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups.
{
var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, TransformSystem, EntityManager);
if (!Resolve(user, ref xform))
return false;
- var diff = coordinates - xform.MapPosition.Position;
+ var diff = coordinates - _transform.GetMapCoordinates(user, xform: xform).Position;
if (diff.LengthSquared() <= 0.01f)
return true;
else
{
// We'll still do the raycast from the centres but we'll bump the range as we know they're in range.
- originPos = xformA.MapPosition;
+ originPos = _transform.GetMapCoordinates(origin, xform: xformA);
range = (originPos.Position - targetPos.Position).Length();
}
}
// No fixtures, e.g. wallmounts.
else
{
- originPos = Transform(origin).MapPosition;
+ originPos = _transform.GetMapCoordinates(origin);
var otherParent = Transform(other).ParentUid;
targetRot = otherParent.IsValid() ? Transform(otherParent).LocalRotation + otherAngle : otherAngle;
}
bool popup = false)
{
Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false);
- var originPosition = Transform(origin).MapPosition;
+ var originPosition = _transform.GetMapCoordinates(origin);
var inRange = InRangeUnobstructed(originPosition, other, range, collisionMask, combinedPredicate, ShouldCheckAccess(origin));
if (!inRange && popup && _gameTiming.IsFirstTimePredicted)
// the problem is that stack pickups delete the original entity, which is fine, but due to
// game state handling we can't show a lerp animation for it.
var nearXform = Transform(near);
- var nearMap = nearXform.MapPosition;
+ var nearMap = _transform.GetMapCoordinates(near, xform: nearXform);
var nearCoords = EntityCoordinates.FromMap(moverCoords.EntityId, nearMap, _transform, EntityManager);
if (!_storage.Insert(uid, near, out var stacked, storageComp: storage, playSound: !playedSound))
[Dependency] protected readonly ActionBlockerSystem ActionBlockerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
- [Dependency] private readonly SharedTransformSystem _transforms = default!;
+ [Dependency] protected readonly SharedTransformSystem Transforms = default!;
[Dependency] private readonly IMapManager _mapMan = default!;
public override void Initialize()
// Move the entity and dirty it (we use the map ID from the entity so noone can try to be funny and move the item to another map)
var transform = EntityManager.GetComponent<TransformComponent>(moved);
- _transforms.SetParent(moved, transform, _mapMan.GetMapEntityId(transform.MapID));
- _transforms.SetLocalPositionNoLerp(transform, msg.Coordinates.Position);
+ Transforms.SetParent(moved, transform, _mapMan.GetMapEntityId(transform.MapID));
+ Transforms.SetLocalPositionNoLerp(transform, msg.Coordinates.Position);
}
private void OnDraggingPlayerChanged(TabletopDraggingPlayerChangedEvent msg, EntitySessionEventArgs args)
_blocker.UpdateCanMove(target);
// Invisible tether entity
- var tether = Spawn("TetherEntity", Transform(target).MapPosition);
+ var tether = Spawn("TetherEntity", TransformSystem.GetMapCoordinates(target));
var tetherPhysics = Comp<PhysicsComponent>(tether);
component.TetherEntity = tether;
_physics.WakeBody(tether);
if (args.Handled)
return;
- ManualCycle(uid, component, Transform(uid).MapPosition, args.User);
+ ManualCycle(uid, component, TransformSystem.GetMapCoordinates(uid), args.User);
args.Handled = true;
}
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
- Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
+ Act = () => ManualCycle(uid, component, TransformSystem.GetMapCoordinates(uid), args.User),
});
}