Re-organize all projects (#4166)
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Acts;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Explosion.Components
|
||||
{
|
||||
/// <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";
|
||||
|
||||
[DataField("range")]
|
||||
private float _range = 7.0f;
|
||||
[DataField("duration")]
|
||||
private float _duration = 8.0f;
|
||||
[DataField("sound")]
|
||||
private string _sound = "/Audio/Effects/flash_bang.ogg";
|
||||
[DataField("deleteOnFlash")]
|
||||
private bool _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)
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user