# Conflicts: # Content.Client/Entry/EntryPoint.cs # Content.Client/Stylesheets/StyleNano.cs # Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs # Content.Server/Nutrition/EntitySystems/FoodSystem.cs # Content.Shared/Follower/FollowerSystem.cs # Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/PAI/SharedPAISystem.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs # Resources/Locale/en-US/_strings/access/components/genpop.ftl # Resources/Locale/en-US/_strings/doors/components/turnstile.ftl # Resources/Locale/en-US/_strings/power/battery.ftl # Resources/Locale/en-US/_strings/store/pai-catalog.ftl # Resources/Locale/en-US/_strings/tools/simple-tool-usage.ftl # Resources/Locale/en-US/_strings/ui/controls.ftl # Resources/Locale/en-US/_strings/weapons/ranged/upgrades.ftl # Resources/Prototypes/Access/misc.yml # Resources/Prototypes/Catalog/Cargo/cargo_vending.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/coats.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml # Resources/Prototypes/Entities/Markers/Spawners/Random/crates.yml # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Entities/Mobs/Player/dragon.yml # Resources/Prototypes/Entities/Mobs/Player/humanoid.yml # Resources/Prototypes/Entities/Objects/Fun/toys.yml # Resources/Prototypes/Entities/Objects/Misc/paper.yml # Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml # Resources/Prototypes/Entities/Objects/Tools/access_configurator.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Stations/base.yml # Resources/Prototypes/Entities/Structures/Walls/asteroid.yml # Resources/Prototypes/Loadouts/role_loadouts.yml # Resources/Prototypes/Recipes/Lathes/Packs/science.yml # Resources/Prototypes/Research/industrial.yml # Resources/Prototypes/Species/vox.yml # Resources/Prototypes/Store/currency.yml # Resources/Prototypes/Voice/speech_emotes.yml # Resources/Prototypes/ai_factions.yml # Resources/Prototypes/borg_types.yml # Resources/Textures/Clothing/Head/Hats/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/capformaldress.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/paramedic.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/paramedic.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/capformal.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/capformal.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/captain.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/captain_sabre.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/energykatana.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/katana.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/machete.rsi/meta.json # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/deny.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/locked.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/opening.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/assembly.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/meta.json # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/open.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/opening.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/opening.png # Resources/Textures/Structures/Wallmounts/posters.rsi/poster4_contraband.png # Resources/migration.yml
127 lines
3.9 KiB
C#
127 lines
3.9 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;
|
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
|
public bool DeactivateUnequippedHand;
|
|
}
|
|
|
|
/// <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;
|
|
}
|