From 37e97ca89ff67ba818aca638a4eb93409873c615 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Fri, 30 Oct 2020 05:02:49 +0100 Subject: [PATCH] Change components to use timer component (#2426) * Change components to use timer component * Fix old usages of tokens --- .../Components/Instruments/InstrumentComponent.cs | 3 ++- .../Components/Sound/LoopingSoundComponent.cs | 3 ++- .../GameObjects/Components/Weapons/FlashableComponent.cs | 3 ++- .../GameObjects/EntitySystems/MeleeWeaponSystem.cs | 3 ++- .../GameObjects/Components/Atmos/FlammableComponent.cs | 3 ++- .../Components/Disposal/DisposalUnitComponent.cs | 7 ++++--- .../GameObjects/Components/Doors/AirlockComponent.cs | 3 ++- .../GameObjects/Components/Doors/ServerDoorComponent.cs | 9 +++++---- .../GameObjects/Components/Fluids/PuddleComponent.cs | 3 ++- .../Components/GUI/HumanInventoryControllerComponent.cs | 3 ++- .../GameObjects/Components/Kitchen/MicrowaveComponent.cs | 3 ++- .../Components/Markers/TimedSpawnerComponent.cs | 3 ++- .../GameObjects/Components/Mobs/MindComponent.cs | 3 ++- .../GameObjects/Components/Mobs/StunnableComponent.cs | 3 ++- .../GameObjects/Components/Portal/PortalComponent.cs | 7 ++++--- .../GameObjects/Components/Portal/TeleporterComponent.cs | 7 ++++--- .../Components/Projectiles/HitscanComponent.cs | 3 ++- .../Components/Projectiles/ThrownItemComponent.cs | 3 ++- .../GameObjects/Components/Research/LatheComponent.cs | 5 +++-- .../GameObjects/Components/Stack/StackComponent.cs | 3 ++- .../GameObjects/Components/Timing/UseDelayComponent.cs | 3 ++- .../VendingMachines/VendingMachineComponent.cs | 5 +++-- .../Components/Weapon/Melee/FlashComponent.cs | 3 ++- .../Components/Mobs/SharedStunnableComponent.cs | 3 ++- 24 files changed, 59 insertions(+), 35 deletions(-) diff --git a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs index ab86148401..0a0356c977 100644 --- a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Physics; using Robust.Client.Audio.Midi; using Robust.Shared.Audio.Midi; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -173,7 +174,7 @@ namespace Content.Client.GameObjects.Components.Instruments var renderer = _renderer; // We dispose of the synth two seconds from now to allow the last notes to stop from playing. - Timer.Spawn(2000, () => { renderer?.Dispose(); }); + Owner.SpawnTimer(2000, () => { renderer?.Dispose(); }); _renderer = null; _midiEventBuffer.Clear(); diff --git a/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs b/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs index 203cf70ef8..b2dec0fcbc 100644 --- a/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs +++ b/Content.Client/GameObjects/Components/Sound/LoopingSoundComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Sound; using Content.Shared.Physics; using Robust.Client.GameObjects.EntitySystems; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Random; @@ -53,7 +54,7 @@ namespace Content.Client.GameObjects.Components.Sound { if (!schedule.Play) return; - Timer.Spawn((int) schedule.Delay + (_random.Next((int) schedule.RandomDelay)),() => + Owner.SpawnTimer((int) schedule.Delay + (_random.Next((int) schedule.RandomDelay)),() => { if (!schedule.Play) return; // We make sure this hasn't changed. if (_audioSystem == null) _audioSystem = EntitySystem.Get(); diff --git a/Content.Client/GameObjects/Components/Weapons/FlashableComponent.cs b/Content.Client/GameObjects/Components/Weapons/FlashableComponent.cs index 5e8573034a..f990eb2b27 100644 --- a/Content.Client/GameObjects/Components/Weapons/FlashableComponent.cs +++ b/Content.Client/GameObjects/Components/Weapons/FlashableComponent.cs @@ -7,6 +7,7 @@ using Robust.Client.Interfaces.Graphics; using Robust.Client.Interfaces.Graphics.Overlays; using Robust.Client.Player; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Maths; @@ -83,7 +84,7 @@ namespace Content.Client.GameObjects.Components.Weapons } _cancelToken = new CancellationTokenSource(); - Timer.Spawn((int) duration * 1000, DisableOverlay, _cancelToken.Token); + Owner.SpawnTimer((int) duration * 1000, DisableOverlay, _cancelToken.Token); } private void DisableOverlay() diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index d2280535e7..806e122204 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Client.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.EntitySystemMessages; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Timing; @@ -95,7 +96,7 @@ namespace Content.Client.GameObjects.EntitySystems var newColor = Color.Red * originalColor; sprite.Color = newColor; - Timer.Spawn(100, () => + hitEntity.SpawnTimer(100, () => { // Only reset back to the original color if something else didn't change the color in the mean time. if (sprite.Color == newColor) diff --git a/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs b/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs index ae7be6c29b..6ca1388d84 100644 --- a/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/FlammableComponent.cs @@ -16,6 +16,7 @@ using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; @@ -205,7 +206,7 @@ namespace Content.Server.GameObjects.Components.Atmos Owner.PopupMessage(Loc.GetString("You stop, drop, and roll!")); stunnable.Paralyze(2f); - Timer.Spawn(2000, () => + Owner.SpawnTimer(2000, () => { _resisting = false; FireStacks -= 2f; diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs index bad4e0baaf..e0e1b7d7bb 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs @@ -29,6 +29,7 @@ using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; @@ -139,7 +140,7 @@ namespace Content.Server.GameObjects.Components.Disposal } - if (!entity.TryGetComponent(out IPhysicsComponent? physics) || + if (!entity.TryGetComponent(out IPhysicsComponent? physics) || !physics.CanCollide) { if (!(entity.TryGetComponent(out IDamageableComponent? damageState) && damageState.CurrentState == DamageState.Dead)) { @@ -165,7 +166,7 @@ namespace Content.Server.GameObjects.Components.Disposal _automaticEngageToken = new CancellationTokenSource(); - Timer.Spawn(_automaticEngageTime, () => + Owner.SpawnTimer(_automaticEngageTime, () => { if (!TryFlush()) { @@ -260,7 +261,7 @@ namespace Content.Server.GameObjects.Components.Disposal if (Engaged && CanFlush()) { - Timer.Spawn(_flushDelay, () => TryFlush()); + Owner.SpawnTimer(_flushDelay, () => TryFlush()); } } diff --git a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs index 9ec0148d28..6f0f536e2f 100644 --- a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs @@ -13,6 +13,7 @@ using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -310,7 +311,7 @@ namespace Content.Server.GameObjects.Components.Doors PowerWiresPulsed = true; _powerWiresPulsedTimerCancel.Cancel(); _powerWiresPulsedTimerCancel = new CancellationTokenSource(); - Timer.Spawn(PowerWiresTimeout, + Owner.SpawnTimer(PowerWiresTimeout, () => PowerWiresPulsed = false, _powerWiresPulsedTimerCancel.Token); break; diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index 2306b8e112..5033eea168 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -23,6 +23,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Maths; @@ -249,7 +250,7 @@ namespace Content.Server.GameObjects.Components.Doors occluder.Enabled = false; } - Timer.Spawn(OpenTimeOne, async () => + Owner.SpawnTimer(OpenTimeOne, async () => { if (Owner.TryGetComponent(out AirtightComponent? airtight)) { @@ -319,7 +320,7 @@ namespace Content.Server.GameObjects.Components.Doors stun.Paralyze(DoorStunTime); // If we hit someone, open up after stun (opens right when stun ends) - Timer.Spawn(TimeSpan.FromSeconds(DoorStunTime) - OpenTimeOne - OpenTimeTwo, Open); + Owner.SpawnTimer(TimeSpan.FromSeconds(DoorStunTime) - OpenTimeOne - OpenTimeTwo, Open); break; } } @@ -402,7 +403,7 @@ namespace Content.Server.GameObjects.Components.Doors occluder.Enabled = true; } - Timer.Spawn(CloseTimeOne, async () => + Owner.SpawnTimer(CloseTimeOne, async () => { if (shouldCheckCrush && _canCrush) { @@ -435,7 +436,7 @@ namespace Content.Server.GameObjects.Components.Doors return; SetAppearance(DoorVisualState.Deny); - Timer.Spawn(DenyTime, () => + Owner.SpawnTimer(DenyTime, () => { SetAppearance(DoorVisualState.Closed); }, _cancellationTokenSource.Token); diff --git a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs index 8f152debec..44a08acaca 100644 --- a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs @@ -14,6 +14,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; @@ -254,7 +255,7 @@ namespace Content.Server.GameObjects.Components.Fluids _evaporationToken = new CancellationTokenSource(); // KYS to evaporate - Timer.Spawn(TimeSpan.FromSeconds(_evaporateTime), Evaporate, _evaporationToken.Token); + Owner.SpawnTimer(TimeSpan.FromSeconds(_evaporateTime), Evaporate, _evaporationToken.Token); } private void UpdateSlip() diff --git a/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs b/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs index d5569f8092..dc7a2a69f5 100644 --- a/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HumanInventoryControllerComponent.cs @@ -1,6 +1,7 @@ using Content.Server.GameObjects.Components.Items.Storage; using Robust.Server.GameObjects.Components.Container; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Timers; @@ -67,7 +68,7 @@ namespace Content.Server.GameObjects.Components.GUI switch (message) { case ContainerContentsModifiedMessage contentsModified: - Timer.Spawn(0, DropIdAndPocketsIfWeNoLongerHaveAUniform); + Owner.SpawnTimer(0, DropIdAndPocketsIfWeNoLongerHaveAUniform); break; } } diff --git a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs index c8ef0f671d..7a665dde13 100644 --- a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs @@ -26,6 +26,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; @@ -312,7 +313,7 @@ namespace Content.Server.GameObjects.Components.Kitchen (_currentCookTimerTime == (uint)recipeToCook.CookTime); SetAppearance(MicrowaveVisualState.Cooking); _audioSystem.PlayFromEntity(_startCookingSound, Owner, AudioParams.Default); - Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => + Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => { if (_lostPower) { diff --git a/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs b/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs index a223349e16..323ffec02b 100644 --- a/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; @@ -67,7 +68,7 @@ namespace Content.Server.GameObjects.Components.Markers { TokenSource?.Cancel(); TokenSource = new CancellationTokenSource(); - Timer.SpawnRepeating(TimeSpan.FromSeconds(IntervalSeconds), OnTimerFired, TokenSource.Token); + Owner.SpawnRepeatingTimer(TimeSpan.FromSeconds(IntervalSeconds), OnTimerFired, TokenSource.Token); } private void OnTimerFired() diff --git a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs index 05c9ec8fbe..8ae15d2640 100644 --- a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.EntitySystems; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; @@ -135,7 +136,7 @@ namespace Content.Server.GameObjects.Components.Mobs else { var spawnPosition = Owner.Transform.Coordinates; - Timer.Spawn(0, () => + Owner.SpawnTimer(0, () => { // Async this so that we don't throw if the grid we're on is being deleted. var mapMan = IoCManager.Resolve(); diff --git a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs index 5b23d16e9c..1af15ecce2 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Interfaces.GameObjects.Components; using NFluidsynth; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -101,7 +102,7 @@ namespace Content.Server.GameObjects.Components.Mobs if (progress >= length) { - Timer.Spawn(250, () => status.RemoveStatusEffect(StatusEffect.Stun), StatusRemoveCancellation.Token); + Owner.SpawnTimer(250, () => status.RemoveStatusEffect(StatusEffect.Stun), StatusRemoveCancellation.Token); LastStun = null; } } diff --git a/Content.Server/GameObjects/Components/Portal/PortalComponent.cs b/Content.Server/GameObjects/Components/Portal/PortalComponent.cs index f177e5bd7a..8f352f83a4 100644 --- a/Content.Server/GameObjects/Components/Portal/PortalComponent.cs +++ b/Content.Server/GameObjects/Components/Portal/PortalComponent.cs @@ -6,6 +6,7 @@ using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Serialization; @@ -58,7 +59,7 @@ namespace Content.Server.GameObjects.Components.Portal if (_aliveTime > 0) { - Timer.Spawn(TimeSpan.FromSeconds(_aliveTime), () => Owner.Delete()); + Owner.SpawnTimer(TimeSpan.FromSeconds(_aliveTime), () => Owner.Delete()); } } @@ -138,7 +139,7 @@ namespace Content.Server.GameObjects.Components.Portal otherPortal.TryChangeState(PortalState.RecentlyTeleported); - Timer.Spawn(TimeSpan.FromSeconds(_overallPortalCooldown), () => + Owner.SpawnTimer(TimeSpan.FromSeconds(_overallPortalCooldown), () => { _onCooldown = false; TryChangeState(PortalState.Pending); @@ -168,7 +169,7 @@ namespace Content.Server.GameObjects.Components.Portal // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal ImmuneEntities.Add(entity); _connectingTeleporter.GetComponent().ImmuneEntities.Add(entity); - Timer.Spawn(TimeSpan.FromSeconds(_individualPortalCooldown), () => ReleaseCooldown(entity)); + Owner.SpawnTimer(TimeSpan.FromSeconds(_individualPortalCooldown), () => ReleaseCooldown(entity)); StartCooldown(); } diff --git a/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs b/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs index a704f7565f..cc0f0bf0c9 100644 --- a/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs +++ b/Content.Server/GameObjects/Components/Portal/TeleporterComponent.cs @@ -8,6 +8,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Random; @@ -125,14 +126,14 @@ namespace Content.Server.GameObjects.Components.Portal return; } - Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, mapCoords.Position)); + Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, mapCoords.Position)); StartCooldown(); } public void StartCooldown() { SetState(ItemTeleporterState.Cooldown); - Timer.Spawn(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off)); + Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off)); if (_cooldownSound != null) { var soundPlayer = EntitySystem.Get(); @@ -212,7 +213,7 @@ namespace Content.Server.GameObjects.Components.Portal } // Seemed easier to just start the cd timer at the same time - Timer.Spawn(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, targetVector)); + Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime), () => Teleport(user, targetVector)); StartCooldown(); } diff --git a/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs b/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs index 091b582574..1a30f4886a 100644 --- a/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs @@ -3,6 +3,7 @@ using Content.Shared.Damage; using Content.Shared.Physics; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.EntitySystemMessages; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; @@ -94,7 +95,7 @@ namespace Content.Server.GameObjects.Components.Projectiles EntitySystem.Get().PlayAtCoords(_soundHitWall, user.Transform.Coordinates.Offset(offset)); } - Timer.Spawn((int) _deathTime.TotalMilliseconds, () => + Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => { if (!Owner.Deleted) { diff --git a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs index 8dfe1f94c8..afcac3a7af 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Damage; using Content.Shared.Physics; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Physics; @@ -102,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Projectiles private void StartStopTimer() { - Timer.Spawn((int) (DefaultThrowTime * 1000), MaybeStopThrow); + Owner.SpawnTimer((int) (DefaultThrowTime * 1000), MaybeStopThrow); } private void MaybeStopThrow() diff --git a/Content.Server/GameObjects/Components/Research/LatheComponent.cs b/Content.Server/GameObjects/Components/Research/LatheComponent.cs index af846aa738..4021d45c03 100644 --- a/Content.Server/GameObjects/Components/Research/LatheComponent.cs +++ b/Content.Server/GameObjects/Components/Research/LatheComponent.cs @@ -16,6 +16,7 @@ using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Timers; using Robust.Shared.ViewVariables; @@ -124,7 +125,7 @@ namespace Content.Server.GameObjects.Components.Research State = LatheState.Producing; SetAppearance(LatheVisualState.Producing); - Timer.Spawn(recipe.CompleteTime, () => + Owner.SpawnTimer(recipe.CompleteTime, () => { Producing = false; _producingRecipe = null; @@ -195,7 +196,7 @@ namespace Content.Server.GameObjects.Components.Research break; } - Timer.Spawn(InsertionTime, () => + Owner.SpawnTimer(InsertionTime, () => { State = LatheState.Base; SetAppearance(LatheVisualState.Idle); diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs index dfb13c8ab8..fe202bdc02 100644 --- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs +++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -117,7 +118,7 @@ namespace Content.Server.GameObjects.Components.Stack if (stack.AvailableSpace == 0) { - Timer.Spawn(300, () => popupPos.PopupMessage(eventArgs.User, "Stack is now full.")); + Owner.SpawnTimer(300, () => popupPos.PopupMessage(eventArgs.User, "Stack is now full.")); } return true; diff --git a/Content.Server/GameObjects/Components/Timing/UseDelayComponent.cs b/Content.Server/GameObjects/Components/Timing/UseDelayComponent.cs index a5bdbcb6aa..2b20077cb1 100644 --- a/Content.Server/GameObjects/Components/Timing/UseDelayComponent.cs +++ b/Content.Server/GameObjects/Components/Timing/UseDelayComponent.cs @@ -2,6 +2,7 @@ using System.Threading; using Content.Shared.GameObjects.Components.Items; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Serialization; @@ -46,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Timing cancellationTokenSource = new CancellationTokenSource(); - Timer.Spawn(TimeSpan.FromSeconds(Delay), () => ActiveDelay = false, cancellationTokenSource.Token); + Owner.SpawnTimer(TimeSpan.FromSeconds(Delay), () => ActiveDelay = false, cancellationTokenSource.Token); _lastUseTime = IoCManager.Resolve().CurTime; diff --git a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs index c1d5dfc96a..138d88d667 100644 --- a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs @@ -14,6 +14,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; @@ -184,7 +185,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines UserInterface?.SendMessage(new VendingMachineInventoryMessage(Inventory)); TrySetVisualState(VendingMachineVisualState.Eject); - Timer.Spawn(_animationDuration, () => + Owner.SpawnTimer(_animationDuration, () => { _ejecting = false; TrySetVisualState(VendingMachineVisualState.Normal); @@ -198,7 +199,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines { TrySetVisualState(VendingMachineVisualState.Deny); //TODO: This duration should be a distinct value specific to the deny animation - Timer.Spawn(_animationDuration, () => + Owner.SpawnTimer(_animationDuration, () => { TrySetVisualState(VendingMachineVisualState.Normal); }); diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs index 3ab0b8c28a..8e7be3056f 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs @@ -8,6 +8,7 @@ using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; @@ -107,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee int animLayer = sprite.AddLayerWithState("flashing"); _flashing = true; - Timer.Spawn(400, () => + Owner.SpawnTimer(400, () => { sprite.RemoveLayer(animLayer); _flashing = false; diff --git a/Content.Shared/GameObjects/Components/Mobs/SharedStunnableComponent.cs b/Content.Shared/GameObjects/Components/Mobs/SharedStunnableComponent.cs index 79ca4dd46c..a347dbbccf 100644 --- a/Content.Shared/GameObjects/Components/Mobs/SharedStunnableComponent.cs +++ b/Content.Shared/GameObjects/Components/Mobs/SharedStunnableComponent.cs @@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components.Timers; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Serialization; @@ -225,7 +226,7 @@ namespace Content.Shared.GameObjects.Components.Mobs } _canHelp = false; - Timer.Spawn((int) _helpInterval * 1000, () => _canHelp = true); + Owner.SpawnTimer((int) _helpInterval * 1000, () => _canHelp = true); KnockdownTimer -= _helpKnockdownRemove;