0 days without buckle breaking (#1366)

This commit is contained in:
DrSmugleaf
2020-07-17 10:43:10 +02:00
committed by GitHub
parent 5c723ea70e
commit f313a9267a
13 changed files with 370 additions and 127 deletions

View File

@@ -1,55 +0,0 @@
using Content.Client.GameObjects.Components.Strap;
using Content.Client.Interfaces.GameObjects.Components.Interaction;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]
public class BuckleComponent : SharedBuckleComponent, IClientDraggable
{
private bool _buckled;
private int? _originalDrawDepth;
protected override bool Buckled => _buckled;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
if (!(curState is BuckleComponentState buckle))
{
return;
}
_buckled = buckle.Buckled;
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;
}
}
bool IClientDraggable.ClientCanDropOn(CanDropEventArgs eventArgs)
{
return eventArgs.Target.HasComponent<StrapComponent>();
}
bool IClientDraggable.ClientCanDrag(CanDragEventArgs eventArgs)
{
return true;
}
}
}

View File

@@ -1,28 +0,0 @@
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Strap;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
{
[UsedImplicitly]
public class BuckleVisualizer2D : SpeciesVisualizer2D
{
public override void OnChangeData(AppearanceComponent component)
{
if (!component.TryGetData<bool>(SharedBuckleComponent.BuckleVisuals.Buckled, out var buckled) ||
!buckled)
{
return;
}
if (!component.TryGetData<int>(StrapVisuals.RotationAngle, out var angle))
{
return;
}
SetRotation(component, Angle.FromDegrees(angle));
}
}
}

View File

@@ -29,7 +29,7 @@ namespace Content.Client.GameObjects.Components.Mobs
}
}
protected void SetRotation(AppearanceComponent component, Angle rotation)
private void SetRotation(AppearanceComponent component, Angle rotation)
{
var sprite = component.Owner.GetComponent<ISpriteComponent>();