Fix toggle verbs (#32138)

First commit

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
beck-thompson
2024-11-19 17:53:52 -08:00
committed by GitHub
parent 35e2c641c1
commit 1fa1975e60
8 changed files with 17 additions and 61 deletions

View File

@@ -32,6 +32,18 @@ public sealed partial class ItemToggleComponent : Component
[DataField] [DataField]
public bool OnUse = true; 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> /// <summary>
/// Whether the item's toggle can be predicted by the client. /// Whether the item's toggle can be predicted by the client.
/// </summary> /// </summary>

View File

@@ -1,18 +0,0 @@
using Content.Shared.Item.ItemToggle;
using Robust.Shared.GameStates;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// Adds a verb for toggling something, requires <see cref="ItemToggleComponent"/>.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(ToggleVerbSystem))]
public sealed partial class ToggleVerbComponent : Component
{
/// <summary>
/// Text the verb will have.
/// Gets passed "entity" as the entity's identity string.
/// </summary>
[DataField(required: true)]
public LocId Text = string.Empty;
}

View File

@@ -78,7 +78,7 @@ public sealed class ItemToggleSystem : EntitySystem
args.Verbs.Add(new ActivationVerb() args.Verbs.Add(new ActivationVerb()
{ {
Text = !ent.Comp.Activated ? Loc.GetString("item-toggle-activate") : Loc.GetString("item-toggle-deactivate"), Text = !ent.Comp.Activated ? Loc.GetString(ent.Comp.VerbToggleOn) : Loc.GetString(ent.Comp.VerbToggleOff),
Act = () => Act = () =>
{ {
Toggle((ent.Owner, ent.Comp), user, predicted: ent.Comp.Predictable); Toggle((ent.Owner, ent.Comp), user, predicted: ent.Comp.Predictable);

View File

@@ -1,34 +0,0 @@
using Content.Shared.IdentityManagement;
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Verbs;
namespace Content.Shared.Item.ItemToggle;
/// <summary>
/// Adds a verb for toggling something with <see cref="ToggleVerbComponent"/>.
/// </summary>
public sealed class ToggleVerbSystem : EntitySystem
{
[Dependency] private readonly ItemToggleSystem _toggle = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ToggleVerbComponent, GetVerbsEvent<ActivationVerb>>(OnGetVerbs);
}
private void OnGetVerbs(Entity<ToggleVerbComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
return;
var name = Identity.Entity(ent, EntityManager);
var user = args.User;
args.Verbs.Add(new ActivationVerb()
{
Text = Loc.GetString(ent.Comp.Text, ("entity", name)),
Act = () => _toggle.Toggle(ent.Owner, user)
});
}
}

View File

@@ -1,3 +0,0 @@
# Toggle Magboots Verb
toggle-magboots-verb-get-data-text = Toggle Magboots

View File

@@ -1,3 +1,4 @@
fire-extinguisher-component-after-interact-refilled-message = {$owner} is now refilled fire-extinguisher-component-after-interact-refilled-message = {$owner} is now refilled
fire-extinguisher-component-safety-on-message = Its safety is on! fire-extinguisher-component-safety-on-message = Its safety is on!
fire-extinguisher-component-verb-text = Toggle safety fire-extinguisher-component-verb-remove = Remove safety
fire-extinguisher-component-verb-engage = Engage safety

View File

@@ -15,8 +15,6 @@
- type: ToggleClothing - type: ToggleClothing
action: ActionToggleMagboots action: ActionToggleMagboots
mustEquip: false mustEquip: false
- type: ToggleVerb
text: toggle-magboots-verb-get-data-text
- type: ComponentToggler - type: ComponentToggler
components: components:
- type: NoSlip - type: NoSlip

View File

@@ -47,8 +47,8 @@
params: params:
variation: 0.125 variation: 0.125
volume: -4 volume: -4
- type: ToggleVerb verbToggleOn: fire-extinguisher-component-verb-remove
text: fire-extinguisher-component-verb-text verbToggleOff: fire-extinguisher-component-verb-engage
- type: SpraySafety - type: SpraySafety
- type: MeleeWeapon - type: MeleeWeapon
wideAnimationRotation: 180 wideAnimationRotation: 180