* Make barstools, PA components, and radiation collectors rotatable. Making barstools rotatable is so that people can spin on the barstool. (RP moment.) The other two are more "functional" changes for assembling a PA. * Allow rotating a rotate-while-anchored object if you're buckled to it. Barstool spinny * Fix bug with rotation of an object that someone is buckled to * BuckleSystem: Efficiency improvements with directed events * Don't need to unsubscribe anymore from events, so in BuckleSystem, just don't
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
#nullable enable
|
|
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 (_originalDrawDepth.HasValue && !buckle.DrawDepth.HasValue)
|
|
{
|
|
ownerSprite.DrawDepth = _originalDrawDepth.Value;
|
|
_originalDrawDepth = null;
|
|
}
|
|
}
|
|
}
|
|
}
|