Files
tbd-station-14/Content.Client/GameObjects/Components/Buckle/BuckleComponent.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

53 lines
1.5 KiB
C#

using Content.Shared.GameObjects.Components.Buckle;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Buckle
{
[RegisterComponent]
[ComponentReference(typeof(SharedBuckleComponent))]
public class BuckleComponent : SharedBuckleComponent
{
private bool _buckled;
private int? _originalDrawDepth;
public override bool Buckled => _buckled;
public override bool TryBuckle(IEntity user, IEntity to)
{
// TODO: Prediction
return false;
}
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (curState is not BuckleComponentState buckle)
{
return;
}
_buckled = buckle.Buckled;
LastEntityBuckledTo = buckle.LastEntityBuckledTo;
DontCollide = buckle.DontCollide;
if (!Owner.TryGetComponent(out SpriteComponent ownerSprite))
{
return;
}
if (_buckled && buckle.DrawDepth.HasValue)
{
_originalDrawDepth ??= ownerSprite.DrawDepth;
ownerSprite.DrawDepth = buckle.DrawDepth.Value;
return;
}
if (!_buckled && _originalDrawDepth.HasValue)
{
ownerSprite.DrawDepth = _originalDrawDepth.Value;
_originalDrawDepth = null;
}
}
}
}