using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Utility; namespace Content.Shared._Shitmed.ItemSwitch.Components; [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class ItemSwitchComponent : Component { /// /// The item's toggle state. /// [DataField, AutoNetworkedField] public string State; [DataField(readOnly: true)] public Dictionary States = []; /// /// Can the entity be activated in the world. /// [DataField] public bool OnActivate = true; /// /// If this is set to false then the item can't be toggled by pressing Z. /// Use another system to do it then. /// [DataField] public bool OnUse = true; /// /// Whether the item's toggle can be predicted by the client. /// /// /// /// If server-side systems affect the item's toggle, like charge/fuel systems, then the item is not predictable. /// [DataField] public bool Predictable = true; /// /// Whether the item's currently toggled state should be shown in the UI. /// [DataField] public bool ShowLabel = false; } [DataDefinition] public sealed partial class ItemSwitchState : BoundUserInterfaceMessage { [DataField] public string Verb; [DataField] public SoundSpecifier? SoundStateActivate; [DataField] public SoundSpecifier? SoundFailToActivate; [DataField] public ComponentRegistry? Components; [DataField] public bool RemoveComponents = true; [DataField] public SpriteSpecifier? Sprite; [DataField] public bool Hidden; } /// /// Raised directed on an entity when its ItemToggle is attempted to be activated. /// [ByRefEvent] public record struct ItemSwitchAttemptEvent() { public bool Cancelled = false; public required readonly EntityUid? User { get; init; } public required readonly string State { get; init; } /// /// Pop-up that gets shown to users explaining why the attempt was cancelled. /// public string? Popup { get; set; } } /// /// Raised directed on an entity any sort of toggle is complete. /// [ByRefEvent] public readonly record struct ItemSwitchedEvent() { public required readonly bool Predicted { get; init; } public required readonly string State { get; init; } public required readonly EntityUid? User { get; init; } }