2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Hands.Components;
|
|
|
|
|
using Content.Shared.ActionBlocker;
|
2021-06-19 10:03:24 +02:00
|
|
|
using Content.Shared.Interaction.Events;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Item;
|
|
|
|
|
using Content.Shared.Verbs;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
2020-01-26 05:00:59 -08:00
|
|
|
using Robust.Shared.Containers;
|
2019-07-31 15:02:36 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-08-29 13:36:02 +02:00
|
|
|
using Robust.Shared.Localization;
|
2017-09-24 21:09:26 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Items
|
2017-09-24 21:09:26 +02:00
|
|
|
{
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2021-04-02 04:01:03 -06:00
|
|
|
[ComponentReference(typeof(SharedItemComponent))]
|
|
|
|
|
public class ItemComponent : SharedItemComponent
|
2017-09-24 21:09:26 +02:00
|
|
|
{
|
2021-04-02 04:01:03 -06:00
|
|
|
public override void RemovedFromSlot()
|
2017-09-24 21:09:26 +02:00
|
|
|
{
|
2018-05-10 19:21:15 +02:00
|
|
|
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
|
2017-09-30 16:56:19 +02:00
|
|
|
{
|
|
|
|
|
component.Visible = true;
|
|
|
|
|
}
|
2017-09-24 21:09:26 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-02 04:01:03 -06:00
|
|
|
public override void EquippedToSlot()
|
2017-09-24 21:09:26 +02:00
|
|
|
{
|
2018-05-10 19:21:15 +02:00
|
|
|
foreach (var component in Owner.GetAllComponents<ISpriteRenderableComponent>())
|
2017-09-30 16:56:19 +02:00
|
|
|
{
|
|
|
|
|
component.Visible = false;
|
|
|
|
|
}
|
2017-09-24 21:09:26 +02:00
|
|
|
}
|
2017-10-06 21:05:21 +02:00
|
|
|
|
2019-03-26 13:46:07 +01:00
|
|
|
[Verb]
|
|
|
|
|
public sealed class PickUpVerb : Verb<ItemComponent>
|
|
|
|
|
{
|
2020-05-23 03:09:44 +02:00
|
|
|
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
|
2019-03-26 13:46:07 +01:00
|
|
|
{
|
2021-06-19 10:03:24 +02:00
|
|
|
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(user) ||
|
2020-11-13 20:25:04 +13:00
|
|
|
component.Owner.IsInContainer() ||
|
2020-06-22 18:54:56 +02:00
|
|
|
!component.CanPickup(user))
|
2019-03-27 12:29:43 +00:00
|
|
|
{
|
2020-05-23 03:09:44 +02:00
|
|
|
data.Visibility = VerbVisibility.Invisible;
|
|
|
|
|
return;
|
2019-03-27 12:29:43 +00:00
|
|
|
}
|
2019-05-15 12:49:29 -07:00
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
data.Text = Loc.GetString("pick-up-verb-get-data-text");
|
2019-03-26 13:46:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Activate(IEntity user, ItemComponent component)
|
|
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (user.TryGetComponent(out HandsComponent? hands) && !hands.IsHolding(component.Owner))
|
2019-03-26 13:46:07 +01:00
|
|
|
{
|
|
|
|
|
hands.PutInHand(component);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-24 21:09:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-21 02:21:20 -07:00
|
|
|
|