* 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>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Content.Server.Explosion.EntitySystems;
|
|
using Content.Shared.Armable;
|
|
using Content.Shared.Item.ItemToggle.Components;
|
|
using Content.Shared.LandMines;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.StepTrigger.Systems;
|
|
using Robust.Shared.Audio.Systems;
|
|
|
|
namespace Content.Server.LandMines;
|
|
|
|
public sealed class LandMineSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly TriggerSystem _trigger = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOnEvent>(HandleStepOnTriggered);
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOffEvent>(HandleStepOffTriggered);
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleStepTriggerAttempt);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Warns the player when stepped on.
|
|
/// </summary>
|
|
private void HandleStepOnTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOnEvent args)
|
|
{
|
|
if (!string.IsNullOrEmpty(component.TriggerText))
|
|
{
|
|
_popupSystem.PopupCoordinates(
|
|
Loc.GetString(component.TriggerText, ("mine", uid)),
|
|
Transform(uid).Coordinates,
|
|
args.Tripper,
|
|
PopupType.LargeCaution);
|
|
}
|
|
_audioSystem.PlayPvs(component.Sound, uid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sends a trigger when stepped off.
|
|
/// </summary>
|
|
private void HandleStepOffTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOffEvent args)
|
|
{
|
|
_trigger.Trigger(uid, args.Tripper);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Presumes that the landmine isn't armable and should be treated as always armed.
|
|
/// If Armable and ItemToggle is present the event will continue only if the mine is activated.
|
|
/// </summary>
|
|
private void HandleStepTriggerAttempt(EntityUid uid, LandMineComponent component, ref StepTriggerAttemptEvent args)
|
|
{
|
|
args.Continue = true;
|
|
|
|
if (HasComp<ArmableComponent>(uid) && TryComp<ItemToggleComponent>(uid, out var itemToggle))
|
|
args.Continue = itemToggle.Activated;
|
|
}
|
|
}
|