* 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
61 lines
1.9 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|