Revert "ctrl-rclick tweaks" (#7171)
This commit is contained in:
@@ -28,7 +28,6 @@ namespace Content.Shared.Pulling.Components
|
||||
if (Pulling != default)
|
||||
{
|
||||
// This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc
|
||||
// Good thing Pulling is nullable now.
|
||||
Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLER {0} - OnRemove called when Pulling is set!", Owner);
|
||||
}
|
||||
base.OnRemove();
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Pulling.Events;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Pulling
|
||||
{
|
||||
@@ -37,6 +53,9 @@ namespace Content.Shared.Pulling
|
||||
var pullerPhysics = EntityManager.GetComponent<PhysicsComponent>(puller.Owner);
|
||||
var pullablePhysics = EntityManager.GetComponent<PhysicsComponent>(pullable.Owner);
|
||||
|
||||
// MovingTo shutdown
|
||||
ForceSetMovingTo(pullable, null);
|
||||
|
||||
// Joint shutdown
|
||||
if (EntityManager.TryGetComponent<JointComponent?>(puller.Owner, out var jointComp))
|
||||
{
|
||||
@@ -134,5 +153,31 @@ namespace Content.Shared.Pulling
|
||||
// DO NOT ADD ADDITIONAL LOGIC IN THIS FUNCTION. Do it in ForceRelationship.
|
||||
ForceRelationship(null, pullable);
|
||||
}
|
||||
|
||||
public void ForceSetMovingTo(SharedPullableComponent pullable, EntityCoordinates? movingTo)
|
||||
{
|
||||
if (pullable.MovingTo == movingTo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow setting a MovingTo if there's no puller.
|
||||
// The other half of this guarantee (shutting down a MovingTo if the puller goes away) is enforced in ForceRelationship.
|
||||
if ((pullable.Puller == null) && (movingTo != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pullable.MovingTo = movingTo;
|
||||
|
||||
if (movingTo == null)
|
||||
{
|
||||
RaiseLocalEvent(pullable.Owner, new PullableStopMovingMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
RaiseLocalEvent(pullable.Owner, new PullableMoveMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Pulling.Events;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Shared.Pulling
|
||||
{
|
||||
@@ -26,12 +29,12 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EntityManager.TryGetComponent<IPhysBody?>(pulled, out var physics))
|
||||
if (!EntityManager.TryGetComponent<IPhysBody?>(pulled, out var _physics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (physics.BodyType == BodyType.Static)
|
||||
if (_physics.BodyType == BodyType.Static)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +181,7 @@ namespace Content.Shared.Pulling
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool TryMoveTo(SharedPullableComponent pullable, EntityCoordinates to)
|
||||
public bool TryMoveTo(SharedPullableComponent pullable, EntityCoordinates to)
|
||||
{
|
||||
if (pullable.Puller == null)
|
||||
{
|
||||
@@ -190,8 +193,13 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
// Action handled under server
|
||||
_pullSm.ForceSetMovingTo(pullable, to);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void StopMoveTo(SharedPullableComponent pullable)
|
||||
{
|
||||
_pullSm.ForceSetMovingTo(pullable, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Content.Shared.Rotatable;
|
||||
@@ -34,6 +33,9 @@ namespace Content.Shared.Pulling
|
||||
private readonly Dictionary<EntityUid, EntityUid> _pullers =
|
||||
new();
|
||||
|
||||
private readonly HashSet<SharedPullableComponent> _moving = new();
|
||||
private readonly HashSet<SharedPullableComponent> _stoppedMoving = new();
|
||||
|
||||
/// <summary>
|
||||
/// If distance between puller and pulled entity lower that this threshold,
|
||||
/// pulled entity will not change its rotation.
|
||||
@@ -49,6 +51,8 @@ namespace Content.Shared.Pulling
|
||||
/// </summary>
|
||||
private const float ThresholdRotAngle = 22.5f;
|
||||
|
||||
public IReadOnlySet<SharedPullableComponent> Moving => _moving;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -102,7 +106,7 @@ namespace Content.Shared.Pulling
|
||||
{
|
||||
if (args.Pulled.Owner != uid)
|
||||
return;
|
||||
|
||||
|
||||
_alertsSystem.ShowAlert(component.Owner, AlertType.Pulled);
|
||||
}
|
||||
|
||||
@@ -114,9 +118,19 @@ namespace Content.Shared.Pulling
|
||||
_alertsSystem.ClearAlert(component.Owner, AlertType.Pulled);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
_moving.ExceptWith(_stoppedMoving);
|
||||
_stoppedMoving.Clear();
|
||||
}
|
||||
|
||||
public void Reset(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
_pullers.Clear();
|
||||
_moving.Clear();
|
||||
_stoppedMoving.Clear();
|
||||
}
|
||||
|
||||
private void OnPullStarted(PullStartedMessage message)
|
||||
@@ -129,6 +143,16 @@ namespace Content.Shared.Pulling
|
||||
RemovePuller(message.Puller.Owner);
|
||||
}
|
||||
|
||||
protected void OnPullableMove(EntityUid uid, SharedPullableComponent component, PullableMoveMessage args)
|
||||
{
|
||||
_moving.Add(component);
|
||||
}
|
||||
|
||||
protected void OnPullableStopMove(EntityUid uid, SharedPullableComponent component, PullableStopMovingMessage args)
|
||||
{
|
||||
_stoppedMoving.Add(component);
|
||||
}
|
||||
|
||||
private void PullerMoved(ref MoveEvent ev)
|
||||
{
|
||||
var puller = ev.Sender;
|
||||
@@ -193,9 +217,6 @@ namespace Content.Shared.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
// No leverage until this is tweaked more
|
||||
if (player.IsWeightless(entityManager: EntityManager)) return false;
|
||||
|
||||
TryMoveTo(pullable, coords);
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user