Slight trigger refactor (#4320)
* Trigger tweaks * Finish trigger refactor * Clusterflash too
This commit is contained in:
@@ -77,7 +77,6 @@ namespace Content.Client.Entry
|
|||||||
"CanSpill",
|
"CanSpill",
|
||||||
"SpeedLoader",
|
"SpeedLoader",
|
||||||
"Hitscan",
|
"Hitscan",
|
||||||
"ExplosiveProjectile",
|
|
||||||
"StunOnCollide",
|
"StunOnCollide",
|
||||||
"RandomPottedPlant",
|
"RandomPottedPlant",
|
||||||
"CommunicationsConsole",
|
"CommunicationsConsole",
|
||||||
@@ -96,8 +95,11 @@ namespace Content.Client.Entry
|
|||||||
"SecureEntityStorage",
|
"SecureEntityStorage",
|
||||||
"PresetIdCard",
|
"PresetIdCard",
|
||||||
"SolarControlConsole",
|
"SolarControlConsole",
|
||||||
"FlashExplosive",
|
"FlashOnTrigger",
|
||||||
"FlashAreaOnCollide",
|
"SoundOnTrigger",
|
||||||
|
"TriggerOnCollide",
|
||||||
|
"DeleteOnTrigger",
|
||||||
|
"ExplodeOnTrigger",
|
||||||
"Utensil",
|
"Utensil",
|
||||||
"UnarmedCombat",
|
"UnarmedCombat",
|
||||||
"TimedSpawner",
|
"TimedSpawner",
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ namespace Content.Server.Construction.Components
|
|||||||
otherPhysics.BodyType = physics.BodyType;
|
otherPhysics.BodyType = physics.BodyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.Delete();
|
Owner.QueueDelete();
|
||||||
|
|
||||||
foreach (var action in node.Actions)
|
foreach (var action in node.Actions)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Flash.Components;
|
||||||
using Content.Server.Throwing;
|
using Content.Server.Throwing;
|
||||||
using Content.Shared.Explosion;
|
using Content.Shared.Explosion;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -58,7 +59,8 @@ namespace Content.Server.Explosion.Components
|
|||||||
|
|
||||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
|
||||||
{
|
{
|
||||||
if (_grenadesContainer.ContainedEntities.Count >= _maxGrenades || !args.Using.HasComponent<FlashExplosiveComponent>())
|
if (_grenadesContainer.ContainedEntities.Count >= _maxGrenades ||
|
||||||
|
!args.Using.HasComponent<FlashOnTriggerComponent>())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_grenadesContainer.Insert(args.Using);
|
_grenadesContainer.Insert(args.Using);
|
||||||
@@ -70,7 +72,7 @@ namespace Content.Server.Explosion.Components
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
_grenadesContainer = ContainerHelpers.EnsureContainer<Container>(Owner, "cluster-flash");
|
_grenadesContainer = Owner.EnsureContainer<Container>("cluster-flash");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,10 +119,7 @@ namespace Content.Server.Explosion.Components
|
|||||||
if (grenade.Deleted)
|
if (grenade.Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (grenade.TryGetComponent(out OnUseTimerTriggerComponent? useTimer))
|
EntitySystem.Get<TriggerSystem>().Trigger(grenade, eventArgs.User);
|
||||||
{
|
|
||||||
useTimer.Trigger(eventArgs.User);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.Explosion.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Will delete the attached entity upon a <see cref="TriggerEvent"/>.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public class DeleteOnTriggerComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "DeleteOnTrigger";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.Explosion.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Explode using the entity's <see cref="ExplosiveComponent"/> if Triggered.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public class ExplodeOnTriggerComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "ExplodeOnTrigger";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
using Content.Shared.Acts;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
|
||||||
namespace Content.Server.Explosion.Components
|
namespace Content.Server.Explosion.Components
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies an explosion range should this entity be exploded.
|
||||||
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ExplosiveComponent : Component, ITimerTrigger, IDestroyAct
|
public class ExplosiveComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "Explosive";
|
public override string Name => "Explosive";
|
||||||
|
|
||||||
@@ -18,31 +20,6 @@ namespace Content.Server.Explosion.Components
|
|||||||
[DataField("flashRange")]
|
[DataField("flashRange")]
|
||||||
public int FlashRange;
|
public int FlashRange;
|
||||||
|
|
||||||
public bool Exploding { get; private set; } = false;
|
public bool Exploding { get; set; } = false;
|
||||||
|
|
||||||
public bool Explosion()
|
|
||||||
{
|
|
||||||
if (Exploding)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Exploding = true;
|
|
||||||
Owner.SpawnExplosion(DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
|
|
||||||
Owner.QueueDelete();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ITimerTrigger.Trigger(TimerTriggerEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
return Explosion();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
Explosion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Physics.Collision;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
|
|
||||||
namespace Content.Server.Explosion.Components
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
public class ExplosiveProjectileComponent : Component, IStartCollide
|
|
||||||
{
|
|
||||||
public override string Name => "ExplosiveProjectile";
|
|
||||||
|
|
||||||
protected override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
Owner.EnsureComponent<ExplosiveComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
|
|
||||||
{
|
|
||||||
if (Owner.TryGetComponent(out ExplosiveComponent? explosive))
|
|
||||||
{
|
|
||||||
explosive.Explosion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,13 @@ namespace Content.Server.Explosion.Components
|
|||||||
[DataField("delay")]
|
[DataField("delay")]
|
||||||
private float _delay = 0f;
|
private float _delay = 0f;
|
||||||
|
|
||||||
|
// TODO: Need to split this out so it's a generic "OnUseTimerTrigger" component.
|
||||||
public void Trigger(IEntity user)
|
public void Trigger(IEntity user)
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||||
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
|
appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
|
||||||
|
|
||||||
EntitySystem.Get<TriggerSystem>().HandleTimerTrigger(TimeSpan.FromSeconds(_delay), user, Owner);
|
EntitySystem.Get<TriggerSystem>().HandleTimerTrigger(TimeSpan.FromSeconds(_delay), Owner, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using Content.Shared.Sound;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Server.Explosion.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whenever a <see cref="TriggerEvent"/> is run play a sound in PVS range.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class SoundOnTriggerComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "SoundOnTrigger";
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("sound")]
|
||||||
|
public SoundSpecifier? Sound { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.Explosion.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class TriggerOnCollideComponent : Component
|
||||||
|
{
|
||||||
|
public override string Name => "TriggerOnCollide";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -274,10 +274,12 @@ namespace Content.Server.Explosion
|
|||||||
public static void SpawnExplosion(this IEntity entity, int devastationRange = 0, int heavyImpactRange = 0,
|
public static void SpawnExplosion(this IEntity entity, int devastationRange = 0, int heavyImpactRange = 0,
|
||||||
int lightImpactRange = 0, int flashRange = 0)
|
int lightImpactRange = 0, int flashRange = 0)
|
||||||
{
|
{
|
||||||
|
// TODO: Need to refactor this stufferino
|
||||||
|
|
||||||
// If you want to directly set off the explosive
|
// If you want to directly set off the explosive
|
||||||
if (!entity.Deleted && entity.TryGetComponent(out ExplosiveComponent? explosive) && !explosive.Exploding)
|
if (!entity.Deleted && entity.TryGetComponent(out ExplosiveComponent? explosive) && !explosive.Exploding)
|
||||||
{
|
{
|
||||||
explosive.Explosion();
|
EntitySystem.Get<TriggerSystem>().Explode(entity.Uid, explosive);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,53 +1,118 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using Content.Server.Explosion.Components;
|
||||||
|
using Content.Server.Flash.Components;
|
||||||
|
using Content.Shared.Acts;
|
||||||
|
using Content.Shared.Audio;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Server.Explosion
|
namespace Content.Server.Explosion
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This interface gives components behavior when being "triggered" by timer or other conditions
|
/// Raised whenever something is Triggered on the entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITimerTrigger
|
public class TriggerEvent : HandledEntityEventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
public IEntity Triggered { get; }
|
||||||
/// Called when one object is triggering some event
|
public IEntity? User { get; }
|
||||||
/// </summary>
|
|
||||||
bool Trigger(TimerTriggerEventArgs eventArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TimerTriggerEventArgs : EventArgs
|
public TriggerEvent(IEntity triggered, IEntity? user = null)
|
||||||
{
|
|
||||||
public TimerTriggerEventArgs(IEntity user, IEntity source)
|
|
||||||
{
|
{
|
||||||
|
Triggered = triggered;
|
||||||
User = user;
|
User = user;
|
||||||
Source = source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEntity User { get; set; }
|
|
||||||
public IEntity Source { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class TriggerSystem : EntitySystem
|
public sealed class TriggerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
public void HandleTimerTrigger(TimeSpan delay, IEntity user, IEntity trigger)
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<TriggerOnCollideComponent, StartCollideEvent>(HandleCollide);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DeleteOnTriggerComponent, TriggerEvent>(HandleDeleteTrigger);
|
||||||
|
SubscribeLocalEvent<SoundOnTriggerComponent, TriggerEvent>(HandleSoundTrigger);
|
||||||
|
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
|
||||||
|
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<ExplosiveComponent, DestructionEventArgs>(HandleDestruction);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Explosions
|
||||||
|
private void HandleDestruction(EntityUid uid, ExplosiveComponent component, DestructionEventArgs args)
|
||||||
|
{
|
||||||
|
Explode(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleExplodeTrigger(EntityUid uid, ExplodeOnTriggerComponent component, TriggerEvent args)
|
||||||
|
{
|
||||||
|
if (!ComponentManager.TryGetComponent(uid, out ExplosiveComponent? explosiveComponent)) return;
|
||||||
|
|
||||||
|
Explode(uid, explosiveComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// You really shouldn't call this directly (TODO Change that when ExplosionHelper gets changed).
|
||||||
|
public void Explode(EntityUid uid, ExplosiveComponent component)
|
||||||
|
{
|
||||||
|
if (component.Exploding)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.Exploding = true;
|
||||||
|
component.Owner.SpawnExplosion(component.DevastationRange, component.HeavyImpactRange, component.LightImpactRange, component.FlashRange);
|
||||||
|
EntityManager.QueueDeleteEntity(uid);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Flash
|
||||||
|
private void HandleFlashTrigger(EntityUid uid, FlashOnTriggerComponent component, TriggerEvent args)
|
||||||
|
{
|
||||||
|
if (component.Flashed) return;
|
||||||
|
|
||||||
|
FlashableComponent.FlashAreaHelper(component.Owner, component.Range, component.Duration);
|
||||||
|
component.Flashed = true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void HandleSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
|
||||||
|
{
|
||||||
|
if (component.Sound == null) return;
|
||||||
|
SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), AudioHelpers.WithVariation(0.01f));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
|
||||||
|
{
|
||||||
|
EntityManager.QueueDeleteEntity(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCollide(EntityUid uid, TriggerOnCollideComponent component, StartCollideEvent args)
|
||||||
|
{
|
||||||
|
Trigger(component.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Trigger(IEntity trigger, IEntity? user = null)
|
||||||
|
{
|
||||||
|
var triggerEvent = new TriggerEvent(trigger, user);
|
||||||
|
EntityManager.EventBus.RaiseLocalEvent(trigger.Uid, triggerEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleTimerTrigger(TimeSpan delay, IEntity triggered, IEntity? user = null)
|
||||||
|
{
|
||||||
|
if (delay.TotalSeconds <= 0)
|
||||||
|
{
|
||||||
|
Trigger(triggered, user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Timer.Spawn(delay, () =>
|
Timer.Spawn(delay, () =>
|
||||||
{
|
{
|
||||||
var timerTriggerEventArgs = new TimerTriggerEventArgs(user, trigger);
|
Trigger(triggered, user);
|
||||||
var timerTriggers = trigger.GetAllComponents<ITimerTrigger>().ToList();
|
|
||||||
|
|
||||||
foreach (var timerTrigger in timerTriggers)
|
|
||||||
{
|
|
||||||
if (timerTrigger.Trigger(timerTriggerEventArgs))
|
|
||||||
{
|
|
||||||
// If an IOnTimerTrigger returns a status completion we finish our trigger
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
|||||||
namespace Content.Server.Flash.Components
|
namespace Content.Server.Flash.Components
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Upon colliding with an object this will flash in an area around it
|
/// Upon being triggered will flash in an area around it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
internal sealed class FlashAreaOnCollide : Component
|
internal sealed class FlashOnTriggerComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "FlashAreaOnCollide";
|
public override string Name => "FlashOnTrigger";
|
||||||
|
|
||||||
[DataField("range")] internal float Range = 1.0f;
|
[DataField("range")] internal float Range = 1.0f;
|
||||||
[DataField("duration")] internal float Duration = 8.0f;
|
[DataField("duration")] internal float Duration = 8.0f;
|
||||||
@@ -3,14 +3,12 @@ using Content.Server.Stunnable.Components;
|
|||||||
using Content.Server.Weapon.Melee;
|
using Content.Server.Weapon.Melee;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Notification;
|
|
||||||
using Content.Shared.Notification.Managers;
|
using Content.Shared.Notification.Managers;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
namespace Content.Server.Flash
|
namespace Content.Server.Flash
|
||||||
@@ -26,15 +24,6 @@ namespace Content.Server.Flash
|
|||||||
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnUseInHand);
|
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnUseInHand);
|
||||||
|
|
||||||
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<FlashComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<FlashAreaOnCollide, StartCollideEvent>(HandleCollide);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleCollide(EntityUid uid, FlashAreaOnCollide component, StartCollideEvent args)
|
|
||||||
{
|
|
||||||
if (component.Flashed) return;
|
|
||||||
|
|
||||||
FlashableComponent.FlashAreaHelper(component.Owner, component.Range, component.Duration);
|
|
||||||
component.Flashed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
public void OnMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Camera;
|
using Content.Server.Camera;
|
||||||
using Content.Server.Projectiles.Components;
|
using Content.Server.Projectiles.Components;
|
||||||
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Damage.Components;
|
using Content.Shared.Damage.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -26,9 +27,13 @@ namespace Content.Server.Projectiles
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var otherEntity = args.OtherFixture.Body.Owner;
|
||||||
|
|
||||||
var coordinates = args.OtherFixture.Body.Owner.Transform.Coordinates;
|
var coordinates = args.OtherFixture.Body.Owner.Transform.Coordinates;
|
||||||
var playerFilter = Filter.Pvs(coordinates);
|
var playerFilter = Filter.Pvs(coordinates);
|
||||||
if (args.OtherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && component.SoundHitSpecies != null)
|
|
||||||
|
if (!otherEntity.Deleted &&
|
||||||
|
otherEntity.HasComponent<SharedBodyComponent>() && component.SoundHitSpecies != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(playerFilter, component.SoundHitSpecies, coordinates);
|
SoundSystem.Play(playerFilter, component.SoundHitSpecies, coordinates);
|
||||||
}
|
}
|
||||||
@@ -37,7 +42,7 @@ namespace Content.Server.Projectiles
|
|||||||
SoundSystem.Play(playerFilter, component.SoundHit, coordinates);
|
SoundSystem.Play(playerFilter, component.SoundHit, coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damage != null)
|
if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage))
|
||||||
{
|
{
|
||||||
EntityManager.TryGetEntity(component.Shooter, out var shooter);
|
EntityManager.TryGetEntity(component.Shooter, out var shooter);
|
||||||
|
|
||||||
@@ -50,7 +55,7 @@ namespace Content.Server.Projectiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Damaging it can delete it
|
// Damaging it can delete it
|
||||||
if (!args.OtherFixture.Body.Deleted && args.OtherFixture.Body.Owner.TryGetComponent(out CameraRecoilComponent? recoilComponent))
|
if (!otherEntity.Deleted && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent))
|
||||||
{
|
{
|
||||||
var direction = args.OurFixture.Body.LinearVelocity.Normalized;
|
var direction = args.OurFixture.Body.LinearVelocity.Normalized;
|
||||||
recoilComponent.Kick(direction);
|
recoilComponent.Kick(direction);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Content.Shared.Acts
|
|||||||
void OnDestroy(DestructionEventArgs eventArgs);
|
void OnDestroy(DestructionEventArgs eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DestructionEventArgs : EventArgs
|
public class DestructionEventArgs : EntityEventArgs
|
||||||
{
|
{
|
||||||
public IEntity Owner { get; set; } = default!;
|
public IEntity Owner { get; set; } = default!;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
heavyImpactRange: 2
|
heavyImpactRange: 2
|
||||||
lightImpactRange: 4
|
lightImpactRange: 4
|
||||||
flashRange: 7
|
flashRange: 7
|
||||||
|
- type: ExplodeOnTrigger
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
@@ -55,7 +56,12 @@
|
|||||||
- Belt
|
- Belt
|
||||||
- type: OnUseTimerTrigger
|
- type: OnUseTimerTrigger
|
||||||
delay: 3.5
|
delay: 3.5
|
||||||
- type: FlashExplosive
|
- type: FlashOnTrigger
|
||||||
|
range: 7
|
||||||
|
- type: SoundOnTrigger
|
||||||
|
sound:
|
||||||
|
path: "/Audio/Effects/flash_bang.ogg"
|
||||||
|
- type: DeleteOnTrigger
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
@@ -90,6 +96,7 @@
|
|||||||
heavyImpactRange: 3
|
heavyImpactRange: 3
|
||||||
lightImpactRange: 5
|
lightImpactRange: 5
|
||||||
flashRange: 10
|
flashRange: 10
|
||||||
|
- type: ExplodeOnTrigger
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
@@ -123,6 +130,7 @@
|
|||||||
devastationRange: 25
|
devastationRange: 25
|
||||||
heavyImpactRange: 25
|
heavyImpactRange: 25
|
||||||
flashRange: 50
|
flashRange: 50
|
||||||
|
- type: ExplodeOnTrigger
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
|
|||||||
@@ -39,8 +39,13 @@
|
|||||||
soundHit: /Audio/Weapons/Guns/Hits/snap.ogg
|
soundHit: /Audio/Weapons/Guns/Hits/snap.ogg
|
||||||
damages:
|
damages:
|
||||||
Piercing: 10
|
Piercing: 10
|
||||||
- type: FlashAreaOnCollide
|
- type: FlashOnTrigger
|
||||||
range: 1
|
range: 1
|
||||||
|
- type: SoundOnTrigger
|
||||||
|
sound:
|
||||||
|
path: "/Audio/Effects/flash_bang.ogg"
|
||||||
|
- type: TriggerOnCollide
|
||||||
|
- type: DeleteOnTrigger
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: BulletBaseHV
|
id: BulletBaseHV
|
||||||
@@ -151,7 +156,9 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
sprite: Objects/Weapons/Guns/Projectiles/rocket.rsi
|
sprite: Objects/Weapons/Guns/Projectiles/rocket.rsi
|
||||||
state: frag
|
state: frag
|
||||||
- type: ExplosiveProjectile
|
- type: ExplodeOnTrigger
|
||||||
|
- type: DeleteOnTrigger
|
||||||
|
- type: TriggerOnCollide
|
||||||
- type: Projectile
|
- type: Projectile
|
||||||
deleteOnCollide: false
|
deleteOnCollide: false
|
||||||
- type: Explosive
|
- type: Explosive
|
||||||
@@ -191,7 +198,9 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
sprite: Objects/Weapons/Guns/Projectiles/grenade.rsi
|
sprite: Objects/Weapons/Guns/Projectiles/grenade.rsi
|
||||||
state: grenade
|
state: grenade
|
||||||
- type: ExplosiveProjectile
|
- type: ExplodeOnTrigger
|
||||||
|
- type: DeleteOnTrigger
|
||||||
|
- type: TriggerOnCollide
|
||||||
- type: Projectile
|
- type: Projectile
|
||||||
deleteOnCollide: false
|
deleteOnCollide: false
|
||||||
- type: Explosive
|
- type: Explosive
|
||||||
@@ -213,8 +222,13 @@
|
|||||||
- type: Projectile
|
- type: Projectile
|
||||||
deleteOnCollide: false
|
deleteOnCollide: false
|
||||||
soundHit: /Audio/Effects/flash_bang.ogg
|
soundHit: /Audio/Effects/flash_bang.ogg
|
||||||
- type: FlashAreaOnCollide
|
- type: FlashOnTrigger
|
||||||
range: 7
|
range: 7
|
||||||
|
- type: SoundOnTrigger
|
||||||
|
sound:
|
||||||
|
path: "/Audio/Effects/flash_bang.ogg"
|
||||||
|
- type: TriggerOnCollide
|
||||||
|
- type: DeleteOnTrigger
|
||||||
|
|
||||||
# This is supposed to spawn shrapnel and stuff so uhh... TODO?
|
# This is supposed to spawn shrapnel and stuff so uhh... TODO?
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -227,7 +241,9 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
sprite: Objects/Weapons/Guns/Projectiles/grenade.rsi
|
sprite: Objects/Weapons/Guns/Projectiles/grenade.rsi
|
||||||
state: grenade
|
state: grenade
|
||||||
- type: ExplosiveProjectile
|
- type: ExplodeOnTrigger
|
||||||
|
- type: DeleteOnTrigger
|
||||||
|
- type: TriggerOnCollide
|
||||||
- type: Projectile
|
- type: Projectile
|
||||||
deleteOnCollide: false
|
deleteOnCollide: false
|
||||||
- type: Explosive
|
- type: Explosive
|
||||||
|
|||||||
Reference in New Issue
Block a user