Files
tbd-station-14/Content.Shared/Armable/ArmableSystem.cs
kaiserbirch 8812237108 Land mine armament (#33883)
* Land Mine is now armable, it will not explode unless armed.

* Land Mine is now armable, it will not explode unless armed.

* Explicitly have Armed as false

* SharedLandMineSystem.cs adds the "Arm"-verb in "Content.Shared" with the Arming logic being implemented in "Content.Server"

* Land Mines now blink only when armed.

* Added prediction components, moved logic to SharedLandMineSystem.cs and inherit it in client content.

* Accessing the datafield directly instead of using methods

* Mines are now armed by default with a unarmed prototype

* Land mine now shows if it is armed when examined and in range.

* Landmine is unarmed by default with an armed variant for mapping purposes.

* Removed properties that were already defined by inheritance.

* Access the bool directly from the component

* Add booleans to change if the Arm-verb is showed and if examining the mine shows the status.

* Added status message for unarmed mine, removed using PushGroup since only one string is displayed.

* Added properties to the explosive floor sign to ensure that it is armed, not showing neither status nor arm-verb.

* The prototypes work now as before with added unarmed versions. Sprite is now only one toggable layer.

* Make the craftable land mine unarmed.

* Refactored the arming mechanic into own component and system.

* Reverted the explosive wet floor sign to previous prototype and added the Armable component and ItemToggle to the landmines.

* Moved the examination strings from land-mines.ftl to armable.ftl.

* Removed unused property.

* Formatting and fixing imports

* Added prefixes to the ftl naming. Moved LocId from system to component

* Added documentation. Moved check for armable to HandleStepTriggerAttempt.
Moved the LocId to component.

* Removed the TryArming method. Added documentation.

* Removed unnecessary TryComp

* Simplified the logic for the trigger attempt

* HasComp instead of TryComp on logic

* EmoGarbage Review

---------

Co-authored-by: Franz - Josef Björck <kaiserbirch@proton.me>
Co-authored-by: EmoGarbage404 <retron404@gmail.com>
2025-04-25 16:53:50 -04:00

55 lines
1.9 KiB
C#

using Content.Shared.Examine;
using Content.Shared.Item.ItemToggle;
using Content.Shared.Item.ItemToggle.Components;
namespace Content.Shared.Armable;
/// <summary>
/// When used together with ItemToggle this will make the ItemToggle one way which is then used to represent an armed
/// state. If ItemComponent.Activated is true then the item is considered to be armed and should be able to be
/// triggered.
/// </summary>
public sealed class ArmableSystem : EntitySystem
{
[Dependency] private readonly ItemToggleSystem _itemToggle = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ArmableComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<ArmableComponent, ItemToggledEvent>(ArmingDone);
}
/// <summary>
/// Shows the status of the armable entity on examination.
/// </summary>
private void OnExamine(EntityUid uid, ArmableComponent comp, ExaminedEvent args)
{
if (!args.IsInDetailsRange || !comp.ShowStatusOnExamination || !TryComp<ItemToggleComponent>(uid, out var itemToggle))
return;
if (itemToggle.Activated)
{
if (!string.IsNullOrEmpty(comp.ExamineTextArmed))
args.PushMarkup(Loc.GetString(comp.ExamineTextArmed, ("name", uid)));
}
else
{
if (!string.IsNullOrEmpty(comp.ExamineTextNotArmed))
args.PushMarkup(Loc.GetString(comp.ExamineTextNotArmed,("name", uid)));
}
}
/// <summary>
/// Changes the appearance and disables the ItemToggleComponent as to not show the deactivate verb.
/// Whatever is armed should probably not be trivially disarmed.
/// </summary>
private void ArmingDone(Entity<ArmableComponent> entity, ref ItemToggledEvent args)
{
if (!args.Activated)
return;
_itemToggle.SetOnActivate(entity.Owner, false);
}
}