diff --git a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs index 7dca7c3467..04b6f11730 100644 --- a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs @@ -78,7 +78,6 @@ namespace Content.Client.GameObjects.EntitySystems if (weapon.Automatic || canFireSemi) { - Logger.Debug(IoCManager.Resolve().CurTick.ToString()); weapon.SyncFirePos(worldPos); } } diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs index ab265e3693..38410a58cb 100644 --- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs @@ -189,7 +189,7 @@ namespace Content.Server.GameObjects return null; } - public bool Drop(string slot, GridCoordinates coords) + public bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true) { if (!CanDrop(slot)) { @@ -204,7 +204,7 @@ namespace Content.Server.GameObjects return false; } - if (!_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) + if (doMobChecks && !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) return false; item.RemovedFromSlot(); @@ -216,7 +216,7 @@ namespace Content.Server.GameObjects return true; } - public bool Drop(IEntity entity, GridCoordinates coords) + public bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true) { if (entity == null) { @@ -229,10 +229,10 @@ namespace Content.Server.GameObjects throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity)); } - return Drop(slot, coords); + return Drop(slot, coords, doMobChecks); } - public bool Drop(string slot) + public bool Drop(string slot, bool doMobChecks = true) { if (!CanDrop(slot)) { @@ -242,7 +242,7 @@ namespace Content.Server.GameObjects var inventorySlot = hands[slot]; var item = inventorySlot.ContainedEntity.GetComponent(); - if (!_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) + if (doMobChecks && !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) return false; if (!inventorySlot.Remove(inventorySlot.ContainedEntity)) @@ -263,7 +263,7 @@ namespace Content.Server.GameObjects return true; } - public bool Drop(IEntity entity) + public bool Drop(IEntity entity, bool doMobChecks = true) { if (entity == null) { @@ -276,10 +276,10 @@ namespace Content.Server.GameObjects throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity)); } - return Drop(slot); + return Drop(slot, doMobChecks); } - public bool Drop(string slot, BaseContainer targetContainer) + public bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true) { if (slot == null) { @@ -296,8 +296,15 @@ namespace Content.Server.GameObjects return false; } + var inventorySlot = hands[slot]; var item = inventorySlot.ContainedEntity.GetComponent(); + + if (doMobChecks && !_entitySystemManager.GetEntitySystem().TryDroppedInteraction(Owner, item.Owner)) + { + return false; + } + if (!inventorySlot.CanRemove(inventorySlot.ContainedEntity)) { return false; @@ -324,7 +331,7 @@ namespace Content.Server.GameObjects return true; } - public bool Drop(IEntity entity, BaseContainer targetContainer) + public bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true) { if (entity == null) { @@ -337,7 +344,7 @@ namespace Content.Server.GameObjects throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity)); } - return Drop(slot, targetContainer); + return Drop(slot, targetContainer, doMobChecks); } /// diff --git a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs index b0a28c2c4d..4f9b1158fc 100644 --- a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -322,7 +322,7 @@ namespace Content.Server.GameObjects.Components.Instruments } else { - StandingStateHelper.DropAllItemsInHands(mob); + StandingStateHelper.DropAllItemsInHands(mob, false); } InstrumentPlayer = null; diff --git a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs index 0fff5a9ef3..ed558fc981 100644 --- a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs +++ b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs @@ -191,7 +191,7 @@ namespace Content.Server.GameObjects if(entity.TryGetComponent(out StunnableComponent stun)) stun.CancelAll(); - StandingStateHelper.Down(entity, playSound:false); + StandingStateHelper.Down(entity); if (entity.TryGetComponent(out CollidableComponent collidable)) { diff --git a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs index a4536c1c9d..b2d5085248 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -96,7 +96,7 @@ namespace Content.Server.GameObjects.Components.Mobs if (seconds <= 0f) return; - StandingStateHelper.DropAllItemsInHands(Owner); + StandingStateHelper.DropAllItemsInHands(Owner, false); _stunnedTimer = seconds; _lastStun = _gameTiming.CurTime; diff --git a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs index 27a11740f7..14d6225851 100644 --- a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs +++ b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs @@ -80,13 +80,15 @@ namespace Content.Server.Interfaces.GameObjects /// Drops the item contained in the slot to the same position as our entity. /// /// The slot of which to drop to drop the item. + /// Whether to check the for the mob or not. /// True on success, false if something blocked the drop. - bool Drop(string slot); + bool Drop(string slot, bool doMobChecks = true); /// /// Drops an item held by one of our hand slots to the same position as our owning entity. /// /// The item to drop. + /// Whether to check the for the mob or not. /// True on success, false if something blocked the drop. /// /// Thrown if is null. @@ -94,15 +96,16 @@ namespace Content.Server.Interfaces.GameObjects /// /// Thrown if is not actually held in any hand. /// - bool Drop(IEntity entity); + bool Drop(IEntity entity, bool doMobChecks = true); /// /// Drops the item in a slot. /// /// The slot to drop the item from. /// + /// Whether to check the for the mob or not. /// True if an item was dropped, false otherwise. - bool Drop(string slot, GridCoordinates coords); + bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true); /// /// Drop the specified entity in our hands to a certain position. @@ -113,6 +116,7 @@ namespace Content.Server.Interfaces.GameObjects /// /// The entity to drop, must be held in one of the hands. /// The coordinates to drop the entity at. + /// Whether to check the for the mob or not. /// /// True if the drop succeeded, /// false if it failed (due to failing to eject from our hand slot, etc...) @@ -123,26 +127,28 @@ namespace Content.Server.Interfaces.GameObjects /// /// Thrown if is not actually held in any hand. /// - bool Drop(IEntity entity, GridCoordinates coords); + bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true); /// /// Drop the item contained in a slot into another container. /// /// The slot of which to drop the entity. /// The container to drop into. + /// Whether to check the for the mob or not. /// True on success, false if something was blocked (insertion or removal). /// /// Thrown if dry-run checks reported OK to remove and insert, /// but practical remove or insert returned false anyways. /// This is an edge-case that is currently unhandled. /// - bool Drop(string slot, BaseContainer targetContainer); + bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true); /// /// Drops an item in one of the hands into a container. /// /// The item to drop. /// The container to drop into. + /// Whether to check the for the mob or not. /// True on success, false if something was blocked (insertion or removal). /// /// Thrown if dry-run checks reported OK to remove and insert, @@ -155,7 +161,7 @@ namespace Content.Server.Interfaces.GameObjects /// /// Thrown if is not actually held in any hand. /// - bool Drop(IEntity entity, BaseContainer targetContainer); + bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true); /// /// Checks whether the item in the specified hand can be dropped. diff --git a/Content.Server/Mobs/StandingStateHelper.cs b/Content.Server/Mobs/StandingStateHelper.cs index 8fd677c66e..b386990308 100644 --- a/Content.Server/Mobs/StandingStateHelper.cs +++ b/Content.Server/Mobs/StandingStateHelper.cs @@ -38,7 +38,7 @@ namespace Content.Server.Mobs .PlayFromEntity(AudioHelpers.GetRandomFileFromSoundCollection("bodyfall"), entity, AudioHelpers.WithVariation(0.25f)); if(dropItems) - DropAllItemsInHands(entity); + DropAllItemsInHands(entity, false); return true; } @@ -61,13 +61,13 @@ namespace Content.Server.Mobs return true; } - public static void DropAllItemsInHands(IEntity entity) + public static void DropAllItemsInHands(IEntity entity, bool doMobChecks = true) { if (!entity.TryGetComponent(out IHandsComponent hands)) return; foreach (var heldItem in hands.GetAllHeldItems()) { - hands.Drop(heldItem.Owner); + hands.Drop(heldItem.Owner, doMobChecks); } } }