diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 044d6099d1..5c64a51d66 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -1,7 +1,8 @@ -using Content.Client.Construction; +using Content.Client.Construction; using Content.Client.DragDrop; using Content.Shared.Input; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.GameObjects; using Robust.Shared.Input; @@ -66,6 +67,9 @@ namespace Content.Client.Actions .BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(TargetingOnUse), typeof(ConstructionSystem), typeof(DragDropSystem)) .Register(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); } public override void Shutdown() diff --git a/Content.Client/Actions/ClientActionsComponent.cs b/Content.Client/Actions/ClientActionsComponent.cs index 7f1ccd4f8c..159c76500d 100644 --- a/Content.Client/Actions/ClientActionsComponent.cs +++ b/Content.Client/Actions/ClientActionsComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Client.Actions.Assignments; using Content.Client.Actions.UI; using Content.Client.Hands; @@ -51,20 +51,6 @@ namespace Content.Client.Actions PlayerDetached(); } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case PlayerAttachedMsg _: - PlayerAttached(); - break; - case PlayerDetachedMsg _: - PlayerDetached(); - break; - } - } - public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) { base.HandleComponentState(curState, nextState); @@ -77,7 +63,7 @@ namespace Content.Client.Actions UpdateUI(); } - private void PlayerAttached() + public void PlayerAttached() { if (!CurrentlyControlled || _ui != null) { @@ -89,7 +75,7 @@ namespace Content.Client.Actions UpdateUI(); } - private void PlayerDetached() + public void PlayerDetached() { if (_ui == null) return; IoCManager.Resolve().StateRoot.RemoveChild(_ui); diff --git a/Content.Client/Alerts/ClientAlertsComponent.cs b/Content.Client/Alerts/ClientAlertsComponent.cs index 13df9dca61..9032241797 100644 --- a/Content.Client/Alerts/ClientAlertsComponent.cs +++ b/Content.Client/Alerts/ClientAlertsComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Content.Client.Alerts.UI; using Content.Shared.Alert; @@ -41,20 +41,6 @@ namespace Content.Client.Alerts PlayerDetached(); } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - switch (message) - { - case PlayerAttachedMsg _: - PlayerAttached(); - break; - case PlayerDetachedMsg _: - PlayerDetached(); - break; - } - } - public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) { base.HandleComponentState(curState, nextState); @@ -67,7 +53,7 @@ namespace Content.Client.Alerts UpdateAlertsControls(); } - private void PlayerAttached() + public void PlayerAttached() { if (!CurrentlyControlled || _ui != null) { @@ -86,7 +72,7 @@ namespace Content.Client.Alerts UpdateAlertsControls(); } - private void PlayerDetached() + public void PlayerDetached() { foreach (var alertControl in _alertControls.Values) { diff --git a/Content.Client/Alerts/ClientAlertsSystem.cs b/Content.Client/Alerts/ClientAlertsSystem.cs new file mode 100644 index 0000000000..19d266fbfe --- /dev/null +++ b/Content.Client/Alerts/ClientAlertsSystem.cs @@ -0,0 +1,16 @@ +using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; + +namespace Content.Client.Alerts +{ + internal class ClientAlertsSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); + } + } +} diff --git a/Content.Client/CharacterInterface/CharacterInterfaceComponent.cs b/Content.Client/CharacterInterface/CharacterInterfaceComponent.cs index 9e304defb2..d9ca6df367 100644 --- a/Content.Client/CharacterInterface/CharacterInterfaceComponent.cs +++ b/Content.Client/CharacterInterface/CharacterInterfaceComponent.cs @@ -76,39 +76,32 @@ namespace Content.Client.CharacterInterface inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null); } - public override void HandleMessage(ComponentMessage message, IComponent? component) + public void PlayerDetached() { - base.HandleMessage(message, component); - - switch (message) + if (Window != null) { - case PlayerAttachedMsg _: - if (Window != null) + _gameHud.CharacterButtonVisible = false; + Window.Close(); + } + } + + public void PlayerAttached() + { + if (Window != null) + { + _gameHud.CharacterButtonVisible = true; + + _gameHud.CharacterButtonToggled = b => + { + if (b) { - _gameHud.CharacterButtonVisible = true; - _gameHud.CharacterButtonToggled = b => - { - if (b) - { - Window.OpenCentered(); - } - else - { - Window.Close(); - } - }; + Window.OpenCentered(); } - - break; - - case PlayerDetachedMsg _: - if (Window != null) + else { - _gameHud.CharacterButtonVisible = false; Window.Close(); } - - break; + }; } } diff --git a/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs b/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs index f188120aa5..589b97bc3e 100644 --- a/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs +++ b/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs @@ -1,6 +1,7 @@ using Content.Client.HUD; using Content.Shared.Input; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.GameObjects; @@ -23,6 +24,9 @@ namespace Content.Client.CharacterInterface .Bind(ContentKeyFunctions.OpenCharacterMenu, InputCmdHandler.FromDelegate(s => HandleOpenCharacterMenu())) .Register(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); } public override void Shutdown() diff --git a/Content.Client/CombatMode/CombatModeComponent.cs b/Content.Client/CombatMode/CombatModeComponent.cs index 9ef65829e9..0cca02a5c0 100644 --- a/Content.Client/CombatMode/CombatModeComponent.cs +++ b/Content.Client/CombatMode/CombatModeComponent.cs @@ -1,4 +1,4 @@ -using Content.Client.HUD; +using Content.Client.HUD; using Content.Shared.CombatMode; using Content.Shared.Targeting; using Robust.Client.GameObjects; @@ -35,21 +35,12 @@ namespace Content.Client.CombatMode } } - public override void HandleMessage(ComponentMessage message, IComponent? component) + public void PlayerDetached() { _gameHud.CombatPanelVisible = false; } + + public void PlayerAttached() { - base.HandleMessage(message, component); - - switch (message) - { - case PlayerAttachedMsg _: - _gameHud.CombatPanelVisible = true; - UpdateHud(); - break; - - case PlayerDetachedMsg _: - _gameHud.CombatPanelVisible = false; - break; - } + _gameHud.CombatPanelVisible = true; + UpdateHud(); } private void UpdateHud() diff --git a/Content.Client/CombatMode/CombatModeSystem.cs b/Content.Client/CombatMode/CombatModeSystem.cs index f50c62d0db..26c27fd538 100644 --- a/Content.Client/CombatMode/CombatModeSystem.cs +++ b/Content.Client/CombatMode/CombatModeSystem.cs @@ -20,6 +20,9 @@ namespace Content.Client.CombatMode base.Initialize(); _gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged; + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); } public override void Shutdown() diff --git a/Content.Client/Hands/HandsComponent.cs b/Content.Client/Hands/HandsComponent.cs index f8f1ba0f64..8ce017b270 100644 --- a/Content.Client/Hands/HandsComponent.cs +++ b/Content.Client/Hands/HandsComponent.cs @@ -210,22 +210,6 @@ namespace Content.Client.Hands switch (message) { - case PlayerAttachedMsg _: - if (_gui == null) - { - _gui = new HandsGui(); - } - else - { - _gui.Parent?.RemoveChild(_gui); - } - - _gameHud.HandsContainer.AddChild(_gui); - _gui.UpdateHandIcons(); - break; - case PlayerDetachedMsg _: - _gui?.Parent?.RemoveChild(_gui); - break; case HandEnabledMsg msg: { var hand = GetHand(msg.Name); @@ -255,6 +239,23 @@ namespace Content.Client.Hands } } + public void PlayerDetached() { _gui?.Parent?.RemoveChild(_gui); } + + public void PlayerAttached() + { + if (_gui == null) + { + _gui = new HandsGui(); + } + else + { + _gui.Parent?.RemoveChild(_gui); + } + + _gameHud.HandsContainer.AddChild(_gui); + _gui.UpdateHandIcons(); + } + public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) { base.HandleNetworkMessage(message, netChannel, session); diff --git a/Content.Client/Hands/HandsSystem.cs b/Content.Client/Hands/HandsSystem.cs new file mode 100644 index 0000000000..d1e2520dfa --- /dev/null +++ b/Content.Client/Hands/HandsSystem.cs @@ -0,0 +1,16 @@ +using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; + +namespace Content.Client.Hands +{ + internal class HandsSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); + } + } +} diff --git a/Content.Client/Inventory/ClientInventoryComponent.cs b/Content.Client/Inventory/ClientInventoryComponent.cs index 7ac3a7135c..9b1059e53c 100644 --- a/Content.Client/Inventory/ClientInventoryComponent.cs +++ b/Content.Client/Inventory/ClientInventoryComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Client.Clothing; @@ -252,22 +252,16 @@ namespace Content.Client.Inventory SendNetworkMessage(new OpenSlotStorageUIMessage(slot)); } - public override void HandleMessage(ComponentMessage message, IComponent? component) + public void PlayerDetached() { - base.HandleMessage(message, component); + InterfaceController.PlayerDetached(); + _playerAttached = false; + } - switch (message) - { - case PlayerAttachedMsg _: - InterfaceController.PlayerAttached(); - _playerAttached = true; - break; - - case PlayerDetachedMsg _: - InterfaceController.PlayerDetached(); - _playerAttached = false; - break; - } + public void PlayerAttached() + { + InterfaceController.PlayerAttached(); + _playerAttached = true; } public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out IEntity? item) diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index 587614bc09..4a2d71e23b 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -1,7 +1,7 @@ using Content.Client.HUD; using Content.Shared.Input; using JetBrains.Annotations; -using Robust.Client.Player; +using Robust.Client.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Input.Binding; using Robust.Shared.IoC; @@ -12,7 +12,6 @@ namespace Content.Client.Inventory public sealed class ClientInventorySystem : EntitySystem { [Dependency] private readonly IGameHud _gameHud = default!; - [Dependency] private readonly IPlayerManager _playerManager = default!; public override void Initialize() { @@ -22,6 +21,9 @@ namespace Content.Client.Inventory .Bind(ContentKeyFunctions.OpenInventoryMenu, InputCmdHandler.FromDelegate(_ => HandleOpenInventoryMenu())) .Register(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); } public override void Shutdown() diff --git a/Content.Client/Suspicion/SuspicionRoleComponent.cs b/Content.Client/Suspicion/SuspicionRoleComponent.cs index 57301e15fb..cf4baf3c5b 100644 --- a/Content.Client/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Client/Suspicion/SuspicionRoleComponent.cs @@ -102,35 +102,29 @@ namespace Content.Client.Suspicion Allies.AddRange(state.Allies); } - public override void HandleMessage(ComponentMessage message, IComponent? component) + public void PlayerDetached() { - base.HandleMessage(message, component); + _gui?.Parent?.RemoveChild(_gui); + RemoveTraitorOverlay(); + } - switch (message) + public void PlayerAttached() + { + if (_gui == null) { - case PlayerAttachedMsg _: - if (_gui == null) - { - _gui = new SuspicionGui(); - } - else - { - _gui.Parent?.RemoveChild(_gui); - } + _gui = new SuspicionGui(); + } + else + { + _gui.Parent?.RemoveChild(_gui); + } - _gameHud.SuspicionContainer.AddChild(_gui); - _gui.UpdateLabel(); + _gameHud.SuspicionContainer.AddChild(_gui); + _gui.UpdateLabel(); - if (_antagonist ?? false) - { - AddTraitorOverlay(); - } - - break; - case PlayerDetachedMsg _: - _gui?.Parent?.RemoveChild(_gui); - RemoveTraitorOverlay(); - break; + if (_antagonist ?? false) + { + AddTraitorOverlay(); } } diff --git a/Content.Client/Suspicion/SuspicionRoleSystem.cs b/Content.Client/Suspicion/SuspicionRoleSystem.cs new file mode 100644 index 0000000000..9f855cece5 --- /dev/null +++ b/Content.Client/Suspicion/SuspicionRoleSystem.cs @@ -0,0 +1,16 @@ +using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; + +namespace Content.Client.Suspicion +{ + class SuspicionRoleSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent((_, component, _) => component.PlayerAttached()); + SubscribeLocalEvent((_, component, _) => component.PlayerDetached()); + } + } +} diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index 9a0fc21502..032163788e 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -21,6 +21,7 @@ using Content.Shared.Configurable; using Content.Shared.Disposal.Components; using Content.Shared.DragDrop; using Content.Shared.Interaction; +using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 660baf69eb..4a29342918 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -5,6 +5,7 @@ using Content.Server.Anchor; using Content.Server.Disposal.Unit.Components; using Content.Shared.Acts; using Content.Shared.Disposal.Components; +using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Verbs; diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 4df838bd9a..be34120c28 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -18,6 +18,7 @@ using Content.Shared.Atmos; using Content.Shared.Disposal.Components; using Content.Shared.DragDrop; using Content.Shared.Interaction; +using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Throwing; diff --git a/Content.Server/Inventory/Components/HumanInventoryControllerComponent.cs b/Content.Server/Inventory/Components/HumanInventoryControllerComponent.cs index 609c2da8a5..4fa50d47e2 100644 --- a/Content.Server/Inventory/Components/HumanInventoryControllerComponent.cs +++ b/Content.Server/Inventory/Components/HumanInventoryControllerComponent.cs @@ -60,17 +60,7 @@ namespace Content.Server.Inventory.Components return flagsCheck; } - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - - switch (message) - { - case ContainerContentsModifiedMessage contentsModified: - Owner.SpawnTimer(0, DropIdAndPocketsIfWeNoLongerHaveAUniform); - break; - } - } + public void CheckUniformExists() { Owner.SpawnTimer(0, DropIdAndPocketsIfWeNoLongerHaveAUniform); } // Hey, it's descriptive. private void DropIdAndPocketsIfWeNoLongerHaveAUniform() diff --git a/Content.Server/Inventory/Components/InventoryComponent.cs b/Content.Server/Inventory/Components/InventoryComponent.cs index cddbd60f79..470fa84152 100644 --- a/Content.Server/Inventory/Components/InventoryComponent.cs +++ b/Content.Server/Inventory/Components/InventoryComponent.cs @@ -489,7 +489,7 @@ namespace Content.Server.Inventory.Components /// The underlying Container System just notified us that an entity was removed from it. /// We need to make sure we process that removed entity as being unequipped from the slot. /// - private void ForceUnequip(IContainer container, IEntity entity) + public void ForceUnequip(IContainer container, IEntity entity) { // make sure this is one of our containers. // Technically the correct way would be to enumerate the possible slot names @@ -572,23 +572,6 @@ namespace Content.Server.Inventory.Components } } - /// - public override void HandleMessage(ComponentMessage message, IComponent? component) - { - base.HandleMessage(message, component); - - switch (message) - { - case ContainerContentsModifiedMessage msg: - if (msg.Removed) - ForceUnequip(msg.Container, msg.Entity); - break; - - default: - break; - } - } - /// public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) diff --git a/Content.Server/Inventory/InventorySystem.cs b/Content.Server/Inventory/InventorySystem.cs new file mode 100644 index 0000000000..79f2767089 --- /dev/null +++ b/Content.Server/Inventory/InventorySystem.cs @@ -0,0 +1,27 @@ +using Content.Server.Inventory.Components; +using Robust.Shared.Containers; +using Robust.Shared.GameObjects; + +namespace Content.Server.Inventory +{ + class InventorySystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(HandleRemovedFromContainer); + SubscribeLocalEvent(HandleInvRemovedFromContainer); + } + + private static void HandleInvRemovedFromContainer(EntityUid uid, InventoryComponent component, EntRemovedFromContainerMessage args) + { + component.ForceUnequip(args.Container, args.Entity); + } + + private static void HandleRemovedFromContainer(EntityUid uid, HumanInventoryControllerComponent component, EntRemovedFromContainerMessage args) + { + component.CheckUniformExists(); + } + } +} diff --git a/Content.Server/Medical/Components/MedicalScannerComponent.cs b/Content.Server/Medical/Components/MedicalScannerComponent.cs index b6db43289d..1b067af2c2 100644 --- a/Content.Server/Medical/Components/MedicalScannerComponent.cs +++ b/Content.Server/Medical/Components/MedicalScannerComponent.cs @@ -14,6 +14,7 @@ using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.MedicalScanner; using Content.Shared.MobState; +using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Preferences; diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 2ce4ed45a5..60589c739b 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Acts; using Content.Shared.Body.Components; using Content.Shared.Interaction; using Content.Shared.Item; +using Content.Shared.Movement; using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Physics; diff --git a/Content.Server/Storage/Components/StorageCounterComponent.cs b/Content.Server/Storage/Components/StorageCounterComponent.cs index 7cf8b41e41..33f71d99c7 100644 --- a/Content.Server/Storage/Components/StorageCounterComponent.cs +++ b/Content.Server/Storage/Components/StorageCounterComponent.cs @@ -47,24 +47,17 @@ namespace Content.Server.Storage.Components } } - public override void HandleMessage(ComponentMessage message, IComponent? component) + public void ContainerUpdateAppearance(IContainer container) { - base.HandleMessage(message, component); + if(_appearanceComponent is null) + return; - if (_appearanceComponent != null) + var actual = Count(container.ContainedEntities); + _appearanceComponent.SetData(StackVisuals.Actual, actual); + + if (_maxAmount != null) { - switch (message) - { - case ContainerContentsModifiedMessage msg: - var actual = Count(msg.Container.ContainedEntities); - _appearanceComponent.SetData(StackVisuals.Actual, actual); - if (_maxAmount != null) - { - _appearanceComponent.SetData(StackVisuals.MaxCount, _maxAmount); - } - - break; - } + _appearanceComponent.SetData(StackVisuals.MaxCount, _maxAmount); } } diff --git a/Content.Server/Storage/StorageSystem.cs b/Content.Server/Storage/StorageSystem.cs index e0df9d95aa..73cf367254 100644 --- a/Content.Server/Storage/StorageSystem.cs +++ b/Content.Server/Storage/StorageSystem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Server.Interaction; using Content.Server.Storage.Components; using JetBrains.Annotations; @@ -39,6 +39,11 @@ namespace Content.Server.Storage { storageComp.HandleEntityMaybeRemoved(message); } + + if (oldParentEntity.TryGetComponent(out var newStorageComp)) + { + newStorageComp.ContainerUpdateAppearance(message.Container); + } } private static void HandleEntityInsertedIntoContainer(EntInsertedIntoContainerMessage message) @@ -49,6 +54,11 @@ namespace Content.Server.Storage { storageComp.HandleEntityMaybeInserted(message); } + + if (oldParentEntity.TryGetComponent(out var newStorageComp)) + { + newStorageComp.ContainerUpdateAppearance(message.Container); + } } private void CheckSubscribedEntities(ServerStorageComponent storageComp) diff --git a/Content.Server/Suspicion/EntitySystems/SuspicionRoleSystem.cs b/Content.Server/Suspicion/EntitySystems/SuspicionRoleSystem.cs index 2b923bc644..7cd2e2c292 100644 --- a/Content.Server/Suspicion/EntitySystems/SuspicionRoleSystem.cs +++ b/Content.Server/Suspicion/EntitySystems/SuspicionRoleSystem.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Shared.GameTicking; using JetBrains.Annotations; +using Robust.Server.GameObjects; using Robust.Shared.GameObjects; namespace Content.Server.Suspicion.EntitySystems @@ -12,6 +13,28 @@ namespace Content.Server.Suspicion.EntitySystems public IReadOnlyCollection Traitors => _traitors; + #region Overrides of EntitySystem + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent((HandlePlayerAttached)); + SubscribeLocalEvent((HandlePlayerDetached)); + } + + private void HandlePlayerDetached(EntityUid uid, SuspicionRoleComponent component, PlayerDetachedEvent args) + { + component.SyncRoles(); + } + + private void HandlePlayerAttached(EntityUid uid, SuspicionRoleComponent component, PlayerAttachedEvent args) + { + component.SyncRoles(); + } + + #endregion + public void AddTraitor(SuspicionRoleComponent role) { if (!_traitors.Add(role)) diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index 7181cc38e5..5ff64872a5 100644 --- a/Content.Server/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Server/Suspicion/SuspicionRoleComponent.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using System.Collections.Generic; using System.Linq; @@ -168,10 +168,6 @@ namespace Content.Server.Suspicion switch (message) { - case PlayerAttachedMsg: - case PlayerDetachedMsg: - SyncRoles(); - break; case RoleAddedMessage {Role: SuspicionRole role}: Role = role; break; diff --git a/Content.Shared/Movement/RelayMovementEntityMessage.cs b/Content.Shared/Movement/RelayMovementEntityMessage.cs new file mode 100644 index 0000000000..9c304d7cf3 --- /dev/null +++ b/Content.Shared/Movement/RelayMovementEntityMessage.cs @@ -0,0 +1,18 @@ +using System; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; + +namespace Content.Shared.Movement +{ + [Obsolete("Component Messages are deprecated, use Entity Events instead.")] + public class RelayMovementEntityMessage : ComponentMessage + { + [PublicAPI] + public readonly IEntity Entity; + + public RelayMovementEntityMessage(IEntity entity) + { + Entity = entity; + } + } +}