Add click dragging for buckle (#1290)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Client.GameObjects.Components.Strap;
|
||||
using Content.Client.Interfaces.GameObjects.Components.Interaction;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Mobs
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class BuckleComponent : SharedBuckleComponent
|
||||
public class BuckleComponent : SharedBuckleComponent, IClientDraggable
|
||||
{
|
||||
private bool _buckled;
|
||||
|
||||
@@ -19,5 +21,15 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
}
|
||||
|
||||
protected override bool Buckled => _buckled;
|
||||
|
||||
bool IClientDraggable.ClientCanDropOn(CanDropEventArgs eventArgs)
|
||||
{
|
||||
return eventArgs.Target.HasComponent<StrapComponent>();
|
||||
}
|
||||
|
||||
bool IClientDraggable.ClientCanDrag(CanDragEventArgs eventArgs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.TryGetData<int>(SharedStrapComponent.StrapVisuals.RotationAngle, out var angle))
|
||||
if (!component.TryGetData<int>(StrapVisuals.RotationAngle, out var angle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Strap;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Strap
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class StrapComponent : SharedStrapComponent
|
||||
{
|
||||
public override StrapPosition Position { get; protected set; }
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (!(curState is StrapComponentState strap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Position = strap.Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,6 @@
|
||||
"Utensil",
|
||||
"UnarmedCombat",
|
||||
"TimedSpawner",
|
||||
"Strap",
|
||||
"NodeContainer",
|
||||
"PowerSupplier",
|
||||
"PowerConsumer",
|
||||
|
||||
@@ -22,7 +22,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Server.GameObjects.Components.Mobs
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class BuckleComponent : SharedBuckleComponent, IInteractHand
|
||||
public class BuckleComponent : SharedBuckleComponent, IInteractHand, IDragDrop
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem;
|
||||
@@ -299,6 +299,11 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
return TryUnbuckle(eventArgs.User);
|
||||
}
|
||||
|
||||
bool IDragDrop.DragDrop(DragDropEventArgs eventArgs)
|
||||
{
|
||||
return TryBuckle(eventArgs.User, eventArgs.Target);
|
||||
}
|
||||
|
||||
[Verb]
|
||||
private sealed class BuckleVerb : Verb<BuckleComponent>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Strap;
|
||||
@@ -35,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Strap
|
||||
public override StrapPosition Position
|
||||
{
|
||||
get => _position;
|
||||
set
|
||||
protected set
|
||||
{
|
||||
_position = value;
|
||||
Dirty();
|
||||
@@ -150,6 +149,11 @@ namespace Content.Server.GameObjects.Components.Strap
|
||||
OccupiedSize = 0;
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new StrapComponentState(Position);
|
||||
}
|
||||
|
||||
[Verb]
|
||||
private sealed class StrapVerb : Verb<StrapComponent>
|
||||
{
|
||||
|
||||
@@ -26,12 +26,27 @@ namespace Content.Shared.GameObjects.Components.Strap
|
||||
{
|
||||
public sealed override string Name => "Strap";
|
||||
|
||||
public virtual StrapPosition Position { get; set; }
|
||||
public sealed override uint? NetID => ContentNetIDs.STRAP;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum StrapVisuals
|
||||
public abstract StrapPosition Position { get; protected set; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class StrapComponentState : ComponentState
|
||||
{
|
||||
public readonly StrapPosition Position;
|
||||
|
||||
public StrapComponentState(StrapPosition position) : base(ContentNetIDs.BUCKLE)
|
||||
{
|
||||
RotationAngle
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public bool Buckled { get; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum StrapVisuals
|
||||
{
|
||||
RotationAngle
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
public const uint BUCKLE = 1052;
|
||||
public const uint PROJECTILE = 1053;
|
||||
public const uint THROWN_ITEM = 1054;
|
||||
public const uint STRAP = 1055;
|
||||
|
||||
// Net IDs for integration tests.
|
||||
public const uint PREDICTION_TEST = 10001;
|
||||
|
||||
Reference in New Issue
Block a user