Skip to content

Commit

Permalink
Merge pull request #92 from Voomra/dev/c4
Browse files Browse the repository at this point in the history
Изменения механики C4
  • Loading branch information
Lemirda authored May 11, 2024
2 parents 65305f5 + fb44189 commit 4b01c4e
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Content.Server/Sticky/Systems/StickySystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Content.Server.Popups;
using Content.Server.Sticky.Components;
using Content.Server.Sticky.Events;
using Content.Shared.Andromeda.Voomra.C4; //A-13 Detonation of C4 during detaching
using Content.Shared.DoAfter;
using Content.Shared.Explosion.Components; //A-13 Detonation of C4 during detaching
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Sticky;
Expand Down Expand Up @@ -133,6 +135,15 @@ private void StartUnsticking(EntityUid uid, EntityUid user, StickyComponent? com
return;

var delay = (float) component.UnstickDelay.TotalSeconds;

//A-13 Detonation of C4 during detaching start
if (TryComp<C4DetonationByUnstickComponent>(uid, out var c4Comp))
{
if (c4Comp.Detonation && TryComp<ActiveTimerTriggerComponent>(uid, out var activateComp))
activateComp.TimeRemaining = 0;
}
//A-13 Detonation of C4 during detaching end

if (delay > 0)
{
// show message to user
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Andromeda.Voomra.C4;

/// <summary>
/// A marker component for detonating C4 when trying to detach it
/// </summary>
/// <seealso cref="T:Content.Shared.Andromeda.Voomra.C4.C4DetonationByUnstickSystem"/>
[RegisterComponent, NetworkedComponent]
public sealed partial class C4DetonationByUnstickComponent : Component
{
/// <summary>
/// An alternative to the outdated <see cref="Robust.Shared.GameObjects.IComponent.Owner">IComponent.Owner</see>
/// </summary>
[ViewVariables]
public EntityUid Owner2 { get; set; } = EntityUid.Invalid;

/// <summary>
/// The detonation flag when trying to remove
/// </summary>
[ViewVariables]
public bool Detonation { get; set; } = false;
}
45 changes: 45 additions & 0 deletions Content.Shared/Andromeda/Voomra/C4/C4DetonationByUnstickSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Content.Shared.Verbs;

namespace Content.Shared.Andromeda.Voomra.C4;

/// <summary>
/// Detonation control system C4 when trying to detach it
/// </summary>
/// /// <seealso cref="T:Content.Shared.Andromeda.Voomra.C4.C4DetonationByUnstickComponent"/>
public sealed class C4DetonationByUnstickSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<C4DetonationByUnstickComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<C4DetonationByUnstickComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<C4DetonationByUnstickComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
}

private void OnComponentInit(EntityUid uid, C4DetonationByUnstickComponent component, ComponentInit args)
{
component.Owner2 = uid;
}

private void OnComponentRemove(EntityUid uid, C4DetonationByUnstickComponent component, ComponentRemove args)
{
component.Owner2 = EntityUid.Invalid;
}

private void OnGetAltVerbs(EntityUid uid, C4DetonationByUnstickComponent component, GetVerbsEvent<AlternativeVerb> args)
{
args.Verbs.Add(new AlternativeVerb
{
Text = Loc.GetString("verb-c4-detonation-by-unstick", ("status", component.Detonation
? Loc.GetString("verb-c4-detonation-by-unstick-status-on")
: Loc.GetString("verb-c4-detonation-by-unstick-status-off"))),
Act = () => DoAltVerbs(component)
});
}

private void DoAltVerbs(C4DetonationByUnstickComponent component)
{
component.Detonation = !component.Detonation;
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/Andromeda/c4-detonation-by-unstick.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
verb-c4-detonation-by-unstick = Детонация при попытке снятия: {$status}
verb-c4-detonation-by-unstick-status-off = ВЫКЛ
verb-c4-detonation-by-unstick-status-on = ВКЛ
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
- type: HolidayRsiSwap
sprite:
festive: Objects/Weapons/Bombs/c4gift.rsi
#A-13 Detonation of C4 during detaching start
- type: Sticky
unstickDelay: 10
- type: C4DetonationByUnstick
#A-13 Detonation of C4 during detaching end

- type: entity
name: seismic charge
Expand Down

0 comments on commit 4b01c4e

Please sign in to comment.