Stop items that are being pulled from spinning (#26504)
* Fixed pulled items spinning when moved * edited out others issues * more reverts * requested fix * Removed "Optional:"
This commit is contained in:
@@ -269,7 +269,7 @@ public sealed class PullingSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dirty(player, pullerComp);
|
Dirty(player, pullerComp);
|
||||||
_throwing.TryThrow(pulled.Value, fromUserCoords, user: player, strength: 4f, animated: false, recoil: false, playSound: false);
|
_throwing.TryThrow(pulled.Value, fromUserCoords, user: player, strength: 4f, animated: false, recoil: false, playSound: false, doSpin: false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
float pushbackRatio = PushbackDefault,
|
float pushbackRatio = PushbackDefault,
|
||||||
bool recoil = true,
|
bool recoil = true,
|
||||||
bool animated = true,
|
bool animated = true,
|
||||||
bool playSound = true)
|
bool playSound = true,
|
||||||
|
bool doSpin = true)
|
||||||
{
|
{
|
||||||
var thrownPos = _transform.GetMapCoordinates(uid);
|
var thrownPos = _transform.GetMapCoordinates(uid);
|
||||||
var mapPos = _transform.ToMapCoordinates(coordinates);
|
var mapPos = _transform.ToMapCoordinates(coordinates);
|
||||||
@@ -57,7 +58,7 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
if (mapPos.MapId != thrownPos.MapId)
|
if (mapPos.MapId != thrownPos.MapId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TryThrow(uid, mapPos.Position - thrownPos.Position, strength, user, pushbackRatio, recoil: recoil, animated: animated, playSound: playSound);
|
TryThrow(uid, mapPos.Position - thrownPos.Position, strength, user, pushbackRatio, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -67,6 +68,7 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
/// <param name="direction">A vector pointing from the entity to its destination.</param>
|
/// <param name="direction">A vector pointing from the entity to its destination.</param>
|
||||||
/// <param name="strength">How much the direction vector should be multiplied for velocity.</param>
|
/// <param name="strength">How much the direction vector should be multiplied for velocity.</param>
|
||||||
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower - defaults to 10 because otherwise it's not enough to properly recover from getting spaced</param>
|
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower - defaults to 10 because otherwise it's not enough to properly recover from getting spaced</param>
|
||||||
|
/// <param name="doSpin">Whether spin will be applied to the thrown entity.</param>
|
||||||
public void TryThrow(EntityUid uid,
|
public void TryThrow(EntityUid uid,
|
||||||
Vector2 direction,
|
Vector2 direction,
|
||||||
float strength = 1.0f,
|
float strength = 1.0f,
|
||||||
@@ -74,7 +76,8 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
float pushbackRatio = PushbackDefault,
|
float pushbackRatio = PushbackDefault,
|
||||||
bool recoil = true,
|
bool recoil = true,
|
||||||
bool animated = true,
|
bool animated = true,
|
||||||
bool playSound = true)
|
bool playSound = true,
|
||||||
|
bool doSpin = true)
|
||||||
{
|
{
|
||||||
var physicsQuery = GetEntityQuery<PhysicsComponent>();
|
var physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||||
if (!physicsQuery.TryGetComponent(uid, out var physics))
|
if (!physicsQuery.TryGetComponent(uid, out var physics))
|
||||||
@@ -90,7 +93,7 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
projectileQuery,
|
projectileQuery,
|
||||||
strength,
|
strength,
|
||||||
user,
|
user,
|
||||||
pushbackRatio, recoil: recoil, animated: animated, playSound: playSound);
|
pushbackRatio, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -100,6 +103,7 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
/// <param name="direction">A vector pointing from the entity to its destination.</param>
|
/// <param name="direction">A vector pointing from the entity to its destination.</param>
|
||||||
/// <param name="strength">How much the direction vector should be multiplied for velocity.</param>
|
/// <param name="strength">How much the direction vector should be multiplied for velocity.</param>
|
||||||
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower - defaults to 10 because otherwise it's not enough to properly recover from getting spaced</param>
|
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower - defaults to 10 because otherwise it's not enough to properly recover from getting spaced</param>
|
||||||
|
/// <param name="doSpin">Whether spin will be applied to the thrown entity.</param>
|
||||||
public void TryThrow(EntityUid uid,
|
public void TryThrow(EntityUid uid,
|
||||||
Vector2 direction,
|
Vector2 direction,
|
||||||
PhysicsComponent physics,
|
PhysicsComponent physics,
|
||||||
@@ -110,7 +114,8 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
float pushbackRatio = PushbackDefault,
|
float pushbackRatio = PushbackDefault,
|
||||||
bool recoil = true,
|
bool recoil = true,
|
||||||
bool animated = true,
|
bool animated = true,
|
||||||
bool playSound = true)
|
bool playSound = true,
|
||||||
|
bool doSpin = true)
|
||||||
{
|
{
|
||||||
if (strength <= 0 || direction == Vector2Helpers.Infinity || direction == Vector2Helpers.NaN || direction == Vector2.Zero)
|
if (strength <= 0 || direction == Vector2Helpers.Infinity || direction == Vector2Helpers.NaN || direction == Vector2.Zero)
|
||||||
return;
|
return;
|
||||||
@@ -147,6 +152,8 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
ThrowingAngleComponent? throwingAngle = null;
|
ThrowingAngleComponent? throwingAngle = null;
|
||||||
|
|
||||||
// Give it a l'il spin.
|
// Give it a l'il spin.
|
||||||
|
if (doSpin)
|
||||||
|
{
|
||||||
if (physics.InvI > 0f && (!TryComp(uid, out throwingAngle) || throwingAngle.AngularVelocity))
|
if (physics.InvI > 0f && (!TryComp(uid, out throwingAngle) || throwingAngle.AngularVelocity))
|
||||||
{
|
{
|
||||||
_physics.ApplyAngularImpulse(uid, ThrowAngularImpulse / physics.InvI, body: physics);
|
_physics.ApplyAngularImpulse(uid, ThrowAngularImpulse / physics.InvI, body: physics);
|
||||||
@@ -159,6 +166,7 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
var offset = throwingAngle?.Angle ?? Angle.Zero;
|
var offset = throwingAngle?.Angle ?? Angle.Zero;
|
||||||
_transform.SetLocalRotation(uid, angle + offset);
|
_transform.SetLocalRotation(uid, angle + offset);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var throwEvent = new ThrownEvent(user, uid);
|
var throwEvent = new ThrownEvent(user, uid);
|
||||||
RaiseLocalEvent(uid, ref throwEvent, true);
|
RaiseLocalEvent(uid, ref throwEvent, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user