Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Nov 16, 2024
1 parent 6e79e54 commit eb3e124
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 55 deletions.
5 changes: 3 additions & 2 deletions Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Content.Client.Clickable
public sealed partial class ClickableComponent : Component
{
[Dependency] private readonly IClickMapManager _clickMapManager = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;

[DataField("bounds")] public DirBoundData? Bounds;

Expand All @@ -36,7 +37,7 @@ public bool CheckClick(SpriteComponent sprite, TransformComponent transform, Ent

drawDepth = sprite.DrawDepth;
renderOrder = sprite.RenderOrder;
var (spritePos, spriteRot) = transform.GetWorldPositionRotation(xformQuery);
var (spritePos, spriteRot) = _transformSystem.GetWorldPositionRotation(transform.Owner);
var spriteBB = sprite.CalculateRotatedBoundingBox(spritePos, spriteRot, eye.Rotation);
bottom = Matrix3Helpers.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;

Expand All @@ -48,7 +49,7 @@ public bool CheckClick(SpriteComponent sprite, TransformComponent transform, Ent
Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero;

// First we get `localPos`, the clicked location in the sprite-coordinate frame.
var entityXform = Matrix3Helpers.CreateInverseTransform(transform.WorldPosition, sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
var entityXform = Matrix3Helpers.CreateInverseTransform(_transformSystem.GetWorldPosition(transform), sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
var localPos = Vector2.Transform(Vector2.Transform(worldPos, entityXform), invSpriteMatrix);

// Check explicitly defined click-able bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class GasPortableSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
[Dependency] private readonly SharedMapSystem _sharedMapSystem = default!;

public override void Initialize()
{
Expand All @@ -33,7 +34,7 @@ private void OnPortableAnchorAttempt(EntityUid uid, GasPortableComponent compone
return;

// If we can't find any ports, cancel the anchoring.
if(!FindGasPortIn(transform.GridUid, transform.Coordinates, out _))
if (!FindGasPortIn(transform.GridUid, transform.Coordinates, out _))
args.Cancel();
}

Expand All @@ -54,10 +55,13 @@ public bool FindGasPortIn(EntityUid? gridId, EntityCoordinates coordinates, [Not
{
port = null;

if (gridId == null)
return false;

if (!TryComp<MapGridComponent>(gridId, out var grid))
return false;

foreach (var entityUid in grid.GetLocal(coordinates))
foreach (var entityUid in _sharedMapSystem.GetLocal((EntityUid) gridId, grid, coordinates))
{
if (EntityManager.TryGetComponent(entityUid, out port))
{
Expand Down
42 changes: 12 additions & 30 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
using Robust.Shared.Configuration;
using Robust.Shared.Map.Components;

namespace Content.Server.Cargo.Systems;

Expand Down Expand Up @@ -91,14 +92,7 @@ private void UpdatePalletConsoleInterface(EntityUid uid)
}

private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component, BoundUIOpenedEvent args)
{
var player = args.Actor;

if (player == null)
return;

UpdatePalletConsoleInterface(uid);
}
=> UpdatePalletConsoleInterface(uid);

/// <summary>
/// Ok so this is just the same thing as opening the UI, its a refresh button.
Expand All @@ -109,20 +103,10 @@ private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component
/// </summary>

private void OnPalletAppraise(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletAppraiseMessage args)
{
var player = args.Actor;

if (player == null)
return;

UpdatePalletConsoleInterface(uid);
}
=> UpdatePalletConsoleInterface(uid);

private void OnCargoShuttleConsoleStartup(EntityUid uid, CargoShuttleConsoleComponent component, ComponentStartup args)
{
var station = _station.GetOwningStation(uid);
UpdateShuttleState(uid, station);
}
=> UpdateShuttleState(uid, _station.GetOwningStation(uid));

private void UpdateShuttleState(EntityUid uid, EntityUid? station = null)
{
Expand Down Expand Up @@ -339,10 +323,6 @@ private bool CanSell(EntityUid uid, TransformComponent xform)
private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletSellMessage args)
{
var player = args.Actor;

if (player == null)
return;

var xform = Transform(uid);

if (xform.GridUid is not EntityUid gridUid)
Expand Down Expand Up @@ -380,7 +360,7 @@ private void OnStationInitialize(StationInitializedEvent args)

private void CleanupTradeStation()
{
if (CargoMap == null || !_mapManager.MapExists(CargoMap.Value))
if (CargoMap == null || !_sharedMapSystem.MapExists(CargoMap.Value))
{
CargoMap = null;
DebugTools.Assert(!EntityQuery<CargoShuttleComponent>().Any());
Expand All @@ -393,13 +373,14 @@ private void CleanupTradeStation()

private void SetupTradePost()
{
if (CargoMap != null && _mapManager.MapExists(CargoMap.Value))
if (CargoMap != null && _sharedMapSystem.MapExists(CargoMap.Value))
{
return;
}

// It gets mapinit which is okay... buuutt we still want it paused to avoid power draining.
CargoMap = _mapManager.CreateMap();
var mapEntId = _mapSystem.CreateMap();
CargoMap = _entityManager.GetComponent<MapComponent>(mapEntId).MapId;

var options = new MapLoadOptions
{
Expand All @@ -420,11 +401,12 @@ private void SetupTradePost()
var shuttleComponent = EnsureComp<ShuttleComponent>(grid);
shuttleComponent.AngularDamping = 10000;
shuttleComponent.LinearDamping = 10000;
Dirty(shuttleComponent);
Dirty(grid, shuttleComponent);
}

var mapUid = _mapManager.GetMapEntityId(CargoMap.Value);
var ftl = EnsureComp<FTLDestinationComponent>(_mapManager.GetMapEntityId(CargoMap.Value));
var mapUid = _sharedMapSystem.GetMap(CargoMap.Value);
var ftl = EnsureComp<FTLDestinationComponent>(mapUid);

ftl.Whitelist = new EntityWhitelist()
{
Components =
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Cargo/Systems/CargoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public sealed partial class CargoSystem : SharedCargoSystem
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly RadioSystem _radio = default!;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly SharedMapSystem _sharedMapSystem = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IComponentFactory _factory = default!;
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Content.Server.Chat.Systems;

// Dear contributor. When I was introducing changes to this system only god and I knew what I was doing.
// Now only god knows. Please don't touch this code ever again. If you do have to, increment this counter as a warning for others:
// TOTAL_HOURS_WASTED_HERE_EE = 18
// TOTAL_HOURS_WASTED_HERE_EE = 19

// TODO refactor whatever active warzone this class and chatmanager have become
/// <summary>
Expand Down Expand Up @@ -343,7 +343,7 @@ public void DispatchGlobalAnnouncement(
_chatManager.ChatMessageToAll(ChatChannel.Radio, message, wrappedMessage, default, false, true, colorOverride);
if (playSound)
{
_audio.PlayGlobal(announcementSound?.GetSound() ?? DefaultAnnouncementSound, Filter.Broadcast(), true, AudioParams.Default.WithVolume(-2f));
_audio.PlayGlobal(announcementSound != null ? announcementSound.ToString() : DefaultAnnouncementSound, Filter.Broadcast(), true, AudioParams.Default.WithVolume(-2f));
}
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Global station announcement from {sender}: {message}");
}
Expand Down Expand Up @@ -381,7 +381,7 @@ public void DispatchStationAnnouncement(

if (playDefaultSound)
{
_audio.PlayGlobal(announcementSound?.GetSound() ?? DefaultAnnouncementSound, filter, true, AudioParams.Default.WithVolume(-2f));
_audio.PlayGlobal(announcementSound != null ? announcementSound.ToString() : DefaultAnnouncementSound, filter, true, AudioParams.Default.WithVolume(-2f));
}

_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Station Announcement on {station} from {sender}: {message}");
Expand Down
10 changes: 6 additions & 4 deletions Content.Server/Chat/TelepathicChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ public override void Initialize()
private IEnumerable<INetChannel> GetAdminClients()
{
return _adminManager.ActiveAdmins
.Select(p => p.ConnectedClient);
.Select(p => p.Channel);
}

private List<INetChannel> GetDreamers(IEnumerable<INetChannel> removeList)
{
var filteredList = new List<INetChannel>();
var filtered = Filter.Empty()
.AddWhereAttachedEntity(entity =>
HasComp<PsionicComponent>(entity) && !HasComp<TelepathyComponent>(entity)
|| HasComp<SleepingComponent>(entity)
|| HasComp<SeeingRainbowsComponent>(entity) && !HasComp<PsionicsDisabledComponent>(entity) && !HasComp<PsionicInsulationComponent>(entity))
.Recipients
.Select(p => p.ConnectedClient);
.Select(p => p.Channel);

var filteredList = filtered.ToList();
if (filtered.ToList() != null)
filteredList = filtered.ToList();

foreach (var entity in removeList)
filteredList.Remove(entity);
Expand Down Expand Up @@ -134,7 +136,7 @@ private string ObfuscateMessageReadability(string message, float chance)

for (var i = 0; i < message.Length; i++)
{
if (char.IsWhiteSpace((modifiedMessage[i])))
if (char.IsWhiteSpace(modifiedMessage[i]))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Player;

namespace Content.Server.Construction.Commands
Expand All @@ -24,8 +26,11 @@ sealed class TileWindowsCommand : IConsoleCommand

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as ICommonSession;
var player = shell.Player;
var entityManager = IoCManager.Resolve<IEntityManager>();
var lookup = IoCManager.Resolve<EntityLookupSystem>();
var mapSystem = IoCManager.Resolve<SharedMapSystem>();

EntityUid? gridId;

switch (args.Length)
Expand Down Expand Up @@ -53,8 +58,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var mapManager = IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
if (!entityManager.TryGetComponent<MapGridComponent>(gridId, out var grid))
{
shell.WriteLine($"No grid exists with id {gridId}");
return;
Expand All @@ -70,8 +74,12 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
var tagSystem = entityManager.EntitySysManager.GetEntitySystem<TagSystem>();
var underplating = tileDefinitionManager[TilePrototypeId];
var underplatingTile = new Tile(underplating.TileId);
var childEntities = new HashSet<Entity<TransformComponent>>();
var changed = 0;
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.Owner).ChildEntities)

lookup.GetChildEntities(grid.Owner, childEntities);

foreach (var child in childEntities)
{
if (!entityManager.EntityExists(child))
{
Expand All @@ -95,15 +103,15 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
continue;
}

var tile = grid.GetTileRef(childTransform.Coordinates);
var tile = mapSystem.GetTileRef((EntityUid) gridId, grid, childTransform.Coordinates);
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];

if (tileDef.ID == TilePrototypeId)
{
continue;
}

grid.SetTile(childTransform.Coordinates, underplatingTile);
mapSystem.SetTile((EntityUid) gridId, grid, childTransform.Coordinates, underplatingTile);
changed++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private void SendWhitelistCached(ICommonSession playerSession)
Whitelisted = whitelist
};

_net.ServerSendMessage(msg, playerSession.ConnectedClient);
_net.ServerSendMessage(msg, playerSession.Channel);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Psionics/Dreams/DreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void Update(float frameTime)
("telepathicChannelName", Loc.GetString("chat-manager-telepathic-channel-name")), ("message", msg));

_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Telepathic,
msg, messageWrap, sleeper.Owner, false, actor.PlayerSession.ConnectedClient, Color.PaleVioletRed);
msg, messageWrap, sleeper.Owner, false, actor.PlayerSession.Channel, Color.PaleVioletRed);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Shadowkin/ShadowkinSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void OnEyeColorChange(EntityUid uid, ShadowkinComponent component, EyeCo

component.OldEyeColor = humanoid.EyeColor;
humanoid.EyeColor = component.BlackEyeColor;
Dirty(humanoid);
Dirty(uid, humanoid);
}

private void OnExamined(EntityUid uid, ShadowkinComponent component, ExaminedEvent args)
Expand Down Expand Up @@ -115,7 +115,7 @@ private void OnManaUpdate(EntityUid uid, ShadowkinComponent component, ref OnMan
if (magic.Mana <= component.BlackEyeMana)
ApplyBlackEye(uid);

Dirty(magic); // Update Shadowkin Overlay.
Dirty(uid, magic); // Update Shadowkin Overlay.
UpdateShadowkinAlert(uid, component);
}

Expand All @@ -141,7 +141,7 @@ private void OnMindbreak(EntityUid uid, ShadowkinComponent component, ref OnMind
{
component.OldEyeColor = humanoid.EyeColor;
humanoid.EyeColor = component.BlackEyeColor;
Dirty(humanoid);
Dirty(uid, humanoid);
}

if (component.BlackeyeSpawn)
Expand All @@ -162,7 +162,7 @@ private void OnRejuvenate(EntityUid uid, ShadowkinComponent component, Rejuvenat
if (TryComp<HumanoidAppearanceComponent>(uid, out var humanoid))
{
humanoid.EyeColor = component.OldEyeColor;
Dirty(humanoid);
Dirty(uid, humanoid);
}

EnsureComp<PsionicComponent>(uid, out var magic);
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ public bool TryDrop(EntityUid uid, Hand hand, EntityCoordinates? targetDropLocat
// TODO recursively check upwards for containers

if (!isInContainer
|| !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true)
|| !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container)
|| !ContainerSystem.Insert((entity, itemXform), container))
TransformSystem.AttachToGridOrMap(entity, itemXform);
return true;
}

var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity);
var origin = new MapCoordinates(itemPos, itemXform.MapID);
var target = targetDropLocation.Value.ToMap(EntityManager, TransformSystem);
var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value);
TransformSystem.SetWorldPositionRotation(entity, GetFinalDropCoordinates(uid, origin, target), itemRot);
return true;
}
Expand Down

0 comments on commit eb3e124

Please sign in to comment.