Files
tbd-station-14/Content.Server/GameObjects/Components/Trigger/TimerTrigger/OnUseTimerTriggerComponent.cs
komunre 2172d00409 Clusterbang (#2712)
* Code is ready but item now spawning

* Prototype of SeveralExplosive component

* Remaked to FlashExplosiveComponent using

* Done. But i feel myself retarted

* Remaked. Looks good

* Full loaded prototype added

* Throwing in progress. Fatal error is here

* I forgot about shared

* Sloth refactor

* Delayed spawning and fix crashes

* Full clusterbang code.

* Removed useless variable and tuned delay

* Delete wrong  in CreamPiedComponent

* Now yaml is code quality followed

* Reworked to GetLevel with bugs

* Never forget resources, guys

* RoundToLevels added. Now it works.

* New textures and sloth refactor is returned

* Now it's TryGetComponent

* Visualizer maximum fix and look fix

* Logging and no max and min check

* Removed max grenades sending

* vizualizer is better now

* GrenadesMax removed

* grammar, checks, NextFloat and no more try catch

* Unused using removed

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-01-18 21:16:34 +11:00

43 lines
1.3 KiB
C#

#nullable enable
using System;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Trigger;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Trigger.TimerTrigger
{
[RegisterComponent]
public class OnUseTimerTriggerComponent : Component, IUse
{
public override string Name => "OnUseTimerTrigger";
private float _delay;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _delay, "delay", 0f);
}
public void Trigger(IEntity user)
{
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
EntitySystem.Get<TriggerSystem>().HandleTimerTrigger(TimeSpan.FromSeconds(_delay), user, Owner);
}
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
Trigger(eventArgs.User);
return true;
}
}
}