Fix tethergun (#13163)

This commit is contained in:
metalgearsloth
2022-12-25 08:24:43 +11:00
committed by GitHub
parent 21d1b885d6
commit a5f17a590f
4 changed files with 13 additions and 11 deletions

View File

@@ -17,7 +17,6 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
public bool Enabled { get; set; }
@@ -85,16 +84,11 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
if (gameState is GameplayState game)
{
EntityUid? uid;
foreach (var ent in _lookup.GetEntitiesIntersecting(mousePos, LookupFlags.Approximate | LookupFlags.Static))
{
uid = game.GetEntityUnderPosition(mousePos);
var uid = game.GetEntityUnderPosition(mousePos);
if (uid != null)
StartDragging(uid.Value, mousePos);
}
}
if (_dragging == null)
return;

View File

@@ -54,7 +54,6 @@ public sealed class PrototypeSaveTest
"SignalSwitch",
"SignalButton",
"ApcNetSwitch",
"TetherEntity",
"SignalButtonExt1",
"SignalButtonExt2",
"SignalButtonExt3",

View File

@@ -21,6 +21,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedJointSystem _joints = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
private readonly Dictionary<ICommonSession, (EntityUid Entity, EntityUid Tether, Joint Joint)> _tethered = new();
private readonly HashSet<ICommonSession> _draggers = new();
@@ -113,6 +114,8 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
body.BodyStatus = BodyStatus.InAir;
}
_physics.WakeBody(bodyA);
_physics.WakeBody(bodyB);
var joint = _joints.CreateMouseJoint(bodyA.Owner, bodyB.Owner, id: JointId);
SharedJointSystem.LinearStiffness(5f, 0.7f, bodyA.Mass, bodyB.Mass, out var stiffness, out var damping);
@@ -183,7 +186,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem
// Force it awake, always
if (bodyQuery.TryGetComponent(entity.Entity, out var body))
{
body.WakeBody();
_physics.WakeBody(body);
}
}

View File

@@ -3,4 +3,10 @@
noSpawn: true
components:
- type: Physics
bodyType: Dynamic
- type: Fixtures
fixtures:
- shape:
!type:PhysShapeCircle
radius: 0.35
id: tether