Files
tbd-station-14/Content.Server/Items/ItemComponent.cs
Leon Friedrich 486dc6ca62 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
2021-08-21 10:20:18 -07:00

61 lines
1.9 KiB
C#

using Content.Server.Hands.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.Items
{
[RegisterComponent]
[ComponentReference(typeof(SharedItemComponent))]
public class ItemComponent : SharedItemComponent
{
public override void RemovedFromSlot()
{
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
{
component.Visible = true;
}
}
public override void EquippedToSlot()
{
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
{
component.Visible = false;
}
}
[Verb]
public sealed class PickUpVerb : Verb<ItemComponent>
{
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) ||
component.Owner.IsInContainer() ||
!component.CanPickup(user))
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.Text = Loc.GetString("pick-up-verb-get-data-text");
data.IconTexture = "/Textures/Interface/VerbIcons/pickup.svg.192dpi.png";
}
protected override void Activate(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent? hands) && !hands.IsHolding(component.Owner))
{
hands.PutInHand(component);
}
}
}
}
}