Drag changes (#2487)
* Drag changes * Higlights only show near cursor * Don't highlight un-droppable entities * Fixes invalid highlights issue * Also the scanner * 2 months fix * Address reviews Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -33,6 +33,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Server.GameObjects.Components.Buckle
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBuckleComponent))]
|
||||
public class BuckleComponent : SharedBuckleComponent, IInteractHand
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
@@ -44,11 +45,6 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
|
||||
private int _size;
|
||||
|
||||
/// <summary>
|
||||
/// The range from which this entity can buckle to a <see cref="StrapComponent"/>.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
private float _range;
|
||||
/// <summary>
|
||||
/// The amount of time that must pass for this entity to
|
||||
/// be able to unbuckle after recently buckling.
|
||||
@@ -184,7 +180,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
var component = strap;
|
||||
bool Ignored(IEntity entity) => entity == Owner || entity == user || entity == component.Owner;
|
||||
|
||||
if (!Owner.InRangeUnobstructed(strap, _range, predicate: Ignored, popup: true))
|
||||
if (!Owner.InRangeUnobstructed(strap, Range, predicate: Ignored, popup: true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -319,7 +315,7 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!user.InRangeUnobstructed(oldBuckledTo, _range, popup: true))
|
||||
if (!user.InRangeUnobstructed(oldBuckledTo, Range, popup: true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -385,7 +381,6 @@ namespace Content.Server.GameObjects.Components.Buckle
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _size, "size", 100);
|
||||
serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 1.4f);
|
||||
|
||||
var seconds = 0.25f;
|
||||
serializer.DataField(ref seconds, "cooldown", 0.25f);
|
||||
|
||||
@@ -10,13 +10,11 @@ using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.EntitySystems.DeviceNetwork;
|
||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.Interfaces;
|
||||
@@ -47,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
[ComponentReference(typeof(SharedDisposalMailingUnitComponent))]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public class DisposalMailingUnitComponent : SharedDisposalMailingUnitComponent, IInteractHand, IActivate, IInteractUsing, IDragDropOn
|
||||
public class DisposalMailingUnitComponent : SharedDisposalMailingUnitComponent, IInteractHand, IActivate, IInteractUsing
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -145,7 +143,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
/// </summary>
|
||||
private (PressureState State, string Localized) _locState;
|
||||
|
||||
public bool CanInsert(IEntity entity)
|
||||
public override bool CanInsert(IEntity entity)
|
||||
{
|
||||
if (!Anchored)
|
||||
{
|
||||
@@ -763,12 +761,12 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
return TryDrop(eventArgs.User, eventArgs.Using);
|
||||
}
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
return CanInsert(eventArgs.Dragged);
|
||||
}
|
||||
|
||||
bool IDragDropOn.DragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
_ = TryInsert(eventArgs.Dragged, eventArgs.User);
|
||||
return true;
|
||||
|
||||
@@ -6,20 +6,17 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Content.Shared.GameObjects.Components.Items;
|
||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.Interfaces;
|
||||
@@ -51,7 +48,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IDragDropOn, IThrowCollide, IGasMixtureHolder
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IThrowCollide, IGasMixtureHolder
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -137,17 +134,16 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
|
||||
public GasMixture Air { get; set; } = default!;
|
||||
|
||||
public bool CanInsert(IEntity entity)
|
||||
public override bool CanInsert(IEntity entity)
|
||||
{
|
||||
if (!Anchored)
|
||||
{
|
||||
if (!base.CanInsert(entity))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
|
||||
!physics.CanCollide)
|
||||
{
|
||||
if (!(entity.TryGetComponent(out IMobStateComponent? state) && state.IsDead())) {
|
||||
if (entity.TryGetComponent(out IMobStateComponent? state) && state.IsDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -676,12 +672,14 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
return TryDrop(eventArgs.User, eventArgs.Using);
|
||||
}
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
// Base is redundant given this already calls the base CanInsert
|
||||
// If that changes then update this
|
||||
return CanInsert(eventArgs.Dragged);
|
||||
}
|
||||
|
||||
bool IDragDropOn.DragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
_ = TryInsert(eventArgs.Dragged, eventArgs.User);
|
||||
return true;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(SharedMedicalScannerComponent))]
|
||||
public class MedicalScannerComponent : SharedMedicalScannerComponent, IActivate, IDragDropOn, IDestroyAct
|
||||
public class MedicalScannerComponent : SharedMedicalScannerComponent, IActivate, IDestroyAct
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -292,12 +292,7 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
return eventArgs.Dragged.HasComponent<IBody>();
|
||||
}
|
||||
|
||||
public bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
_bodyContainer.Insert(eventArgs.Dragged);
|
||||
return true;
|
||||
|
||||
@@ -27,41 +27,36 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IClimbable))]
|
||||
public class ClimbableComponent : SharedClimbableComponent, IDragDropOn
|
||||
public class ClimbableComponent : SharedClimbableComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The range from which this entity can be climbed.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
private float _range;
|
||||
|
||||
/// <summary>
|
||||
/// The time it takes to climb onto the entity.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
private float _climbDelay;
|
||||
|
||||
private DoAfterSystem _doAfterSystem;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Owner.EnsureComponentWarn(out PhysicsComponent _);
|
||||
|
||||
_doAfterSystem = EntitySystem.Get<DoAfterSystem>();
|
||||
if (!Owner.EnsureComponent(out PhysicsComponent _))
|
||||
{
|
||||
Logger.Warning($"Entity {Owner.Name} at {Owner.Transform.MapPosition} didn't have a {nameof(PhysicsComponent)}");
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 1.4f);
|
||||
serializer.DataField(ref _climbDelay, "delay", 0.8f);
|
||||
}
|
||||
|
||||
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool CanDragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
if (!base.CanDragDropOn(eventArgs))
|
||||
return false;
|
||||
|
||||
string reason;
|
||||
bool canVault;
|
||||
|
||||
@@ -105,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!user.InRangeUnobstructed(target, _range))
|
||||
if (!user.InRangeUnobstructed(target, Range))
|
||||
{
|
||||
reason = Loc.GetString("You can't reach there!");
|
||||
return false;
|
||||
@@ -139,8 +134,8 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
bool Ignored(IEntity entity) => entity == target || entity == user || entity == dragged;
|
||||
|
||||
if (!user.InRangeUnobstructed(target, _range, predicate: Ignored) ||
|
||||
!user.InRangeUnobstructed(dragged, _range, predicate: Ignored))
|
||||
if (!user.InRangeUnobstructed(target, Range, predicate: Ignored) ||
|
||||
!user.InRangeUnobstructed(dragged, Range, predicate: Ignored))
|
||||
{
|
||||
reason = Loc.GetString("You can't reach there!");
|
||||
return false;
|
||||
@@ -150,7 +145,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IDragDropOn.DragDropOn(DragDropEventArgs eventArgs)
|
||||
public override bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.User == eventArgs.Dragged)
|
||||
{
|
||||
@@ -174,7 +169,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
BreakOnStun = true
|
||||
};
|
||||
|
||||
var result = await _doAfterSystem.DoAfter(doAfterEventArgs);
|
||||
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
||||
|
||||
if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||
{
|
||||
@@ -219,7 +214,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
BreakOnStun = true
|
||||
};
|
||||
|
||||
var result = await _doAfterSystem.DoAfter(doAfterEventArgs);
|
||||
var result = await EntitySystem.Get<DoAfterSystem>().DoAfter(doAfterEventArgs);
|
||||
|
||||
if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using Robust.Shared.Maths;
|
||||
namespace Content.Server.GameObjects.Components.Movement
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedClimbingComponent))]
|
||||
public class ClimbingComponent : SharedClimbingComponent
|
||||
{
|
||||
private bool _isClimbing;
|
||||
|
||||
@@ -207,9 +207,7 @@ namespace Content.Server.GameObjects.Components.Strap
|
||||
parent = parent.Parent;
|
||||
}
|
||||
|
||||
var range = SharedInteractionSystem.InteractionRange / 2;
|
||||
|
||||
if (!user.InRangeUnobstructed(component, range))
|
||||
if (!user.InRangeUnobstructed(component, buckle.Range))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -228,5 +226,11 @@ namespace Content.Server.GameObjects.Components.Strap
|
||||
buckle.ToggleBuckle(user, component.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool DragDropOn(DragDropEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Dragged.TryGetComponent(out BuckleComponent? buckleComponent)) return false;
|
||||
return buckleComponent.TryBuckle(eventArgs.User, Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user