Skip to content

Commit

Permalink
Merge pull request #102 from Voomra/dev/c4
Browse files Browse the repository at this point in the history
Dev/c4
  • Loading branch information
Lemirda authored May 13, 2024
2 parents 4b01c4e + 74d865b commit c059c2a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Content.Server/Sticky/Systems/StickySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Content.Shared.Sticky.Components;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Random; //A-13 Detonation of C4 during detaching
using Robust.Shared.Utility;

namespace Content.Server.Sticky.Systems;
Expand All @@ -22,6 +23,7 @@ public sealed class StickySystem : EntitySystem
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IRobustRandom _random = default!; //A-13 Detonation of C4 during detaching

private const string StickerSlotId = "stickers_container";

Expand Down Expand Up @@ -139,8 +141,12 @@ private void StartUnsticking(EntityUid uid, EntityUid user, StickyComponent? com
//A-13 Detonation of C4 during detaching start
if (TryComp<C4DetonationByUnstickComponent>(uid, out var c4Comp))
{
if (c4Comp.Detonation && TryComp<ActiveTimerTriggerComponent>(uid, out var activateComp))
if (c4Comp.Detonation
&& TryComp<ActiveTimerTriggerComponent>(uid, out var activateComp)
&& _random.NextFloat(0.0f, 1.0f) > 0.5f)
{
activateComp.TimeRemaining = 0;
}
}
//A-13 Detonation of C4 during detaching end

Expand Down
12 changes: 12 additions & 0 deletions Content.Shared/Andromeda/Voomra/C4/C4DetonationByUnstickSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Content.Shared.Examine;
using Content.Shared.Explosion.Components;
using Content.Shared.Verbs;

namespace Content.Shared.Andromeda.Voomra.C4;
Expand All @@ -15,6 +17,7 @@ public override void Initialize()
SubscribeLocalEvent<C4DetonationByUnstickComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<C4DetonationByUnstickComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<C4DetonationByUnstickComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
SubscribeLocalEvent<C4DetonationByUnstickComponent, ExaminedEvent>(OnExamined);
}

private void OnComponentInit(EntityUid uid, C4DetonationByUnstickComponent component, ComponentInit args)
Expand All @@ -29,6 +32,9 @@ private void OnComponentRemove(EntityUid uid, C4DetonationByUnstickComponent com

private void OnGetAltVerbs(EntityUid uid, C4DetonationByUnstickComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (HasComp<ActiveTimerTriggerComponent>(uid))
return;

args.Verbs.Add(new AlternativeVerb
{
Text = Loc.GetString("verb-c4-detonation-by-unstick", ("status", component.Detonation
Expand All @@ -42,4 +48,10 @@ private void DoAltVerbs(C4DetonationByUnstickComponent component)
{
component.Detonation = !component.Detonation;
}

private void OnExamined(EntityUid uid, C4DetonationByUnstickComponent component, ExaminedEvent args)
{
if (component.Detonation)
args.PushMarkup(Loc.GetString("examine-c4-detonation-by-unstick"));
}
}
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/Andromeda/c4-detonation-by-unstick.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
verb-c4-detonation-by-unstick = Детонация при попытке снятия: {$status}
verb-c4-detonation-by-unstick-status-off = ВЫКЛ
verb-c4-detonation-by-unstick-status-on = ВКЛ
examine-c4-detonation-by-unstick = [color=red]Детонирует при попытке открепить[/color]

0 comments on commit c059c2a

Please sign in to comment.