* Update RobustToolbox * Transition direct type usages * More updates * Fix invalid use of to map * Update RobustToolbox * Fix dropping items * Rename name usages of "GridCoordinates" to "EntityCoordinates" * Revert "Update RobustToolbox" This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346. * Revert "Update RobustToolbox" This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09. # Conflicts: # RobustToolbox * Fix cursed IMapGrid method usage. * GridTileLookupTest now uses EntityCoordinates Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es>
69 lines
2.2 KiB
C#
69 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
|
|
ContainerHelpers.TryGetContainer(Owner, 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();
|
|
}
|
|
}
|
|
}
|