Files
tbd-station-14/Content.Client/GameObjects/Components/Body/Mechanism/MechanismComponent.cs
DrSmugleaf bd30a73026 Add mechanism events when being added/removed to/from body/parts (#2271)
* Add mechanism events when added/removed to/from body/parts

* Change old usages

* Add TODO
2020-10-16 14:42:33 +02:00

35 lines
998 B
C#

#nullable enable
using Content.Shared.GameObjects.Components.Body.Mechanism;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Body.Mechanism
{
[RegisterComponent]
[ComponentReference(typeof(SharedMechanismComponent))]
[ComponentReference(typeof(IMechanism))]
public class MechanismComponent : SharedMechanismComponent
{
protected override void OnAddedToPart()
{
base.OnAddedToPart();
if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{
sprite.Visible = false;
}
}
protected override void OnRemovedFromPart(IBodyPart old)
{
base.OnRemovedFromPart(old);
if (Owner.TryGetComponent(out ISpriteComponent? sprite))
{
sprite.Visible = true;
}
}
}
}