Re-organize all projects (#4166)
This commit is contained in:
53
Content.Client/Buckle/BuckleComponent.cs
Normal file
53
Content.Client/Buckle/BuckleComponent.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.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 (_originalDrawDepth.HasValue && !buckle.DrawDepth.HasValue)
|
||||
{
|
||||
ownerSprite.DrawDepth = _originalDrawDepth.Value;
|
||||
_originalDrawDepth = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user