From 2ff16a580b9b59bbee7e1ba69a0e83cf002bc45c Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Sat, 4 Dec 2021 12:59:44 +0100 Subject: [PATCH] Bunch more error fixes. --- Content.Shared/Alert/IAlertClick.cs | 4 +- .../Components/SharedBodyPartComponent.cs | 6 +-- .../Components/SharedMechanismComponent.cs | 2 +- Content.Shared/Body/Surgery/ISurgeon.cs | 2 +- .../Body/Surgery/SurgeryDataComponent.cs | 4 +- .../Conditions/EmptyOrWindowValidInTile.cs | 2 +- .../Containers/ItemSlot/ItemSlotsComponent.cs | 5 +-- .../Containers/ItemSlot/ItemSlotsSystem.cs | 42 +++++++++--------- .../EntityCoordinatesExtensions.cs | 20 --------- .../Disposal/SharedDisposalUnitSystem.cs | 8 +--- Content.Shared/Doors/SharedDoorComponent.cs | 2 +- Content.Shared/Interaction/IRangedInteract.cs | 6 +-- .../Interaction/RotateToFaceSystem.cs | 4 +- .../Inventory/SharedInventoryComponent.cs | 2 +- Content.Shared/Item/SharedItemComponent.cs | 2 +- .../MobState/MobStateChangedMessage.cs | 2 +- .../MovementIgnoreGravityComponent.cs | 2 +- .../Movement/RelayMovementEntityEvent.cs | 4 +- .../Popups/SharedPopupExtensions.cs | 8 ++-- .../Systems/SharedPullingSystem.Actions.cs | 20 ++++----- .../Pulling/Systems/SharedPullingSystem.cs | 44 +++++++++---------- .../Random/Helpers/SharedEntityExtensions.cs | 6 +-- Content.Shared/Roles/JobSpecial.cs | 2 +- .../Storage/SharedStorageComponent.cs | 4 +- .../Components/SharedStrippableComponent.cs | 2 +- Content.Shared/Tag/TagComponentExtensions.cs | 28 ++++++------ Content.Shared/Throwing/ThrowEvents.cs | 12 ++--- .../Throwing/ThrownItemComponent.cs | 2 +- Content.Shared/Throwing/ThrownItemSystem.cs | 2 +- .../Transform/TransformExtensions.cs | 2 +- Content.Shared/Weapons/Melee/AttackEvent.cs | 20 ++++----- 31 files changed, 120 insertions(+), 151 deletions(-) diff --git a/Content.Shared/Alert/IAlertClick.cs b/Content.Shared/Alert/IAlertClick.cs index 614c9ee6a0..e953b6f525 100644 --- a/Content.Shared/Alert/IAlertClick.cs +++ b/Content.Shared/Alert/IAlertClick.cs @@ -20,13 +20,13 @@ namespace Content.Shared.Alert /// /// Player clicking the alert /// - public readonly IEntity Player; + public readonly EntityUid Player; /// /// Alert that was clicked /// public readonly AlertPrototype Alert; - public ClickAlertEventArgs(IEntity player, AlertPrototype alert) + public ClickAlertEventArgs(EntityUid player, AlertPrototype alert) { Player = player; Alert = alert; diff --git a/Content.Shared/Body/Components/SharedBodyPartComponent.cs b/Content.Shared/Body/Components/SharedBodyPartComponent.cs index 750d248846..4e42a05f5f 100644 --- a/Content.Shared/Body/Components/SharedBodyPartComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyPartComponent.cs @@ -143,7 +143,7 @@ namespace Content.Shared.Body.Components var i = 0; foreach (var mechanism in _mechanisms) { - mechanismIds[i] = mechanism.OwnerUid; + mechanismIds[i] = mechanism.Owner; i++; } @@ -183,7 +183,7 @@ namespace Content.Shared.Body.Components return SurgeryDataComponent?.CheckSurgery(surgery) ?? false; } - public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, IEntity performer) + public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, EntityUid performer) { DebugTools.AssertNotNull(toolType); DebugTools.AssertNotNull(target); @@ -370,7 +370,7 @@ namespace Content.Shared.Body.Components continue; } - if (!IoCManager.Resolve().TryGetComponent(entity, out SharedMechanismComponent? mechanism)) + if (!IoCManager.Resolve().TryGetComponent(entity.Value, out SharedMechanismComponent? mechanism)) { continue; } diff --git a/Content.Shared/Body/Components/SharedMechanismComponent.cs b/Content.Shared/Body/Components/SharedMechanismComponent.cs index eff45e15bf..337a5c4069 100644 --- a/Content.Shared/Body/Components/SharedMechanismComponent.cs +++ b/Content.Shared/Body/Components/SharedMechanismComponent.cs @@ -15,7 +15,7 @@ namespace Content.Shared.Body.Components protected readonly Dictionary OptionsCache = new(); protected SharedBodyComponent? BodyCache; protected int IdHash; - protected IEntity? PerformerCache; + protected EntityUid? PerformerCache; private SharedBodyPartComponent? _part; public SharedBodyComponent? Body => Part?.Body; diff --git a/Content.Shared/Body/Surgery/ISurgeon.cs b/Content.Shared/Body/Surgery/ISurgeon.cs index 33ec4f375b..a322e779cd 100644 --- a/Content.Shared/Body/Surgery/ISurgeon.cs +++ b/Content.Shared/Body/Surgery/ISurgeon.cs @@ -15,7 +15,7 @@ namespace Content.Shared.Body.Surgery SharedMechanismComponent target, IBodyPartContainer container, ISurgeon surgeon, - IEntity performer); + EntityUid performer); /// /// How long it takes to perform a single surgery step in seconds. diff --git a/Content.Shared/Body/Surgery/SurgeryDataComponent.cs b/Content.Shared/Body/Surgery/SurgeryDataComponent.cs index 1d9c24b93e..d7ad938d3f 100644 --- a/Content.Shared/Body/Surgery/SurgeryDataComponent.cs +++ b/Content.Shared/Body/Surgery/SurgeryDataComponent.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Body.Surgery /// public interface ISurgeryData : IComponent { - public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer); + public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer); /// /// The this @@ -78,6 +78,6 @@ namespace Content.Shared.Body.Surgery /// The entity performing the surgery. /// True if successful, false otherwise. public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon, - IEntity performer); + EntityUid performer); } } diff --git a/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs b/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs index 61a3a520b9..9e12089294 100644 --- a/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs +++ b/Content.Shared/Construction/Conditions/EmptyOrWindowValidInTile.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Construction.Conditions [DataField("tileNotBlocked")] private readonly TileNotBlocked _tileNotBlocked = new(); - public bool Condition(IEntity user, EntityCoordinates location, Direction direction) + public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { var result = false; diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsComponent.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsComponent.cs index b8993fb475..6b37f44178 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsComponent.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsComponent.cs @@ -171,9 +171,6 @@ namespace Content.Shared.Containers.ItemSlots // Convenience properties public bool HasItem => ContainerSlot.ContainedEntity != null; - public IEntity? Item => ContainerSlot.ContainedEntity; - - // and to make it easier for whenever IEntity is removed - public EntityUid? ItemUid => ContainerSlot.ContainedEntity; + public EntityUid? Item => ContainerSlot.ContainedEntity; } } diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 25bc754d24..da03ac4e28 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -120,7 +120,7 @@ namespace Content.Shared.Containers.ItemSlots continue; args.Handled = true; - TryEjectToHands(uid, slot, args.UserUid); + TryEjectToHands(uid, slot, args.User); break; } } @@ -139,12 +139,12 @@ namespace Content.Shared.Containers.ItemSlots if (args.Handled) return; - if (!EntityManager.TryGetComponent(args.UserUid, out SharedHandsComponent? hands)) + if (!EntityManager.TryGetComponent(args.User, out SharedHandsComponent? hands)) return; foreach (var slot in itemSlots.Slots.Values) { - if (!CanInsert(uid, args.UsedUid, slot, swap: slot.Swap, popup: args.UserUid)) + if (!CanInsert(uid, args.Used, slot, swap: slot.Swap, popup: args.User)) continue; // Drop the held item onto the floor. Return if the user cannot drop. @@ -152,7 +152,7 @@ namespace Content.Shared.Containers.ItemSlots return; if (slot.Item != null) - hands.TryPutInAnyHand(slot.Item); + hands.TryPutInAnyHand(slot.Item.Value); Insert(uid, slot, args.Used); args.Handled = true; @@ -166,7 +166,7 @@ namespace Content.Shared.Containers.ItemSlots /// Insert an item into a slot. This does not perform checks, so make sure to also use or just use instead. /// - private void Insert(EntityUid uid, ItemSlot slot, IEntity item) + private void Insert(EntityUid uid, ItemSlot slot, EntityUid item) { slot.ContainerSlot.Insert(item); // ContainerSlot automatically raises a directed EntInsertedIntoContainerMessage @@ -208,7 +208,7 @@ namespace Content.Shared.Containers.ItemSlots /// Tries to insert item into a specific slot. /// /// False if failed to insert item - public bool TryInsert(EntityUid uid, string id, IEntity item, ItemSlotsComponent? itemSlots = null) + public bool TryInsert(EntityUid uid, string id, EntityUid item, ItemSlotsComponent? itemSlots = null) { if (!Resolve(uid, ref itemSlots)) return false; @@ -223,7 +223,7 @@ namespace Content.Shared.Containers.ItemSlots /// Tries to insert item into a specific slot. /// /// False if failed to insert item - public bool TryInsert(EntityUid uid, ItemSlot slot, IEntity item) + public bool TryInsert(EntityUid uid, ItemSlot slot, EntityUid item) { if (!CanInsert(uid, item, slot)) return false; @@ -244,14 +244,14 @@ namespace Content.Shared.Containers.ItemSlots if (!hands.TryGetActiveHeldEntity(out var item)) return false; - if (!CanInsert(uid, item, slot)) + if (!CanInsert(uid, item.Value, slot)) return false; // hands.Drop(item) checks CanDrop action blocker - if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item)) + if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item.Value)) return false; - Insert(uid, slot, item); + Insert(uid, slot, item.Value); return true; } #endregion @@ -261,7 +261,7 @@ namespace Content.Shared.Containers.ItemSlots /// Eject an item into a slot. This does not perform checks (e.g., is the slot locked?), so you should /// probably just use instead. /// - private void Eject(EntityUid uid, ItemSlot slot, IEntity item) + private void Eject(EntityUid uid, ItemSlot slot, EntityUid item) { slot.ContainerSlot.Remove(item); // ContainerSlot automatically raises a directed EntRemovedFromContainerMessage @@ -274,7 +274,7 @@ namespace Content.Shared.Containers.ItemSlots /// Try to eject an item from a slot. /// /// False if item slot is locked or has no item inserted - public bool TryEject(EntityUid uid, ItemSlot slot, [NotNullWhen(true)] out IEntity? item) + public bool TryEject(EntityUid uid, ItemSlot slot, [NotNullWhen(true)] out EntityUid? item) { item = null; @@ -282,7 +282,7 @@ namespace Content.Shared.Containers.ItemSlots return false; item = slot.Item; - Eject(uid, slot, item); + Eject(uid, slot, item.Value); return true; } @@ -290,7 +290,7 @@ namespace Content.Shared.Containers.ItemSlots /// Try to eject item from a slot. /// /// False if the id is not valid, the item slot is locked, or it has no item inserted - public bool TryEject(EntityUid uid, string id, [NotNullWhen(true)] out IEntity? item, ItemSlotsComponent? itemSlots = null) + public bool TryEject(EntityUid uid, string id, [NotNullWhen(true)] out EntityUid? item, ItemSlotsComponent? itemSlots = null) { item = null; @@ -317,7 +317,7 @@ namespace Content.Shared.Containers.ItemSlots return false; if (user != null && EntityManager.TryGetComponent(user.Value, out SharedHandsComponent? hands)) - hands.TryPutInAnyHand(item); + hands.TryPutInAnyHand(item.Value); return true; } @@ -344,7 +344,7 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(slot.Item!).EntityName ?? string.Empty; + : IoCManager.Resolve().GetComponent(slot.Item!.Value).EntityName ?? string.Empty; Verb verb = new(); verb.Act = () => TryEjectToHands(uid, slot, args.User); @@ -379,7 +379,7 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(slot.Item!).EntityName ?? string.Empty; + : IoCManager.Resolve().GetComponent(slot.Item!.Value).EntityName ?? string.Empty; Verb takeVerb = new(); takeVerb.Act = () => TryEjectToHands(uid, slot, args.User); @@ -400,15 +400,15 @@ namespace Content.Shared.Containers.ItemSlots foreach (var slot in itemSlots.Slots.Values) { - if (!CanInsert(uid, args.Using, slot)) + if (!CanInsert(uid, args.Using.Value, slot)) continue; var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(args.Using).EntityName ?? string.Empty; + : IoCManager.Resolve().GetComponent(args.Using.Value).EntityName ?? string.Empty; Verb insertVerb = new(); - insertVerb.Act = () => Insert(uid, slot, args.Using); + insertVerb.Act = () => Insert(uid, slot, args.Using.Value); if (slot.InsertVerbText != null) { @@ -448,7 +448,7 @@ namespace Content.Shared.Containers.ItemSlots /// /// Get the contents of some item slot. /// - public IEntity? GetItem(EntityUid uid, string id, ItemSlotsComponent? itemSlots = null) + public EntityUid? GetItem(EntityUid uid, string id, ItemSlotsComponent? itemSlots = null) { if (!Resolve(uid, ref itemSlots)) return null; diff --git a/Content.Shared/Coordinates/EntityCoordinatesExtensions.cs b/Content.Shared/Coordinates/EntityCoordinatesExtensions.cs index 2d81f1c411..11c313d592 100644 --- a/Content.Shared/Coordinates/EntityCoordinatesExtensions.cs +++ b/Content.Shared/Coordinates/EntityCoordinatesExtensions.cs @@ -16,26 +16,6 @@ namespace Content.Shared.Coordinates return new(id, x, y); } - public static EntityCoordinates ToCoordinates(this EntityUid id) - { - return ToCoordinates(id, Vector2.Zero); - } - - public static EntityCoordinates ToCoordinates(this IEntity entity, Vector2 offset) - { - return ToCoordinates((EntityUid) entity, offset); - } - - public static EntityCoordinates ToCoordinates(this IEntity entity, float x, float y) - { - return new(entity, x, y); - } - - public static EntityCoordinates ToCoordinates(this IEntity entity) - { - return ToCoordinates((EntityUid) entity, Vector2.Zero); - } - public static EntityCoordinates ToCoordinates(this IMapGrid grid, Vector2 offset) { return ToCoordinates(grid.GridEntityId, offset); diff --git a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs index 7ba9d278ad..4660b9d93a 100644 --- a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs +++ b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs @@ -47,7 +47,7 @@ namespace Content.Shared.Disposal } } - public virtual bool CanInsert(SharedDisposalUnitComponent component, IEntity entity) + public virtual bool CanInsert(SharedDisposalUnitComponent component, EntityUid entity) { if (!IoCManager.Resolve().GetComponent(component.Owner).Anchored) return false; @@ -71,11 +71,5 @@ namespace Content.Shared.Disposal return true; } - - public bool CanInsert(SharedDisposalUnitComponent component, EntityUid entityId) - { - var entity = EntityManager.GetEntity(entityId); - return CanInsert(component, entity); - } } } diff --git a/Content.Shared/Doors/SharedDoorComponent.cs b/Content.Shared/Doors/SharedDoorComponent.cs index a673fa78a8..efc643b344 100644 --- a/Content.Shared/Doors/SharedDoorComponent.cs +++ b/Content.Shared/Doors/SharedDoorComponent.cs @@ -97,7 +97,7 @@ namespace Content.Shared.Doors /// protected List CurrentlyCrushing = new(); - public bool IsCrushing(IEntity entity) + public bool IsCrushing(EntityUid entity) { return CurrentlyCrushing.Contains(entity); } diff --git a/Content.Shared/Interaction/IRangedInteract.cs b/Content.Shared/Interaction/IRangedInteract.cs index 89b1f0eb00..c878b1dcd0 100644 --- a/Content.Shared/Interaction/IRangedInteract.cs +++ b/Content.Shared/Interaction/IRangedInteract.cs @@ -23,15 +23,15 @@ namespace Content.Shared.Interaction [PublicAPI] public class RangedInteractEventArgs : EventArgs { - public RangedInteractEventArgs(IEntity user, IEntity @using, EntityCoordinates clickLocation) + public RangedInteractEventArgs(EntityUid user, EntityUid @using, EntityCoordinates clickLocation) { User = user; Using = @using; ClickLocation = clickLocation; } - public IEntity User { get; } - public IEntity Using { get; } + public EntityUid User { get; } + public EntityUid Using { get; } public EntityCoordinates ClickLocation { get; } } diff --git a/Content.Shared/Interaction/RotateToFaceSystem.cs b/Content.Shared/Interaction/RotateToFaceSystem.cs index 0905c21844..019ff49881 100644 --- a/Content.Shared/Interaction/RotateToFaceSystem.cs +++ b/Content.Shared/Interaction/RotateToFaceSystem.cs @@ -34,7 +34,7 @@ namespace Content.Shared.Interaction public class RotateToFaceSystem : EntitySystem { [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; - public bool TryFaceCoordinates(IEntity user, Vector2 coordinates) + public bool TryFaceCoordinates(EntityUid user, Vector2 coordinates) { var diff = coordinates - IoCManager.Resolve().GetComponent(user).MapPosition.Position; if (diff.LengthSquared <= 0.01f) @@ -43,7 +43,7 @@ namespace Content.Shared.Interaction return TryFaceAngle(user, diffAngle); } - public bool TryFaceAngle(IEntity user, Angle diffAngle) + public bool TryFaceAngle(EntityUid user, Angle diffAngle) { if (_actionBlockerSystem.CanChangeDirection(user)) { diff --git a/Content.Shared/Inventory/SharedInventoryComponent.cs b/Content.Shared/Inventory/SharedInventoryComponent.cs index 27733bb097..a49a2018d5 100644 --- a/Content.Shared/Inventory/SharedInventoryComponent.cs +++ b/Content.Shared/Inventory/SharedInventoryComponent.cs @@ -44,7 +44,7 @@ namespace Content.Shared.Inventory /// true if the item is equipped to an equip slot (NOT inside an equipped container /// like inside a backpack) - public abstract bool IsEquipped(IEntity item); + public abstract bool IsEquipped(EntityUid item); [Serializable, NetSerializable] protected class InventoryComponentState : ComponentState diff --git a/Content.Shared/Item/SharedItemComponent.cs b/Content.Shared/Item/SharedItemComponent.cs index 8414387d54..995ee70ff9 100644 --- a/Content.Shared/Item/SharedItemComponent.cs +++ b/Content.Shared/Item/SharedItemComponent.cs @@ -110,7 +110,7 @@ namespace Content.Shared.Item /// /// If a player can pick up this item. /// - public bool CanPickup(IEntity user, bool popup = true) + public bool CanPickup(EntityUid user, bool popup = true) { if (!EntitySystem.Get().CanPickup(user)) return false; diff --git a/Content.Shared/MobState/MobStateChangedMessage.cs b/Content.Shared/MobState/MobStateChangedMessage.cs index 5ac381fa77..b6d6ae71ff 100644 --- a/Content.Shared/MobState/MobStateChangedMessage.cs +++ b/Content.Shared/MobState/MobStateChangedMessage.cs @@ -18,7 +18,7 @@ namespace Content.Shared.MobState CurrentMobState = currentMobState; } - public IEntity Entity => Component.Owner; + public EntityUid Entity => Component.Owner; public MobStateComponent Component { get; } diff --git a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs index 0ba4ab2f06..07fc45be59 100644 --- a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs +++ b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs @@ -14,7 +14,7 @@ namespace Content.Shared.Movement.Components public static class GravityExtensions { - public static bool IsWeightless(this IEntity entity, PhysicsComponent? body = null, EntityCoordinates? coords = null, IMapManager? mapManager = null, IEntityManager? entityManager = null) + public static bool IsWeightless(this EntityUid entity, PhysicsComponent? body = null, EntityCoordinates? coords = null, IMapManager? mapManager = null, IEntityManager? entityManager = null) { if (body == null) IoCManager.Resolve().TryGetComponent(entity, out body); diff --git a/Content.Shared/Movement/RelayMovementEntityEvent.cs b/Content.Shared/Movement/RelayMovementEntityEvent.cs index 79021d816f..ad8609aaf3 100644 --- a/Content.Shared/Movement/RelayMovementEntityEvent.cs +++ b/Content.Shared/Movement/RelayMovementEntityEvent.cs @@ -4,9 +4,9 @@ namespace Content.Shared.Movement { public sealed class RelayMovementEntityEvent : EntityEventArgs { - public IEntity Entity { get; } + public EntityUid Entity { get; } - public RelayMovementEntityEvent(IEntity entity) + public RelayMovementEntityEvent(EntityUid entity) { Entity = entity; } diff --git a/Content.Shared/Popups/SharedPopupExtensions.cs b/Content.Shared/Popups/SharedPopupExtensions.cs index e9eb7ffc88..26cec77eda 100644 --- a/Content.Shared/Popups/SharedPopupExtensions.cs +++ b/Content.Shared/Popups/SharedPopupExtensions.cs @@ -13,7 +13,7 @@ namespace Content.Shared.Popups /// The entity above which the message will appear. /// The entity that will see the message. /// The message to show. - public static void PopupMessage(this IEntity source, IEntity viewer, string message) + public static void PopupMessage(this EntityUid source, EntityUid viewer, string message) { var popupSystem = EntitySystem.Get(); @@ -25,7 +25,7 @@ namespace Content.Shared.Popups /// /// The entity that will see the message. /// The message to be seen. - public static void PopupMessage(this IEntity viewer, string message) + public static void PopupMessage(this EntityUid viewer, string message) { viewer.PopupMessage(viewer, message); } @@ -36,7 +36,7 @@ namespace Content.Shared.Popups /// Location on a grid that the message floats up from. /// The client attached entity that the message is being sent to. /// Text contents of the message. - public static void PopupMessage(this EntityCoordinates coordinates, IEntity viewer, string message) + public static void PopupMessage(this EntityCoordinates coordinates, EntityUid viewer, string message) { var popupSystem = EntitySystem.Get(); popupSystem.PopupCoordinates(message, coordinates, Filter.Entities(viewer)); @@ -49,7 +49,7 @@ namespace Content.Shared.Popups /// The client attached entity that the message is being sent to. /// /// Text contents of the message. - public static void PopupMessageCursor(this IEntity viewer, string message) + public static void PopupMessageCursor(this EntityUid viewer, string message) { var popupSystem = EntitySystem.Get(); popupSystem.PopupCursor(message, Filter.Entities(viewer)); diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index dad4b5c16d..ec95444c85 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -27,7 +27,7 @@ namespace Content.Shared.Pulling { [Dependency] private readonly ActionBlockerSystem _blocker = default!; - public bool CanPull(IEntity puller, IEntity pulled) + public bool CanPull(EntityUid puller, EntityUid pulled) { if (!IoCManager.Resolve().HasComponent(puller)) { @@ -73,7 +73,7 @@ namespace Content.Shared.Pulling return !startPull.Cancelled; } - public bool TogglePull(IEntity puller, SharedPullableComponent pullable) + public bool TogglePull(EntityUid puller, SharedPullableComponent pullable) { if (pullable.Puller == puller) { @@ -84,7 +84,7 @@ namespace Content.Shared.Pulling // -- Core attempted actions -- - public bool TryStopPull(SharedPullableComponent pullable, IEntity? user = null) + public bool TryStopPull(SharedPullableComponent pullable, EntityUid? user = null) { if (!pullable.BeingPulled) { @@ -100,13 +100,13 @@ namespace Content.Shared.Pulling return true; } - public bool TryStartPull(IEntity puller, IEntity pullable) + public bool TryStartPull(EntityUid puller, EntityUid pullable) { - if (!IoCManager.Resolve().TryGetComponent(puller, out var pullerComp)) + if (!EntityManager.TryGetComponent(puller, out var pullerComp)) { return false; } - if (!IoCManager.Resolve().TryGetComponent(pullable, out var pullableComp)) + if (!EntityManager.TryGetComponent(pullable, out var pullableComp)) { return false; } @@ -121,17 +121,17 @@ namespace Content.Shared.Pulling // Pulling a new object : Perform sanity checks. - if (!EntitySystem.Get().CanPull(puller.Owner, pullable.Owner)) + if (!CanPull(puller.Owner, pullable.Owner)) { return false; } - if (!IoCManager.Resolve().TryGetComponent(puller.Owner, out var pullerPhysics)) + if (!EntityManager.TryGetComponent(puller.Owner, out var pullerPhysics)) { return false; } - if (!IoCManager.Resolve().TryGetComponent(pullable.Owner, out var pullablePhysics)) + if (!EntityManager.TryGetComponent(pullable.Owner, out var pullablePhysics)) { return false; } @@ -143,7 +143,7 @@ namespace Content.Shared.Pulling var oldPullable = puller.Pulling; if (oldPullable != null) { - if (IoCManager.Resolve().TryGetComponent(oldPullable, out var oldPullableComp)) + if (EntityManager.TryGetComponent(oldPullable.Value, out var oldPullableComp)) { if (!TryStopPull(oldPullableComp)) { diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index cbb5e37701..aa2a64e8a3 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -30,7 +30,7 @@ namespace Content.Shared.Pulling /// /// A mapping of pullers to the entity that they are pulling. /// - private readonly Dictionary _pullers = + private readonly Dictionary _pullers = new(); private readonly HashSet _moving = new(); @@ -100,21 +100,21 @@ namespace Content.Shared.Pulling } // Raise a "you are being pulled" alert if the pulled entity has alerts. - private static void PullableHandlePullStarted(EntityUid uid, SharedPullableComponent component, PullStartedMessage args) + private void PullableHandlePullStarted(EntityUid uid, SharedPullableComponent component, PullStartedMessage args) { if (args.Pulled.Owner != uid) return; - if (IoCManager.Resolve().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts)) + if (EntityManager.TryGetComponent(component.Owner, out SharedAlertsComponent? alerts)) alerts.ShowAlert(AlertType.Pulled); } - private static void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args) + private void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args) { if (args.Pulled.Owner != uid) return; - if (IoCManager.Resolve().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts)) + if (EntityManager.TryGetComponent(component.Owner, out SharedAlertsComponent? alerts)) alerts.ClearAlert(AlertType.Pulled); } @@ -165,17 +165,17 @@ namespace Content.Shared.Pulling // The pulled object may have already been deleted. // TODO: Work out why. Monkey + meat spike is a good test for this, // assuming you're still pulling the monkey when it gets gibbed. - if ((!IoCManager.Resolve().EntityExists(pulled) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(pulled).EntityLifeStage) >= EntityLifeStage.Deleted) + if ((!EntityManager.EntityExists(pulled.Value) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(pulled.Value).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } - if (!IoCManager.Resolve().TryGetComponent(pulled, out IPhysBody? physics)) + if (!EntityManager.TryGetComponent(pulled.Value, out IPhysBody? physics)) { return; } - UpdatePulledRotation(puller, pulled); + UpdatePulledRotation(puller, pulled.Value); physics.WakeBody(); } @@ -183,16 +183,16 @@ namespace Content.Shared.Pulling // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. private void HandleContainerInsert(EntInsertedIntoContainerMessage message) { - if (IoCManager.Resolve().TryGetComponent(message.Entity, out SharedPullableComponent? pullable)) + if (EntityManager.TryGetComponent(message.Entity, out SharedPullableComponent? pullable)) { TryStopPull(pullable); } - if (IoCManager.Resolve().TryGetComponent(message.Entity, out SharedPullerComponent? puller)) + if (EntityManager.TryGetComponent(message.Entity, out SharedPullerComponent? puller)) { if (puller.Pulling == null) return; - if (!IoCManager.Resolve().TryGetComponent(puller.Pulling, out SharedPullableComponent? pulling)) + if (!EntityManager.TryGetComponent(puller.Pulling.Value, out SharedPullableComponent? pulling)) { return; } @@ -203,19 +203,17 @@ namespace Content.Shared.Pulling private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid) { - var player = session?.AttachedEntity; - - if (player == null) - { + if (session?.AttachedEntityUid == null) return false; - } + + var player = session.AttachedEntityUid.Value; if (!TryGetPulled(player, out var pulled)) { return false; } - if (!IoCManager.Resolve().TryGetComponent(pulled, out SharedPullableComponent? pullable)) + if (!EntityManager.TryGetComponent(pulled.Value, out SharedPullableComponent? pullable)) { return false; } @@ -225,32 +223,32 @@ namespace Content.Shared.Pulling return false; } - private void SetPuller(IEntity puller, IEntity pulled) + private void SetPuller(EntityUid puller, EntityUid pulled) { _pullers[puller] = pulled; } - private bool RemovePuller(IEntity puller) + private bool RemovePuller(EntityUid puller) { return _pullers.Remove(puller); } - public IEntity? GetPulled(IEntity by) + public EntityUid? GetPulled(EntityUid by) { return _pullers.GetValueOrDefault(by); } - public bool TryGetPulled(IEntity by, [NotNullWhen(true)] out IEntity? pulled) + public bool TryGetPulled(EntityUid by, [NotNullWhen(true)] out EntityUid? pulled) { return (pulled = GetPulled(by)) != null; } - public bool IsPulling(IEntity puller) + public bool IsPulling(EntityUid puller) { return _pullers.ContainsKey(puller); } - private void UpdatePulledRotation(IEntity puller, IEntity pulled) + private void UpdatePulledRotation(EntityUid puller, EntityUid pulled) { // TODO: update once ComponentReference works with directed event bus. if (!IoCManager.Resolve().TryGetComponent(pulled, out RotatableComponent? rotatable)) diff --git a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs b/Content.Shared/Random/Helpers/SharedEntityExtensions.cs index 9df605f7a7..cb83761d27 100644 --- a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs +++ b/Content.Shared/Random/Helpers/SharedEntityExtensions.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Random.Helpers { public static class SharedEntityExtensions { - public static void RandomOffset(this IEntity entity, float minX, float maxX, float minY, float maxY) + public static void RandomOffset(this EntityUid entity, float minX, float maxX, float minY, float maxY) { DebugTools.AssertNotNull(entity); DebugTools.Assert(minX <= maxX, $"Minimum X value ({minX}) must be smaller than or equal to the maximum X value ({maxX})"); @@ -23,7 +23,7 @@ namespace Content.Shared.Random.Helpers IoCManager.Resolve().GetComponent(entity).LocalPosition += offset; } - public static void RandomOffset(this IEntity entity, float min, float max) + public static void RandomOffset(this EntityUid entity, float min, float max) { DebugTools.AssertNotNull(entity); DebugTools.Assert(min <= max, $"Minimum value ({min}) must be smaller than or equal to the maximum value ({max})"); @@ -31,7 +31,7 @@ namespace Content.Shared.Random.Helpers entity.RandomOffset(min, max, min, max); } - public static void RandomOffset(this IEntity entity, float value) + public static void RandomOffset(this EntityUid entity, float value) { value = Math.Abs(value); entity.RandomOffset(-value, value); diff --git a/Content.Shared/Roles/JobSpecial.cs b/Content.Shared/Roles/JobSpecial.cs index 8ef76fda0f..54259e3058 100644 --- a/Content.Shared/Roles/JobSpecial.cs +++ b/Content.Shared/Roles/JobSpecial.cs @@ -9,6 +9,6 @@ namespace Content.Shared.Roles [ImplicitDataDefinitionForInheritors] public abstract class JobSpecial { - public abstract void AfterEquip(IEntity mob); + public abstract void AfterEquip(EntityUid mob); } } diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs index 4bc2559515..afa6cf25b2 100644 --- a/Content.Shared/Storage/SharedStorageComponent.cs +++ b/Content.Shared/Storage/SharedStorageComponent.cs @@ -18,14 +18,14 @@ namespace Content.Shared.Storage { public override string Name => "Storage"; - public abstract IReadOnlyList? StoredEntities { get; } + public abstract IReadOnlyList? StoredEntities { get; } /// /// Removes from the storage container and updates the stored value /// /// The entity to remove /// True if no longer in storage, false otherwise - public abstract bool Remove(IEntity entity); + public abstract bool Remove(EntityUid entity); bool IDraggable.CanDrop(CanDropEvent args) { diff --git a/Content.Shared/Strip/Components/SharedStrippableComponent.cs b/Content.Shared/Strip/Components/SharedStrippableComponent.cs index 76e32c87ab..165d693c1a 100644 --- a/Content.Shared/Strip/Components/SharedStrippableComponent.cs +++ b/Content.Shared/Strip/Components/SharedStrippableComponent.cs @@ -14,7 +14,7 @@ namespace Content.Shared.Strip.Components { public override string Name => "Strippable"; - public bool CanBeStripped(IEntity by) + public bool CanBeStripped(EntityUid by) { return by != Owner && IoCManager.Resolve().HasComponent(@by) diff --git a/Content.Shared/Tag/TagComponentExtensions.cs b/Content.Shared/Tag/TagComponentExtensions.cs index e39c470eab..b722b8699f 100644 --- a/Content.Shared/Tag/TagComponentExtensions.cs +++ b/Content.Shared/Tag/TagComponentExtensions.cs @@ -18,7 +18,7 @@ namespace Content.Shared.Tag /// /// Thrown if no exists with the given id. /// - public static bool AddTag(this IEntity entity, string id) + public static bool AddTag(this EntityUid entity, string id) { return entity.EnsureComponent(out TagComponent tagComponent) && tagComponent.AddTag(id); @@ -35,7 +35,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool AddTags(this IEntity entity, params string[] ids) + public static bool AddTags(this EntityUid entity, params string[] ids) { return entity.EnsureComponent(out TagComponent tagComponent) && tagComponent.AddTags(ids); @@ -52,7 +52,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool AddTags(this IEntity entity, IEnumerable ids) + public static bool AddTags(this EntityUid entity, IEnumerable ids) { return entity.EnsureComponent(out TagComponent tagComponent) && tagComponent.AddTags(ids); @@ -70,7 +70,7 @@ namespace Content.Shared.Tag /// /// Thrown if no exists with the given id. /// - public static bool TryAddTag(this IEntity entity, string id) + public static bool TryAddTag(this EntityUid entity, string id) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.AddTag(id); @@ -88,7 +88,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool TryAddTags(this IEntity entity, params string[] ids) + public static bool TryAddTags(this EntityUid entity, params string[] ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.AddTags(ids); @@ -106,7 +106,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool TryAddTags(this IEntity entity, IEnumerable ids) + public static bool TryAddTags(this EntityUid entity, IEnumerable ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.AddTags(ids); @@ -121,7 +121,7 @@ namespace Content.Shared.Tag /// /// Thrown if no exists with the given id. /// - public static bool HasTag(this IEntity entity, string id) + public static bool HasTag(this EntityUid entity, string id) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.HasTag(id); @@ -136,7 +136,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool HasAllTags(this IEntity entity, params string[] ids) + public static bool HasAllTags(this EntityUid entity, params string[] ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.HasAllTags(ids); @@ -151,7 +151,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool HasAllTags(this IEntity entity, IEnumerable ids) + public static bool HasAllTags(this EntityUid entity, IEnumerable ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.HasAllTags(ids); @@ -166,7 +166,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool HasAnyTag(this IEntity entity, params string[] ids) + public static bool HasAnyTag(this EntityUid entity, params string[] ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.HasAnyTag(ids); @@ -181,7 +181,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool HasAnyTag(this IEntity entity, IEnumerable ids) + public static bool HasAnyTag(this EntityUid entity, IEnumerable ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.HasAnyTag(ids); @@ -198,7 +198,7 @@ namespace Content.Shared.Tag /// /// Thrown if no exists with the given id. /// - public static bool RemoveTag(this IEntity entity, string id) + public static bool RemoveTag(this EntityUid entity, string id) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.RemoveTag(id); @@ -215,7 +215,7 @@ namespace Content.Shared.Tag /// Thrown if one of the ids represents an unregistered . /// /// - public static bool RemoveTags(this IEntity entity, params string[] ids) + public static bool RemoveTags(this EntityUid entity, params string[] ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.RemoveTags(ids); @@ -232,7 +232,7 @@ namespace Content.Shared.Tag /// /// Thrown if one of the ids represents an unregistered . /// - public static bool RemoveTags(this IEntity entity, IEnumerable ids) + public static bool RemoveTags(this EntityUid entity, IEnumerable ids) { return IoCManager.Resolve().TryGetComponent(entity, out TagComponent? tagComponent) && tagComponent.RemoveTags(ids); diff --git a/Content.Shared/Throwing/ThrowEvents.cs b/Content.Shared/Throwing/ThrowEvents.cs index 714ff3af7b..1142eceb07 100644 --- a/Content.Shared/Throwing/ThrowEvents.cs +++ b/Content.Shared/Throwing/ThrowEvents.cs @@ -13,19 +13,19 @@ namespace Content.Shared.Throwing /// /// The entity that threw . /// - public IEntity? User { get; } + public EntityUid? User { get; } /// /// The entity thrown by that hit /// - public IEntity Thrown { get; } + public EntityUid Thrown { get; } /// /// The entity hit with by /// - public IEntity Target { get; } + public EntityUid Target { get; } - public ThrowEvent(IEntity? user, IEntity thrown, IEntity target) + public ThrowEvent(EntityUid? user, EntityUid thrown, EntityUid target) { User = user; Thrown = thrown; @@ -38,7 +38,7 @@ namespace Content.Shared.Throwing /// public class ThrowHitByEvent : ThrowEvent { - public ThrowHitByEvent(IEntity? user, IEntity thrown, IEntity target) : base(user, thrown, target) + public ThrowHitByEvent(EntityUid? user, EntityUid thrown, EntityUid target) : base(user, thrown, target) { } } @@ -48,7 +48,7 @@ namespace Content.Shared.Throwing /// public class ThrowDoHitEvent : ThrowEvent { - public ThrowDoHitEvent(IEntity? user, IEntity thrown, IEntity target) : base(user, thrown, target) + public ThrowDoHitEvent(EntityUid? user, EntityUid thrown, EntityUid target) : base(user, thrown, target) { } } diff --git a/Content.Shared/Throwing/ThrownItemComponent.cs b/Content.Shared/Throwing/ThrownItemComponent.cs index 6a4e49cc28..404ee8e9f0 100644 --- a/Content.Shared/Throwing/ThrownItemComponent.cs +++ b/Content.Shared/Throwing/ThrownItemComponent.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Throwing { public override string Name => "ThrownItem"; - public IEntity? Thrower { get; set; } + public EntityUid? Thrower { get; set; } } [Serializable, NetSerializable] diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 4db15178ea..642f5f8662 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -136,7 +136,7 @@ namespace Content.Shared.Throwing /// /// Raises collision events on the thrown and target entities. /// - public void ThrowCollideInteraction(IEntity? user, IPhysBody thrown, IPhysBody target) + public void ThrowCollideInteraction(EntityUid? user, IPhysBody thrown, IPhysBody target) { if (user is not null) _adminLogSystem.Add(LogType.ThrowHit, LogImpact.Low, diff --git a/Content.Shared/Transform/TransformExtensions.cs b/Content.Shared/Transform/TransformExtensions.cs index c599cb25a6..a8a389234a 100644 --- a/Content.Shared/Transform/TransformExtensions.cs +++ b/Content.Shared/Transform/TransformExtensions.cs @@ -18,7 +18,7 @@ namespace Content.Shared.Transform transform.AttachParent(grandParent); } - public static void AttachToGrandparent(this IEntity entity) + public static void AttachToGrandparent(this EntityUid entity) { AttachToGrandparent(IoCManager.Resolve().GetComponent(entity)); } diff --git a/Content.Shared/Weapons/Melee/AttackEvent.cs b/Content.Shared/Weapons/Melee/AttackEvent.cs index c053694d46..dda7b419f8 100644 --- a/Content.Shared/Weapons/Melee/AttackEvent.cs +++ b/Content.Shared/Weapons/Melee/AttackEvent.cs @@ -12,12 +12,12 @@ namespace Content.Shared.Weapons.Melee /// /// Entity used to attack, for broadcast purposes. /// - public IEntity Used { get; } + public EntityUid Used { get; } /// /// Entity that triggered the attack. /// - public IEntity User { get; } + public EntityUid User { get; } /// /// The original location that was clicked by the user. @@ -32,9 +32,9 @@ namespace Content.Shared.Weapons.Melee /// /// Entity that was attacked. /// - public IEntity? TargetEntity { get; } + public EntityUid? TargetEntity { get; } - public ClickAttackEvent(IEntity used, IEntity user, EntityCoordinates clickLocation, EntityUid target = default) + public ClickAttackEvent(EntityUid used, EntityUid user, EntityCoordinates clickLocation, EntityUid target = default) { Used = used; User = user; @@ -54,19 +54,19 @@ namespace Content.Shared.Weapons.Melee /// /// Entity used to attack, for broadcast purposes. /// - public IEntity Used { get; } + public EntityUid Used { get; } /// /// Entity that triggered the attack. /// - public IEntity User { get; } + public EntityUid User { get; } /// /// The original location that was clicked by the user. /// public EntityCoordinates ClickLocation { get; } - public WideAttackEvent(IEntity used, IEntity user, EntityCoordinates clickLocation) + public WideAttackEvent(EntityUid used, EntityUid user, EntityCoordinates clickLocation) { Used = used; User = user; @@ -82,19 +82,19 @@ namespace Content.Shared.Weapons.Melee /// /// Entity used to attack, for broadcast purposes. /// - public IEntity Used { get; } + public EntityUid Used { get; } /// /// Entity that triggered the attack. /// - public IEntity User { get; } + public EntityUid User { get; } /// /// The original location that was clicked by the user. /// public EntityCoordinates ClickLocation { get; } - public AttackedEvent(IEntity used, IEntity user, EntityCoordinates clickLocation) + public AttackedEvent(EntityUid used, EntityUid user, EntityCoordinates clickLocation) { Used = used; User = user;