Refactored RoundEndSystem (2) (#6115)

* No RestartRound if round id changed

* Refactored RoundEndSystem

* Fix round end + add test
This commit is contained in:
wrexbe
2022-01-10 11:24:41 -08:00
committed by GitHub
parent 083f2d8acd
commit 76c6ee08e7
4 changed files with 188 additions and 82 deletions

View File

@@ -17,11 +17,12 @@ using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.Communications
{
[RegisterComponent]
public class CommunicationsConsoleComponent : SharedCommunicationsConsoleComponent
public class CommunicationsConsoleComponent : SharedCommunicationsConsoleComponent, IEntityEventSubscriber
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
@@ -42,10 +43,7 @@ namespace Content.Server.Communications
UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
}
RoundEndSystem.OnRoundEndCountdownStarted += UpdateBoundInterface;
RoundEndSystem.OnRoundEndCountdownCancelled += UpdateBoundInterface;
RoundEndSystem.OnRoundEndCountdownFinished += UpdateBoundInterface;
RoundEndSystem.OnCallCooldownEnded += UpdateBoundInterface;
_entityManager.EventBus.SubscribeEvent<RoundEndSystemChangedEvent>(EventSource.Local, this, (s) => UpdateBoundInterface());
}
protected override void Startup()
@@ -76,9 +74,7 @@ namespace Content.Server.Communications
protected override void OnRemove()
{
RoundEndSystem.OnRoundEndCountdownStarted -= UpdateBoundInterface;
RoundEndSystem.OnRoundEndCountdownCancelled -= UpdateBoundInterface;
RoundEndSystem.OnRoundEndCountdownFinished -= UpdateBoundInterface;
_entityManager.EventBus.UnsubscribeEvent<RoundEndSystemChangedEvent>(EventSource.Local, this);
base.OnRemove();
}