forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from Voomra/dev/c4
Изменения механики C4
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Content.Shared/Andromeda/Voomra/C4/C4DetonationByUnstickComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
Content.Shared/Andromeda/Voomra/C4/C4DetonationByUnstickSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
3
Resources/Locale/ru-RU/Andromeda/c4-detonation-by-unstick.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ВКЛ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters