* 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>
125 lines
3.8 KiB
C#
125 lines
3.8 KiB
C#
using Robust.Shared.Audio;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Item.ItemToggle.Components;
|
|
|
|
/// <summary>
|
|
/// Handles generic item toggles, like a welder turning on and off, or an e-sword.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// If you need extended functionality (e.g. requiring power) then add a new component and use events:
|
|
/// ItemToggleActivateAttemptEvent, ItemToggleDeactivateAttemptEvent, ItemToggledEvent.
|
|
/// </remarks>
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
|
public sealed partial class ItemToggleComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// The item's toggle state.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public bool Activated = false;
|
|
|
|
/// <summary>
|
|
/// Can the entity be activated in the world.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public bool OnActivate = true;
|
|
|
|
/// <summary>
|
|
/// If this is set to false then the item can't be toggled by pressing Z.
|
|
/// Use another system to do it then.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool OnUse = true;
|
|
|
|
/// <summary>
|
|
/// The localized text to display in the verb to activate.
|
|
/// </summary>
|
|
[DataField]
|
|
public string VerbToggleOn = "item-toggle-activate";
|
|
|
|
/// <summary>
|
|
/// The localized text to display in the verb to de-activate.
|
|
/// </summary>
|
|
[DataField]
|
|
public string VerbToggleOff = "item-toggle-deactivate";
|
|
|
|
/// <summary>
|
|
/// Whether the item's toggle can be predicted by the client.
|
|
/// </summary>
|
|
/// /// <remarks>
|
|
/// If server-side systems affect the item's toggle, like charge/fuel systems, then the item is not predictable.
|
|
/// </remarks>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public bool Predictable = true;
|
|
|
|
/// <summary>
|
|
/// The noise this item makes when it is toggled on.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public SoundSpecifier? SoundActivate;
|
|
|
|
/// <summary>
|
|
/// The noise this item makes when it is toggled off.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public SoundSpecifier? SoundDeactivate;
|
|
|
|
/// <summary>
|
|
/// The noise this item makes when it is toggled on.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public SoundSpecifier? SoundFailToActivate;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed on an entity when its ItemToggle is attempted to be activated.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct ItemToggleActivateAttemptEvent(EntityUid? User)
|
|
{
|
|
/// <summary>
|
|
/// Should we silently fail.
|
|
/// </summary>
|
|
public bool Silent = false;
|
|
|
|
public bool Cancelled = false;
|
|
public readonly EntityUid? User = User;
|
|
|
|
/// <summary>
|
|
/// Pop-up that gets shown to users explaining why the attempt was cancelled.
|
|
/// </summary>
|
|
public string? Popup;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed on an entity when its ItemToggle is attempted to be deactivated.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public record struct ItemToggleDeactivateAttemptEvent(EntityUid? User)
|
|
{
|
|
/// <summary>
|
|
/// Should we silently fail.
|
|
/// </summary>
|
|
public bool Silent = false;
|
|
|
|
public bool Cancelled = false;
|
|
public readonly EntityUid? User = User;
|
|
|
|
/// <summary>
|
|
/// Pop-up that gets shown to users explaining why the attempt was cancelled.
|
|
/// </summary>
|
|
public string? Popup;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed on an entity any sort of toggle is complete.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public readonly record struct ItemToggledEvent(bool Predicted, bool Activated, EntityUid? User)
|
|
{
|
|
public readonly bool Predicted = Predicted;
|
|
public readonly bool Activated = Activated;
|
|
public readonly EntityUid? User = User;
|
|
}
|