Add Alt-click functionality (#4497)

* Fix ItemSlot Bug

* Add Alt-use Key

* Fix TransferAmount window bug

* Alt-click functionality

* Added AltInteract verbs

* Add new verbs

* verb icons

* Changed Comments

* Change Comments

* Fix disposal verbs

* Changed Get...() to Get...OrNull()

* Changed alt-interact combat behaviour

* Update verb icons

* Inventory interact event

* Add Alt+E secondary binding

* Add alt-z keybinding

* Rename AltUse -> AltActivateItemInWorld
This commit is contained in:
Leon Friedrich
2021-08-22 03:20:18 +10:00
committed by GitHub
parent ad5f7bb71b
commit 486dc6ca62
51 changed files with 748 additions and 53 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Shared.ActionBlocker;
using Content.Shared.Acts;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
@@ -14,6 +15,7 @@ using Content.Shared.Notification.Managers;
using Content.Shared.Placeable;
using Content.Shared.Sound;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Content.Shared.Whitelist;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -22,6 +24,7 @@ using Robust.Shared.Containers;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Network;
@@ -629,5 +632,46 @@ namespace Content.Server.Storage.Components
{
SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default);
}
[Verb]
private sealed class ToggleOpenVerb : Verb<ServerStorageComponent>
{
public override bool AlternativeInteraction => true;
protected override void GetData(IEntity user, ServerStorageComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user))
{
data.Visibility = VerbVisibility.Invisible;
return;
}
// Get the session for the user
var session = user.GetComponentOrNull<ActorComponent>()?.PlayerSession;
if (session == null)
{
data.Visibility = VerbVisibility.Invisible;
return;
}
// Does this player currently have the storage UI open?
if (component.SubscribedSessions.Contains(session))
{
data.Text = Loc.GetString("toggle-open-verb-close");
data.IconTexture = "/Textures/Interface/VerbIcons/close.svg.192dpi.png";
} else
{
data.Text = Loc.GetString("toggle-open-verb-open");
data.IconTexture = "/Textures/Interface/VerbIcons/open.svg.192dpi.png";
}
}
/// <inheritdoc />
protected override void Activate(IEntity user, ServerStorageComponent component)
{
// "Open" actually closes the UI if it is already open.
component.OpenStorageUI(user);
}
}
}
}