diff --git a/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs index 0525ffaf5d..f793567e57 100644 --- a/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Client/GameObjects/Components/Mobs/BuckleComponent.cs @@ -1,6 +1,7 @@ -using Content.Client.GameObjects.Components.Strap; +using Content.Client.GameObjects.Components.Strap; using Content.Client.Interfaces.GameObjects.Components.Interaction; using Content.Shared.GameObjects.Components.Mobs; +using Robust.Client.GameObjects; using Robust.Shared.GameObjects; namespace Content.Client.GameObjects.Components.Mobs @@ -9,6 +10,9 @@ namespace Content.Client.GameObjects.Components.Mobs public class BuckleComponent : SharedBuckleComponent, IClientDraggable { private bool _buckled; + private int? _originalDrawDepth; + + protected override bool Buckled => _buckled; public override void HandleComponentState(ComponentState curState, ComponentState nextState) { @@ -18,9 +22,25 @@ namespace Content.Client.GameObjects.Components.Mobs } _buckled = buckle.Buckled; - } - protected override bool Buckled => _buckled; + if (!Owner.TryGetComponent(out SpriteComponent ownerSprite)) + { + return; + } + + if (_buckled && buckle.DrawDepth.HasValue) + { + _originalDrawDepth ??= ownerSprite.DrawDepth; + ownerSprite.DrawDepth = buckle.DrawDepth.Value; + return; + } + + if (!_buckled && _originalDrawDepth.HasValue) + { + ownerSprite.DrawDepth = _originalDrawDepth.Value; + _originalDrawDepth = null; + } + } bool IClientDraggable.ClientCanDropOn(CanDropEventArgs eventArgs) { diff --git a/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs b/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs index d70300e4a4..257489a3a2 100644 --- a/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs +++ b/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs @@ -1,6 +1,7 @@ using Content.Server.AI.Utility; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Utility; using Robust.Shared.Interfaces.GameObjects; diff --git a/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs b/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs index 54190e6e0b..cd6dacc616 100644 --- a/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs +++ b/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs @@ -1,6 +1,7 @@ using Content.Server.AI.Utility; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Utility; using Content.Shared.GameObjects.EntitySystems; @@ -29,7 +30,7 @@ namespace Content.Server.AI.Operators.Inventory { return Outcome.Success; } - + if (!InteractionChecks.InRangeUnobstructed(_owner, container.Owner.Transform.MapPosition, ignoredEnt: container.Owner)) { return Outcome.Failed; diff --git a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs index 01255d9470..a2998d4aaa 100644 --- a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs @@ -1,4 +1,5 @@ using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Utility; using Robust.Shared.Containers; diff --git a/Content.Server/AI/Operators/Inventory/UseItemInHandsOperator.cs b/Content.Server/AI/Operators/Inventory/UseItemInHandsOperator.cs index 3c678641ce..aaaab852f0 100644 --- a/Content.Server/AI/Operators/Inventory/UseItemInHandsOperator.cs +++ b/Content.Server/AI/Operators/Inventory/UseItemInHandsOperator.cs @@ -1,4 +1,5 @@ using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.AI.Operators.Inventory diff --git a/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs b/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs index d9bbd31e09..5af9ac5a79 100644 --- a/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs +++ b/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs @@ -1,6 +1,7 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Robust.Shared.Containers; namespace Content.Server.AI.Utility.Considerations.Containers diff --git a/Content.Server/AI/Utility/Considerations/Hands/TargetInOurHandsCon.cs b/Content.Server/AI/Utility/Considerations/Hands/TargetInOurHandsCon.cs index 6054e93373..72958d9d73 100644 --- a/Content.Server/AI/Utility/Considerations/Hands/TargetInOurHandsCon.cs +++ b/Content.Server/AI/Utility/Considerations/Hands/TargetInOurHandsCon.cs @@ -1,6 +1,7 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; namespace Content.Server.AI.Utility.Considerations.Hands { diff --git a/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInHandsCon.cs b/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInHandsCon.cs index ed0aea239b..7a75efe411 100644 --- a/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInHandsCon.cs +++ b/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInHandsCon.cs @@ -2,7 +2,7 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Hands; using Content.Server.AI.WorldState.States.Inventory; -using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; namespace Content.Server.AI.Utility.Considerations.Inventory { diff --git a/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs b/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs index a081f442a8..4d4e1b6970 100644 --- a/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs +++ b/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs @@ -1,7 +1,7 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; -using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; namespace Content.Server.AI.Utility.Considerations.Inventory { diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs index 60c6f1164b..9164111d01 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Content.Server.AI.Utility.Actions; using Content.Server.AI.Utility.Actions.Clothing.Head; @@ -6,7 +5,6 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.GameObjects; -using Content.Server.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Inventory; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head diff --git a/Content.Server/AI/WorldState/States/Inventory/LastOpenedStorageState.cs b/Content.Server/AI/WorldState/States/Inventory/LastOpenedStorageState.cs index 636cb8ea63..973faf3115 100644 --- a/Content.Server/AI/WorldState/States/Inventory/LastOpenedStorageState.cs +++ b/Content.Server/AI/WorldState/States/Inventory/LastOpenedStorageState.cs @@ -1,4 +1,5 @@ using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Robust.Shared.Interfaces.GameObjects; using Logger = Robust.Shared.Log.Logger; diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs index bfee177d69..a2be3e46f2 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Content.Server.AI.Utils; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Nutrition; using JetBrains.Annotations; diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs index e33bca5a0c..168f9c0897 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Content.Server.AI.Utils; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Nutrition; using JetBrains.Annotations; diff --git a/Content.Server/Chat/ChatCommands.cs b/Content.Server/Chat/ChatCommands.cs index 051c382bcf..5ff3828f58 100644 --- a/Content.Server/Chat/ChatCommands.cs +++ b/Content.Server/Chat/ChatCommands.cs @@ -12,6 +12,7 @@ using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using System.Linq; +using Content.Server.GameObjects.Components; namespace Content.Server.Chat { diff --git a/Content.Server/GameObjects/Components/Access/AccessReaderComponent.cs b/Content.Server/GameObjects/Components/Access/AccessReaderComponent.cs index 94f06bc4a2..9fffb5f77b 100644 --- a/Content.Server/GameObjects/Components/Access/AccessReaderComponent.cs +++ b/Content.Server/GameObjects/Components/Access/AccessReaderComponent.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces; using Content.Server.Interfaces.GameObjects; using Content.Shared.GameObjects.Components.Inventory; diff --git a/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs b/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs index 98ca521b45..3f12ad5f47 100644 --- a/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs +++ b/Content.Server/GameObjects/Components/Access/IdCardConsoleComponent.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces; diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs index 367181e6b0..85004d542c 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Sound; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.GameObjects.Components.Power; diff --git a/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs b/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs index 554a722311..5dab5960c2 100644 --- a/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs +++ b/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs @@ -1,3 +1,4 @@ +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Weapon; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs b/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs index d084fdf462..0bfe3b1c04 100644 --- a/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs @@ -1,7 +1,8 @@ +using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Robust.Server.GameObjects.Components.Container; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Network; using Robust.Shared.Localization; using Robust.Shared.Timers; using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines; diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index 6091c504dc..4c3b903490 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks.Dataflow; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces; using Content.Shared.GameObjects; using Content.Shared.GameObjects.EntitySystems; using Robust.Server.GameObjects.Components.Container; -using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs index df383f54fd..9082ef3b43 100644 --- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs @@ -4,9 +4,8 @@ using Robust.Shared.Utility; using System; using System.Collections.Generic; using System.Linq; -using Content.Server.GameObjects.EntitySystems; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.EntitySystems.Click; -using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; using Robust.Server.GameObjects; diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index a151639a78..d6923ef8b9 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -1,8 +1,6 @@ using Content.Server.GameObjects.Components.Power; -using Content.Server.GameObjects.Components.Sound; using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Interfaces.GameObjects.Components.Interaction; -using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components; @@ -19,7 +17,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; -using System; +using Content.Server.GameObjects.Components.Items.Storage; namespace Content.Server.GameObjects.Components.Interactable { diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 26d1498946..f9c67efebd 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -2,6 +2,7 @@ using System; using System.Runtime.Remoting; using Content.Server.GameObjects.Components.Chemistry; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces; diff --git a/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs b/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs index 5d0903eb6c..9b3055537c 100644 --- a/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs @@ -3,6 +3,8 @@ using Robust.Shared.Utility; using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces; using Content.Shared.GameObjects; diff --git a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs index 403ea6de74..86954b9edd 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs @@ -2,7 +2,6 @@ using System.Linq; using Content.Server.GameObjects.Components.Interactable; using Content.Server.GameObjects.Components.Items.Storage; -using Content.Server.GameObjects.Components.Sound; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components.Interactable; @@ -30,7 +29,7 @@ namespace Content.Server.GameObjects.Components [RegisterComponent] [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] - public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct + public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IActionBlocker { public override string Name => "EntityStorage"; @@ -40,13 +39,13 @@ namespace Content.Server.GameObjects.Components private TimeSpan _lastInternalOpenAttempt; [ViewVariables] - private int StorageCapacityMax; + private int _storageCapacityMax; [ViewVariables] - private bool IsCollidableWhenOpen; + private bool _isCollidableWhenOpen; [ViewVariables] - private Container Contents; + private Container _contents; [ViewVariables] - private IEntityQuery entityQuery; + private IEntityQuery _entityQuery; private bool _showContents; private bool _open; private bool _isWeldedShut; @@ -63,7 +62,7 @@ namespace Content.Server.GameObjects.Components set { _showContents = value; - Contents.ShowContents = _showContents; + _contents.ShowContents = _showContents; } } @@ -96,10 +95,10 @@ namespace Content.Server.GameObjects.Components public override void Initialize() { base.Initialize(); - Contents = ContainerManagerComponent.Ensure(nameof(EntityStorageComponent), Owner); - entityQuery = new IntersectingEntityQuery(Owner); + _contents = ContainerManagerComponent.Ensure(nameof(EntityStorageComponent), Owner); + _entityQuery = new IntersectingEntityQuery(Owner); - Contents.ShowContents = _showContents; + _contents.ShowContents = _showContents; if (Owner.TryGetComponent(out var placeableSurfaceComponent)) { @@ -112,8 +111,8 @@ namespace Content.Server.GameObjects.Components { base.ExposeData(serializer); - serializer.DataField(ref StorageCapacityMax, "Capacity", 30); - serializer.DataField(ref IsCollidableWhenOpen, "IsCollidableWhenOpen", false); + serializer.DataField(ref _storageCapacityMax, "Capacity", 30); + serializer.DataField(ref _isCollidableWhenOpen, "IsCollidableWhenOpen", false); serializer.DataField(ref _showContents, "showContents", false); serializer.DataField(ref _open, "open", false); serializer.DataField(this, a => a.IsWeldedShut, "IsWeldedShut", false); @@ -146,7 +145,7 @@ namespace Content.Server.GameObjects.Components private void CloseStorage() { Open = false; - var entities = Owner.EntityManager.GetEntities(entityQuery); + var entities = Owner.EntityManager.GetEntities(_entityQuery); var count = 0; foreach (var entity in entities) { @@ -163,7 +162,7 @@ namespace Content.Server.GameObjects.Components continue; } count++; - if (count >= StorageCapacityMax) + if (count >= _storageCapacityMax) { break; } @@ -180,12 +179,11 @@ namespace Content.Server.GameObjects.Components EmptyContents(); ModifyComponents(); EntitySystem.Get().PlayFromEntity("/Audio/Machines/closetopen.ogg", Owner); - } private void ModifyComponents() { - if (!IsCollidableWhenOpen && Owner.TryGetComponent(out var collidableComponent)) + if (!_isCollidableWhenOpen && Owner.TryGetComponent(out var collidableComponent)) { var physShape = collidableComponent.PhysicsShapes[0]; if (Open) @@ -242,7 +240,7 @@ namespace Content.Server.GameObjects.Components entity.Transform.WorldPosition += new Vector2(0, collidableComponent.WorldAABB.Top - entityCollidableComponent.WorldAABB.Top); } } - if (Contents.CanInsert(entity)) + if (_contents.CanInsert(entity)) { // Because Insert sets the local position to (0,0), and we want to keep the contents spread out, // we re-apply the world position after inserting. @@ -255,7 +253,7 @@ namespace Content.Server.GameObjects.Components { worldPos = entity.Transform.WorldPosition; } - Contents.Insert(entity); + _contents.Insert(entity); entity.Transform.WorldPosition = worldPos; if (entityCollidableComponent != null) { @@ -268,9 +266,9 @@ namespace Content.Server.GameObjects.Components private void EmptyContents() { - foreach (var contained in Contents.ContainedEntities.ToArray()) + foreach (var contained in _contents.ContainedEntities.ToArray()) { - if(Contents.Remove(contained)) + if(_contents.Remove(contained)) { if (contained.TryGetComponent(out var entityCollidableComponent)) { @@ -317,7 +315,7 @@ namespace Content.Server.GameObjects.Components /// public bool Remove(IEntity entity) { - return Contents.CanRemove(entity); + return _contents.CanRemove(entity); } /// @@ -330,7 +328,7 @@ namespace Content.Server.GameObjects.Components return true; } - return Contents.Insert(entity); + return _contents.Insert(entity); } /// @@ -341,12 +339,37 @@ namespace Content.Server.GameObjects.Components return true; } - if (Contents.ContainedEntities.Count >= StorageCapacityMax) + if (_contents.ContainedEntities.Count >= _storageCapacityMax) { return false; } - return Contents.CanInsert(entity); + return _contents.CanInsert(entity); + } + + bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) + { + + if (Open) + return false; + + if (!CanWeldShut) + return false; + + if (!eventArgs.Using.TryGetComponent(out WelderComponent tool)) + return false; + + if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Welding, 1f)) + return false; + + IsWeldedShut ^= true; + return true; + } + + void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs) + { + Open = true; + EmptyContents(); } [Verb] @@ -388,29 +411,5 @@ namespace Content.Server.GameObjects.Components data.Text = component.Open ? "Close" : "Open"; } - - public bool InteractUsing(InteractUsingEventArgs eventArgs) - { - - if (Open) - return false; - - if (!CanWeldShut) - return false; - - if (!eventArgs.Using.TryGetComponent(out WelderComponent tool)) - return false; - - if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Welding, 1f)) - return false; - - IsWeldedShut ^= true; - return true; - } - - public void OnDestroy(DestructionEventArgs eventArgs) - { - EmptyContents(); - } } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 6466f40237..0118b378fd 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -1,8 +1,5 @@ -using System; -using Content.Server.GameObjects.Components; -using Content.Server.GameObjects.Components.Destructible; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; -using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects; using Content.Server.Throw; using Content.Server.Utility; @@ -21,7 +18,7 @@ using Robust.Shared.Maths; using Robust.Shared.Random; using Robust.Shared.Serialization; -namespace Content.Server.GameObjects +namespace Content.Server.GameObjects.Components { [RegisterComponent] [ComponentReference(typeof(StoreableComponent))] diff --git a/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs index 7f25245112..af7e559ea0 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs @@ -1,7 +1,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization; -namespace Content.Server.GameObjects +namespace Content.Server.GameObjects.Components.Items.Storage { [RegisterComponent] public class StoreableComponent : Component diff --git a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs index 71ffa3aa01..b8a6401a6c 100644 --- a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs @@ -24,6 +24,7 @@ using Robust.Shared.Audio; using Content.Server.Interfaces.GameObjects; using Content.Server.Interfaces.Chat; using Content.Server.BodySystem; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Shared.BodySystem; using Robust.Shared.GameObjects.Systems; using Content.Server.GameObjects.Components.Power.ApcNetComponents; diff --git a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs index 509baf88b1..e8733b095b 100644 --- a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs @@ -1,6 +1,6 @@ #nullable enable +using System; using Content.Server.GameObjects.Components.Strap; -using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Mobs; @@ -10,9 +10,12 @@ using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Strap; using Content.Shared.GameObjects.EntitySystems; using Robust.Server.GameObjects; +using Robust.Server.GameObjects.EntitySystemMessages; using Robust.Server.GameObjects.EntitySystems; +using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -25,13 +28,35 @@ namespace Content.Server.GameObjects.Components.Mobs public class BuckleComponent : SharedBuckleComponent, IInteractHand, IDragDrop { #pragma warning disable 649 + [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystem = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IServerNotifyManager _notifyManager = default!; #pragma warning restore 649 - private StrapComponent? _buckledTo; + /// + /// The amount of space that this entity occupies in a . + /// private int _size; + /// + /// The range from which this entity can buckle to a . + /// + private float _range; + + /// + /// The amount of time that must pass for this entity to + /// be able to unbuckle after recently buckling. + /// + private TimeSpan _unbuckleDelay; + + /// + /// The time that this entity buckled at. + /// + private TimeSpan _buckleTime; + + private StrapComponent? _buckledTo; + [ViewVariables] public StrapComponent? BuckledTo { @@ -39,6 +64,7 @@ namespace Content.Server.GameObjects.Components.Mobs private set { _buckledTo = value; + _buckleTime = _gameTiming.CurTime; Dirty(); } } @@ -46,6 +72,8 @@ namespace Content.Server.GameObjects.Components.Mobs [ViewVariables] protected override bool Buckled => BuckledTo != null; + public bool ContainerChanged { get; private set; } + [ViewVariables] public int Size => _size; @@ -55,11 +83,35 @@ namespace Content.Server.GameObjects.Components.Mobs { status.ChangeStatusEffectIcon(StatusEffect.Buckled, Buckled - ? "/Textures/Interface/StatusEffects/Buckle/buckled.png" + ? BuckledTo!.BuckledIcon : "/Textures/Interface/StatusEffects/Buckle/unbuckled.png"); } } + private void ReAttach(StrapComponent strap) + { + var ownTransform = Owner.Transform; + var strapTransform = strap.Owner.Transform; + + ownTransform.GridPosition = strapTransform.GridPosition; + ownTransform.AttachParent(strapTransform); + + switch (strap.Position) + { + case StrapPosition.None: + ownTransform.WorldRotation = strapTransform.WorldRotation; + break; + case StrapPosition.Stand: + StandingStateHelper.Standing(Owner); + ownTransform.WorldRotation = strapTransform.WorldRotation; + break; + case StrapPosition.Down: + StandingStateHelper.Down(Owner); + ownTransform.WorldRotation = Angle.South; + break; + } + } + private bool TryBuckle(IEntity user, IEntity to) { if (user == null || user == to) @@ -74,30 +126,40 @@ namespace Content.Server.GameObjects.Components.Mobs return false; } - var strapPosition = Owner.Transform.MapPosition; - var range = SharedInteractionSystem.InteractionRange / 2; - - if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) + if (!to.TryGetComponent(out StrapComponent strap)) { - _notifyManager.PopupMessage(user, user, - Loc.GetString("You can't reach there!")); + _notifyManager.PopupMessage(Owner, user, + Loc.GetString(Owner == user + ? "You can't buckle yourself there!" + : "You can't buckle {0:them} there!", Owner)); return false; } - if (!user.TryGetComponent(out HandsComponent hands)) + var strapPosition = strap.Owner.Transform.MapPosition; + + if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range)) + { + return false; + } + + if (ContainerHelpers.TryGetContainer(Owner, out var ownerContainer)) + { + if (!ContainerHelpers.TryGetContainer(strap.Owner, out var strapContainer) || + ownerContainer != strapContainer) + { + _notifyManager.PopupMessage(strap.Owner, user, + Loc.GetString("You can't reach there!")); + return false; + } + } + + if (!user.HasComponent()) { _notifyManager.PopupMessage(user, user, Loc.GetString("You don't have hands!")); return false; } - if (hands.GetActiveHand != null) - { - _notifyManager.PopupMessage(user, user, - Loc.GetString("Your hand isn't free!")); - return false; - } - if (Buckled) { _notifyManager.PopupMessage(Owner, user, @@ -107,15 +169,6 @@ namespace Content.Server.GameObjects.Components.Mobs return false; } - if (!to.TryGetComponent(out StrapComponent strap)) - { - _notifyManager.PopupMessage(Owner, user, - Loc.GetString(Owner == user - ? "You can't buckle yourself there!" - : "You can't buckle {0:them} there!", Owner)); - return false; - } - var parent = to.Transform.Parent; while (parent != null) { @@ -152,34 +205,14 @@ namespace Content.Server.GameObjects.Components.Mobs return false; } - BuckledTo = strap; - if (Owner.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(BuckleVisuals.Buckled, true); } - var ownTransform = Owner.Transform; - var strapTransform = strap.Owner.Transform; - - ownTransform.GridPosition = strapTransform.GridPosition; - ownTransform.AttachParent(strapTransform); - - switch (strap.Position) - { - case StrapPosition.None: - ownTransform.WorldRotation = strapTransform.WorldRotation; - break; - case StrapPosition.Stand: - StandingStateHelper.Standing(Owner); - ownTransform.WorldRotation = strapTransform.WorldRotation; - break; - case StrapPosition.Down: - StandingStateHelper.Down(Owner); - ownTransform.WorldRotation = Angle.South; - break; - } + ReAttach(strap); + BuckledTo = strap; BuckleStatus(); return true; @@ -194,6 +227,11 @@ namespace Content.Server.GameObjects.Components.Mobs if (!force) { + if (_gameTiming.CurTime < _buckleTime + _unbuckleDelay) + { + return false; + } + if (!ActionBlockerSystem.CanInteract(user)) { _notifyManager.PopupMessage(user, user, @@ -202,11 +240,10 @@ namespace Content.Server.GameObjects.Components.Mobs } var strapPosition = Owner.Transform.MapPosition; - var range = SharedInteractionSystem.InteractionRange / 2; - if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) + if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range)) { - _notifyManager.PopupMessage(user, user, + _notifyManager.PopupMessage(Owner, user, Loc.GetString("You can't reach there!")); return false; } @@ -219,8 +256,12 @@ namespace Content.Server.GameObjects.Components.Mobs .PlayFromEntity(strap.UnbuckleSound, Owner); } - Owner.Transform.DetachParent(); - Owner.Transform.WorldRotation = BuckledTo.Owner.Transform.WorldRotation; + if (Owner.Transform.Parent == BuckledTo.Owner.Transform) + { + Owner.Transform.DetachParent(); + Owner.Transform.WorldRotation = BuckledTo.Owner.Transform.WorldRotation; + } + BuckledTo = null; if (Owner.TryGetComponent(out AppearanceComponent appearance)) @@ -249,18 +290,46 @@ namespace Content.Server.GameObjects.Components.Mobs public bool ToggleBuckle(IEntity user, IEntity to) { - if (BuckledTo == null) - { - return TryBuckle(user, to); - } - else if (BuckledTo.Owner == to) + if (BuckledTo?.Owner == to) { return TryUnbuckle(user); } - else + + return TryBuckle(user, to); + } + + private void InsertIntoContainer(ContainerModifiedMessage message) + { + if (message.Entity != Owner) { - return false; + return; } + + ContainerChanged = true; + } + + public void Update() + { + if (!ContainerChanged || BuckledTo == null) + { + return; + } + + var contained = ContainerHelpers.TryGetContainer(Owner, out var ownContainer); + var strapContained = ContainerHelpers.TryGetContainer(BuckledTo.Owner, out var strapContainer); + + if (contained != strapContained || ownContainer != strapContainer) + { + TryUnbuckle(Owner, true); + return; + } + + if (!contained && !strapContained) + { + ReAttach(BuckledTo); + } + + ContainerChanged = false; } public override void ExposeData(ObjectSerializer serializer) @@ -268,6 +337,20 @@ namespace Content.Server.GameObjects.Components.Mobs base.ExposeData(serializer); serializer.DataField(ref _size, "size", 100); + serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 2); + + var seconds = 0.25f; + serializer.DataField(ref seconds, "cooldown", 0.25f); + + _unbuckleDelay = TimeSpan.FromSeconds(seconds); + } + + public override void Initialize() + { + base.Initialize(); + + _entityManager.EventBus.SubscribeEvent(EventSource.Local, this, InsertIntoContainer); + _entityManager.EventBus.SubscribeEvent(EventSource.Local, this, InsertIntoContainer); } protected override void Startup() @@ -280,18 +363,32 @@ namespace Content.Server.GameObjects.Components.Mobs { base.OnRemove(); - if (BuckledTo != null && BuckledTo.Owner.TryGetComponent(out StrapComponent strap)) + _entityManager.EventBus.UnsubscribeEvents(this); + + if (BuckledTo != null && + BuckledTo.Owner.TryGetComponent(out StrapComponent strap)) { strap.Remove(this); } - BuckledTo = null; + TryUnbuckle(Owner, true); + + _buckleTime = default; BuckleStatus(); } public override ComponentState GetComponentState() { - return new BuckleComponentState(Buckled); + int? drawDepth = null; + + if (BuckledTo != null && + Owner.Transform.WorldRotation.GetCardinalDir() == Direction.North && + BuckledTo.Owner.TryGetComponent(out SpriteComponent strapSprite)) + { + drawDepth = strapSprite.DrawDepth - 1; + } + + return new BuckleComponentState(Buckled, drawDepth); } bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) diff --git a/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs b/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs index 5e754e5e63..760aea0caf 100644 --- a/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs @@ -1,9 +1,6 @@ -using System; -using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.GameObjects.Components.Inventory; using Robust.Shared.GameObjects; -using CannyFastMath; using Math = CannyFastMath.Math; -using MathF = CannyFastMath.MathF; namespace Content.Server.GameObjects { diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs index 1dae799af5..039e3ff759 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Content.Server.GameObjects.Components.Chemistry; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Utensil; using Content.Server.GameObjects.EntitySystems; using Content.Server.Utility; diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs index 572f1963c5..3c365de9ae 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Shared.GameObjects.Components.Nutrition; using Robust.Server.GameObjects; diff --git a/Content.Server/GameObjects/Components/PDA/PDAComponent.cs b/Content.Server/GameObjects/Components/PDA/PDAComponent.cs index c14cce399f..e91c4fac54 100644 --- a/Content.Server/GameObjects/Components/PDA/PDAComponent.cs +++ b/Content.Server/GameObjects/Components/PDA/PDAComponent.cs @@ -4,6 +4,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Access; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces; using Content.Server.Interfaces.PDA; diff --git a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs index ff1dec7e23..4c48cceddf 100644 --- a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs +++ b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs @@ -1,3 +1,4 @@ +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.Interfaces.GameObjects.Components.Interaction; using Content.Server.Interfaces.GameObjects; using Content.Shared.Audio; diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/BaseCharger.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/BaseCharger.cs index 543c14b698..9a8002681d 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/BaseCharger.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/BaseCharger.cs @@ -1,4 +1,5 @@ using System; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.Weapon.Ranged.Barrels; using Content.Server.GameObjects.EntitySystems; diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs index 01a468fc10..3d4a6e615b 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs @@ -1,4 +1,5 @@ using System; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.Sound; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/Components/Strap/StrapComponent.cs b/Content.Server/GameObjects/Components/Strap/StrapComponent.cs index 8c7671702b..c62c233b45 100644 --- a/Content.Server/GameObjects/Components/Strap/StrapComponent.cs +++ b/Content.Server/GameObjects/Components/Strap/StrapComponent.cs @@ -20,6 +20,7 @@ namespace Content.Server.GameObjects.Components.Strap private StrapPosition _position; private string _buckleSound; private string _unbuckleSound; + private string _buckledIcon; private int _rotation; private int _size; @@ -53,6 +54,12 @@ namespace Content.Server.GameObjects.Components.Strap [ViewVariables] public string UnbuckleSound => _unbuckleSound; + /// + /// The icon to be displayed as a status when buckled + /// + [ViewVariables] + public string BuckledIcon => _buckledIcon; + /// /// The angle in degrees to rotate the player by when they get strapped /// @@ -123,6 +130,7 @@ namespace Content.Server.GameObjects.Components.Strap serializer.DataField(ref _position, "position", StrapPosition.None); serializer.DataField(ref _buckleSound, "buckleSound", "/Audio/Effects/buckle.ogg"); serializer.DataField(ref _unbuckleSound, "unbuckleSound", "/Audio/Effects/unbuckle.ogg"); + serializer.DataField(ref _buckledIcon, "buckledIcon", "/Textures/Interface/StatusEffects/Buckle/buckled.png"); serializer.DataField(ref _rotation, "rotation", 0); var defaultSize = 100; @@ -154,6 +162,16 @@ namespace Content.Server.GameObjects.Components.Strap return new StrapComponentState(Position); } + bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) + { + if (!eventArgs.User.TryGetComponent(out BuckleComponent buckle)) + { + return false; + } + + return buckle.ToggleBuckle(eventArgs.User, Owner); + } + [Verb] private sealed class StrapVerb : Verb { @@ -206,15 +224,5 @@ namespace Content.Server.GameObjects.Components.Strap buckle.ToggleBuckle(user, component.Owner); } } - - bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) - { - if (!eventArgs.User.TryGetComponent(out BuckleComponent buckle)) - { - return false; - } - - return buckle.ToggleBuckle(eventArgs.User, Owner); - } } } diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs index 9d77629431..aa3f7335b8 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.EntitySystems.Click; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs index 2c733d186f..88cd3ab9f9 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Weapon.Ranged.Barrels; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs index 1f24d682fa..e1cfe71da7 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Weapon.Ranged.Barrels; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs index e44f6a560c..2a078a1ce9 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Weapon.Ranged.Barrels; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs index 9c0f1597dc..ac42c5cbf5 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Projectiles; using Content.Server.GameObjects.Components.Sound; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs index eaf2453ca5..9e358e61c0 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition; using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Interaction; diff --git a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs new file mode 100644 index 0000000000..133e8eb652 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs @@ -0,0 +1,34 @@ +using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.EntitySystems.Click; +using Robust.Server.GameObjects.EntitySystems; +using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Systems; + +namespace Content.Server.GameObjects.EntitySystems +{ + public class BuckleSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + EntityQuery = new TypeEntityQuery(typeof(BuckleComponent)); + + UpdatesAfter.Add(typeof(InteractionSystem)); + UpdatesAfter.Add(typeof(InputSystem)); + } + + public override void Update(float frameTime) + { + foreach (var entity in RelevantEntities) + { + if (!entity.TryGetComponent(out BuckleComponent buckle)) + { + continue; + } + + buckle.Update(); + } + } + } +} diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 15ec860880..1e2d95ae3c 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -11,10 +11,9 @@ using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Input; using JetBrains.Annotations; using Robust.Server.GameObjects; -using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.Player; +using Robust.Shared.Containers; using Robust.Shared.GameObjects; -using Robust.Shared.GameObjects.Components; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Interfaces.GameObjects; @@ -266,6 +265,19 @@ namespace Content.Server.GameObjects.EntitySystems.Click return; } + // In a container where the attacked entity is not the container's owner + if (ContainerHelpers.TryGetContainer(player, out var playerContainer) && + attacked != playerContainer.Owner) + { + // Either the attacked entity is null, not contained or in a different container + if (attacked == null || + !ContainerHelpers.TryGetContainer(attacked, out var attackedContainer) || + attackedContainer != playerContainer) + { + return; + } + } + // TODO: Check if client should be able to see that object to click on it in the first place // Clicked on empty space behavior, try using ranged attack diff --git a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs index 92963b3e77..e4a4393230 100644 --- a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components.Construction; using Content.Server.GameObjects.Components.Interactable; using Content.Server.GameObjects.Components.Stack; diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index 7cb3f9481c..3dd7f4a63c 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -1,7 +1,5 @@ using System.Linq; using Content.Server.GameObjects.Components.Stack; -using Content.Server.Interfaces; -using Content.Server.Interfaces.GameObjects; using Content.Server.Throw; using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.Input; @@ -10,7 +8,6 @@ using Robust.Server.GameObjects.EntitySystemMessages; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; @@ -20,6 +17,7 @@ using Robust.Shared.Players; using System; using Content.Shared.GameObjects.EntitySystems; using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.EntitySystems.Click; namespace Content.Server.Interfaces.GameObjects.Components.Interaction diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index bb1d181930..51b6fa4e32 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -1,6 +1,7 @@ #nullable enable using Content.Server.GameObjects; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Sound; diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 8dca1a22a1..4373fd9e51 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -4,13 +4,13 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components.Access; using Content.Server.GameObjects.Components.Markers; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Observer; using Content.Server.GameObjects.Components.PDA; using Content.Server.Interfaces.GameObjects.Components.Interaction; -using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems.AI.Pathfinding; using Content.Server.GameTicking.GamePresets; using Content.Server.Interfaces; @@ -23,7 +23,6 @@ using Content.Shared; using Content.Shared.Chat; using Content.Shared.GameObjects.Components.PDA; using Content.Shared.Jobs; -using Content.Shared.Physics; using Content.Shared.Preferences; using Prometheus; using Robust.Server.Interfaces; @@ -34,7 +33,6 @@ using Robust.Server.ServerStatus; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.GameObjects; -using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.GameObjects; diff --git a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs index 341106539f..b335f50f7c 100644 --- a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs +++ b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Content.Shared.GameObjects.EntitySystems; using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.EntitySystemMessages; diff --git a/Content.Server/PDA/PDAUplinkManager.cs b/Content.Server/PDA/PDAUplinkManager.cs index 56b673df12..b627b92f67 100644 --- a/Content.Server/PDA/PDAUplinkManager.cs +++ b/Content.Server/PDA/PDAUplinkManager.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects; +using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components.Mobs; using Content.Server.Interfaces.PDA; using Content.Shared.GameObjects.Components.PDA; diff --git a/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs b/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs index e475b01896..7cb6b760f7 100644 --- a/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs +++ b/Content.Shared/GameObjects/Components/Mobs/SharedBuckleComponent.cs @@ -31,12 +31,14 @@ namespace Content.Shared.GameObjects.Components.Mobs [Serializable, NetSerializable] protected sealed class BuckleComponentState : ComponentState { - public BuckleComponentState(bool buckled) : base(ContentNetIDs.BUCKLE) + public BuckleComponentState(bool buckled, int? drawDepth) : base(ContentNetIDs.BUCKLE) { Buckled = buckled; + DrawDepth = drawDepth; } public bool Buckled { get; } + public int? DrawDepth; } [Serializable, NetSerializable] diff --git a/Resources/Prototypes/Entities/Mobs/human.yml b/Resources/Prototypes/Entities/Mobs/human.yml index 320f593f64..1334d119cb 100644 --- a/Resources/Prototypes/Entities/Mobs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/human.yml @@ -254,4 +254,3 @@ - type: SpeciesVisualizer2D - type: HumanoidAppearance - \ No newline at end of file