Adding shock collar and electropack (#30529)
* Adding shock collar with the new ShockOnTrigger * Cleaning and updating the shock collar * Add StripDelay datafield to ClothingComponent * Adding SelfUnremovableClothingComponent * ShockCollar Update * Correction of the shock collar * Correction of the shock collar 2 * Renaming the DamageSpecifier DataField to Damage * Fixing the damage field in ShockCollar * Cleaning the ShockCollar * Renaming ShockCollar to ClothingNeckShockCollar * Adding ClothingNeckShockCollar as a stealTarget to a thief * Fixing a typo of the sprite path in ClothingNeckShockCollar * Cleaning the ShockOnTriggerComponent * Revision of SelfUnremovableClothing * Adding a ClothingBackpackElectropack * Sprite fix * Code review * Shock Collar sprite update * add commit hash --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
|
||||
namespace Content.Server.Explosion.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component that electrocutes an entity having this component when a trigger is triggered.
|
||||
/// </summary>
|
||||
[RegisterComponent, AutoGenerateComponentPause]
|
||||
[Access(typeof(TriggerSystem))]
|
||||
public sealed partial class ShockOnTriggerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The force of an electric shock when the trigger is triggered.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int Damage = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Duration of electric shock when the trigger is triggered.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public TimeSpan Duration = TimeSpan.FromSeconds(2);
|
||||
|
||||
/// <summary>
|
||||
/// The minimum delay between repeating triggers.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public TimeSpan Cooldown = TimeSpan.FromSeconds(4);
|
||||
|
||||
/// <summary>
|
||||
/// When can the trigger run again?
|
||||
/// </summary>
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||
[AutoPausedField]
|
||||
public TimeSpan NextTrigger = TimeSpan.Zero;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Body.Systems;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.Flash;
|
||||
using Content.Server.Electrocution;
|
||||
using Content.Server.Pinpointer;
|
||||
using Content.Shared.Flash.Components;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
@@ -33,6 +34,7 @@ using Robust.Shared.Random;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.Coordinates;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Explosion.EntitySystems
|
||||
{
|
||||
@@ -75,6 +77,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly ElectrocutionSystem _electrocution = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -104,6 +107,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
|
||||
SubscribeLocalEvent<AnchorOnTriggerComponent, TriggerEvent>(OnAnchorTrigger);
|
||||
SubscribeLocalEvent<SoundOnTriggerComponent, TriggerEvent>(OnSoundTrigger);
|
||||
SubscribeLocalEvent<ShockOnTriggerComponent, TriggerEvent>(HandleShockTrigger);
|
||||
SubscribeLocalEvent<RattleComponent, TriggerEvent>(HandleRattleTrigger);
|
||||
}
|
||||
|
||||
@@ -120,6 +124,24 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleShockTrigger(Entity<ShockOnTriggerComponent> shockOnTrigger, ref TriggerEvent args)
|
||||
{
|
||||
if (!_container.TryGetContainingContainer(shockOnTrigger, out var container))
|
||||
return;
|
||||
|
||||
var containerEnt = container.Owner;
|
||||
var curTime = _timing.CurTime;
|
||||
|
||||
if (curTime < shockOnTrigger.Comp.NextTrigger)
|
||||
{
|
||||
// The trigger's on cooldown.
|
||||
return;
|
||||
}
|
||||
|
||||
_electrocution.TryDoElectrocution(containerEnt, null, shockOnTrigger.Comp.Damage, shockOnTrigger.Comp.Duration, true);
|
||||
shockOnTrigger.Comp.NextTrigger = curTime + shockOnTrigger.Comp.Cooldown;
|
||||
}
|
||||
|
||||
private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
Reference in New Issue
Block a user