* 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>
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Content.Server.GameObjects.Components.Items.Storage;
|
|
using Content.Server.GameObjects.Components.Weapon;
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
using Content.Shared.GameObjects.EntitySystems;
|
|
using Robust.Server.GameObjects.EntitySystems;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Server.GameObjects.Components.Explosion
|
|
{
|
|
/// <summary>
|
|
/// When triggered will flash in an area around the object and destroy itself
|
|
/// </summary>
|
|
[RegisterComponent]
|
|
public class FlashExplosiveComponent : Component, ITimerTrigger, IDestroyAct
|
|
{
|
|
public override string Name => "FlashExplosive";
|
|
|
|
private float _range;
|
|
|
|
private float _duration;
|
|
|
|
private string _sound;
|
|
private bool _deleteOnFlash;
|
|
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|
{
|
|
base.ExposeData(serializer);
|
|
|
|
serializer.DataField(ref _range, "range", 7.0f);
|
|
serializer.DataField(ref _duration, "duration", 8.0f);
|
|
serializer.DataField(ref _sound, "sound", "/Audio/Effects/flash_bang.ogg");
|
|
serializer.DataField(ref _deleteOnFlash, "deleteOnFlash", true);
|
|
}
|
|
|
|
public bool Explode()
|
|
{
|
|
// If we're in a locker or whatever then can't flash anything
|
|
Owner.TryGetContainer(out var container);
|
|
if (container == null || !container.Owner.HasComponent<EntityStorageComponent>())
|
|
{
|
|
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
|
|
}
|
|
|
|
if (_sound != null)
|
|
{
|
|
EntitySystem.Get<AudioSystem>().PlayAtCoords(_sound, Owner.Transform.Coordinates);
|
|
}
|
|
|
|
if (_deleteOnFlash && !Owner.Deleted)
|
|
{
|
|
Owner.Delete();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool ITimerTrigger.Trigger(TimerTriggerEventArgs eventArgs)
|
|
{
|
|
return Explode();
|
|
}
|
|
|
|
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
|
{
|
|
Explode();
|
|
}
|
|
}
|
|
}
|