2021-01-11 19:24:09 +01:00
|
|
|
using Content.Shared.Actions;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Clothing;
|
|
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Content.Shared.Inventory;
|
2021-12-30 22:56:10 +01:00
|
|
|
using Content.Shared.Item;
|
2021-01-11 19:24:09 +01:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Shared.Containers;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-01-11 19:24:09 +01:00
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Clothing.Components
|
2021-01-11 19:24:09 +01:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
[ComponentReference(typeof(IActivate))]
|
2022-01-13 06:13:25 -08:00
|
|
|
[ComponentReference(typeof(SharedMagbootsComponent))]
|
2022-01-05 02:23:01 +13:00
|
|
|
public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate
|
2021-01-11 19:24:09 +01:00
|
|
|
{
|
2022-01-15 03:26:37 +01:00
|
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
2021-12-08 17:04:21 +01:00
|
|
|
|
2021-01-11 19:24:09 +01:00
|
|
|
private bool _on;
|
|
|
|
|
|
|
|
|
|
[ViewVariables]
|
|
|
|
|
public override bool On
|
|
|
|
|
{
|
|
|
|
|
get => _on;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_on = value;
|
|
|
|
|
|
2021-12-30 22:56:10 +01:00
|
|
|
if (Owner.TryGetContainer(out var container) && EntitySystem.Get<InventorySystem>()
|
|
|
|
|
.TryGetSlotEntity(container.Owner, "shoes", out var entityUid) && entityUid == Owner)
|
|
|
|
|
{
|
|
|
|
|
EntitySystem.Get<MagbootsSystem>().UpdateMagbootEffects(container.Owner, Owner, true, this);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-15 03:26:37 +01:00
|
|
|
if (_entMan.TryGetComponent<SharedItemComponent>(Owner, out var item))
|
|
|
|
|
item.EquippedPrefix = On ? "on" : null;
|
|
|
|
|
if(_entMan.TryGetComponent<SpriteComponent>(Owner, out var sprite))
|
|
|
|
|
sprite.LayerSetState(0, On ? "icon-on" : "icon");
|
2021-01-11 19:24:09 +01:00
|
|
|
OnChanged();
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 18:55:18 +13:00
|
|
|
void IActivate.Activate(ActivateEventArgs eventArgs)
|
|
|
|
|
{
|
2022-02-26 18:24:08 +13:00
|
|
|
On = !On;
|
2022-02-25 18:55:18 +13:00
|
|
|
}
|
|
|
|
|
|
2021-11-30 15:20:38 +01:00
|
|
|
public override ComponentState GetComponentState()
|
2021-01-11 19:24:09 +01:00
|
|
|
{
|
|
|
|
|
return new MagbootsComponentState(On);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|