Files
tbd-station-14/Content.Server/Clothing/Components/MagbootsComponent.cs
Leon Friedrich ff7d4ed9f6 Patched Actions Rework (#6899)
* Rejig Actions

* fix merge errors

* lambda-b-gon

* fix PAI, add innate actions

* Revert "fix PAI, add innate actions"

This reverts commit 4b501ac083e979e31ebd98d7b98077e0dbdd344b.

* Just fix by making nullable.

if only require: true actually did something somehow.

* Make AddActions() ensure an actions component

and misc comments

* misc cleanup

* Limit range even when not checking for obstructions

* remove old guardian code

* rename function and make EntityUid nullable

* fix magboot bug

* fix action search menu

* make targeting toggle all equivalent actions

* fix combat popups (enabling <-> disabling)

* fix networking

* Allow action locking

* prevent telepathy
2022-02-25 23:24:08 -06:00

59 lines
1.8 KiB
C#

using Content.Shared.Actions;
using Content.Shared.Clothing;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Item;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Clothing.Components
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
[ComponentReference(typeof(SharedMagbootsComponent))]
public sealed class MagbootsComponent : SharedMagbootsComponent, IActivate
{
[Dependency] private readonly IEntityManager _entMan = default!;
private bool _on;
[ViewVariables]
public override bool On
{
get => _on;
set
{
_on = value;
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);
}
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");
OnChanged();
Dirty();
}
}
void IActivate.Activate(ActivateEventArgs eventArgs)
{
On = !On;
}
public override ComponentState GetComponentState()
{
return new MagbootsComponentState(On);
}
}
}