Change components to use timer component (#2426)

* Change components to use timer component

* Fix old usages of tokens
This commit is contained in:
DrSmugleaf
2020-10-30 05:02:49 +01:00
committed by GitHub
parent c86c378198
commit 37e97ca89f
24 changed files with 59 additions and 35 deletions

View File

@@ -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<PortalComponent>().ImmuneEntities.Add(entity);
Timer.Spawn(TimeSpan.FromSeconds(_individualPortalCooldown), () => ReleaseCooldown(entity));
Owner.SpawnTimer(TimeSpan.FromSeconds(_individualPortalCooldown), () => ReleaseCooldown(entity));
StartCooldown();
}

View File

@@ -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<AudioSystem>();
@@ -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();
}