diff --git a/Content.Server/Physics/Controllers/PullController.cs b/Content.Server/Physics/Controllers/PullController.cs index 54c6ad8f31..407f6aa382 100644 --- a/Content.Server/Physics/Controllers/PullController.cs +++ b/Content.Server/Physics/Controllers/PullController.cs @@ -1,4 +1,5 @@ -using Content.Shared.Pulling; +using Content.Shared.Gravity; +using Content.Shared.Pulling; using Content.Shared.Pulling.Components; using Content.Shared.Rotatable; using Robust.Shared.Physics; @@ -36,6 +37,8 @@ namespace Content.Server.Physics.Controllers private const float MinimumMovementDistance = 0.005f; [Dependency] private readonly SharedPullingSystem _pullableSystem = default!; + [Dependency] private readonly SharedGravitySystem _gravity = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; // TODO: Move this stuff to pullingsystem /// @@ -63,19 +66,19 @@ namespace Content.Server.Physics.Controllers private void OnPullerMove(EntityUid uid, SharedPullerComponent component, ref MoveEvent args) { - if (component.Pulling == null || - !TryComp(component.Pulling.Value, out var pullable)) return; + if (component.Pulling is not { } pullable || !TryComp(pullable, out var pullableComponent)) + return; - UpdatePulledRotation(uid, pullable.Owner); + UpdatePulledRotation(uid, pullable); if (args.NewPosition.EntityId == args.OldPosition.EntityId && (args.NewPosition.Position - args.OldPosition.Position).LengthSquared < MinimumMovementDistance * MinimumMovementDistance) return; - if (TryComp(pullable.Owner, out var physics)) - PhysicsSystem.WakeBody(pullable.Owner, body: physics); + if (TryComp(pullable, out var physics)) + PhysicsSystem.WakeBody(pullable, body: physics); - _pullableSystem.StopMoveTo(pullable); + _pullableSystem.StopMoveTo(pullableComponent); } private void UpdatePulledRotation(EntityUid puller, EntityUid pulled) @@ -101,7 +104,7 @@ namespace Content.Server.Physics.Controllers var newAngle = Angle.FromWorldVec(dir); var diff = newAngle - oldAngle; - if (Math.Abs(diff.Degrees) > (ThresholdRotAngle / 2f)) + if (Math.Abs(diff.Degrees) > ThresholdRotAngle / 2f) { // Ok, so this bit is difficult because ideally it would look like it's snapping to sane angles. // Otherwise PIANO DOOR STUCK! happens. @@ -126,47 +129,45 @@ namespace Content.Server.Physics.Controllers // or due to being deleted. if (pullable.Deleted) - { continue; - } if (pullable.MovingTo == null) - { continue; - } if (pullable.Puller is not {Valid: true} puller) - { continue; - } + + var pullableEnt = pullable.Owner; + var pullableXform = Transform(pullableEnt); + var pullerXform = Transform(puller); // Now that's over with... - var pullerPosition = EntityManager.GetComponent(puller).MapPosition; - var movingTo = pullable.MovingTo.Value.ToMap(EntityManager); + var pullerPosition = pullerXform.MapPosition; + var movingTo = pullable.MovingTo.Value.ToMap(EntityManager, _transform); if (movingTo.MapId != pullerPosition.MapId) { _pullableSystem.StopMoveTo(pullable); continue; } - if (!EntityManager.TryGetComponent(pullable.Owner, out var physics) || + if (!TryComp(pullableEnt, out var physics) || physics.BodyType == BodyType.Static || - movingTo.MapId != EntityManager.GetComponent(pullable.Owner).MapID) + movingTo.MapId != pullableXform.MapID) { _pullableSystem.StopMoveTo(pullable); continue; } var movingPosition = movingTo.Position; - var ownerPosition = EntityManager.GetComponent(pullable.Owner).MapPosition.Position; + var ownerPosition = pullableXform.MapPosition.Position; var diff = movingPosition - ownerPosition; var diffLength = diff.Length; - if (diffLength < MaximumSettleDistance && (physics.LinearVelocity.Length < MaximumSettleVelocity)) + if (diffLength < MaximumSettleDistance && physics.LinearVelocity.Length < MaximumSettleVelocity) { - PhysicsSystem.SetLinearVelocity(pullable.Owner, Vector2.Zero, body: physics); + PhysicsSystem.SetLinearVelocity(pullableEnt, Vector2.Zero, body: physics); _pullableSystem.StopMoveTo(pullable); continue; } @@ -177,17 +178,25 @@ namespace Content.Server.Physics.Controllers // Note the implication that the real rules of physics don't apply to pulling control. var accel = diff.Normalized * multiplier; // Now for the part where velocity gets shutdown... - if ((diffLength < SettleShutdownDistance) && (physics.LinearVelocity.Length >= SettleMinimumShutdownVelocity)) + if (diffLength < SettleShutdownDistance && physics.LinearVelocity.Length >= SettleMinimumShutdownVelocity) { // Shutdown velocity increases as we get closer to centre var scaling = (SettleShutdownDistance - diffLength) / SettleShutdownDistance; accel -= physics.LinearVelocity * SettleShutdownMultiplier * scaling; } - PhysicsSystem.WakeBody(pullable.Owner, body: physics); + PhysicsSystem.WakeBody(pullableEnt, body: physics); var impulse = accel * physics.Mass * frameTime; - PhysicsSystem.ApplyLinearImpulse(pullable.Owner, impulse, body: physics); + PhysicsSystem.ApplyLinearImpulse(pullableEnt, impulse, body: physics); + + // if the puller is weightless, then we apply the inverse impulse. + // doing it under gravity produces an unsatisfying wiggling when pulling. + if (_gravity.IsWeightless(puller) && pullerXform.GridUid == null) + { + PhysicsSystem.WakeBody(puller); + PhysicsSystem.ApplyLinearImpulse(puller, -impulse); + } } } } diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs index 0fc7815d22..7c3d1e4304 100644 --- a/Content.Shared/Maps/ContentTileDefinition.cs +++ b/Content.Shared/Maps/ContentTileDefinition.cs @@ -50,7 +50,7 @@ namespace Content.Shared.Maps /// [DataField("barestepSounds")] public SoundSpecifier? BarestepSounds { get; } = new SoundCollectionSpecifier("BarestepHard"); - [DataField("friction")] public float Friction { get; set; } = 0.3f; + [DataField("friction")] public float Friction { get; set; } = 0.2f; [DataField("variants")] public byte Variants { get; set; } = 1; diff --git a/Content.Shared/Pulling/Components/SharedPullerComponent.cs b/Content.Shared/Pulling/Components/SharedPullerComponent.cs index a2f82f8583..88fe6464e4 100644 --- a/Content.Shared/Pulling/Components/SharedPullerComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullerComponent.cs @@ -5,9 +5,9 @@ public sealed class SharedPullerComponent : Component { // Before changing how this is updated, please see SharedPullerSystem.RefreshMovementSpeed - public float WalkSpeedModifier => Pulling == default ? 1.0f : 0.9f; + public float WalkSpeedModifier => Pulling == default ? 1.0f : 0.95f; - public float SprintSpeedModifier => Pulling == default ? 1.0f : 0.9f; + public float SprintSpeedModifier => Pulling == default ? 1.0f : 0.95f; [ViewVariables] public EntityUid? Pulling { get; set; } diff --git a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs index 5810a9c0ff..e388d7a57c 100644 --- a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs @@ -84,7 +84,7 @@ namespace Content.Shared.Pulling.Systems private void RefreshMovementSpeed(SharedPullerComponent component) { - _movementSpeedModifierSystem.RefreshMovementSpeedModifiers((component).Owner); + _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(component.Owner); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 799eced098..b73565d5b2 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -193,7 +193,7 @@ namespace Content.Shared.Pulling // 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)) + if (pullable.Puller == null && movingTo != null) { return; } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index c7f247452f..6f19d048b4 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -1,9 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared.Alert; using Content.Shared.GameTicking; -using Content.Shared.Gravity; using Content.Shared.Input; -using Content.Shared.Movement.Components; using Content.Shared.Physics.Pull; using Content.Shared.Pulling.Components; using Content.Shared.Verbs; @@ -22,7 +20,6 @@ namespace Content.Shared.Pulling public abstract partial class SharedPullingSystem : EntitySystem { [Dependency] private readonly SharedPullingStateManagementSystem _pullSm = default!; - [Dependency] private readonly SharedGravitySystem _gravity = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly SharedJointSystem _joints = default!; @@ -102,18 +99,22 @@ namespace Content.Shared.Pulling //TODO VERB ICONS add pulling icon if (component.Puller == args.User) { - Verb verb = new(); - verb.Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling"); - verb.Act = () => TryStopPull(component, args.User); - verb.DoContactInteraction = false; // pulling handle its own contact interaction. + Verb verb = new() + { + Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling"), + Act = () => TryStopPull(component, args.User), + DoContactInteraction = false // pulling handle its own contact interaction. + }; args.Verbs.Add(verb); } else if (CanPull(args.User, args.Target)) { - Verb verb = new(); - verb.Text = Loc.GetString("pulling-verb-get-data-text"); - verb.Act = () => TryStartPull(args.User, args.Target); - verb.DoContactInteraction = false; // pulling handle its own contact interaction. + Verb verb = new() + { + Text = Loc.GetString("pulling-verb-get-data-text"), + Act = () => TryStartPull(args.User, args.Target), + DoContactInteraction = false // pulling handle its own contact interaction. + }; args.Verbs.Add(verb); } } @@ -124,7 +125,7 @@ namespace Content.Shared.Pulling if (args.Pulled.Owner != uid) return; - _alertsSystem.ShowAlert(component.Owner, AlertType.Pulled); + _alertsSystem.ShowAlert(uid, AlertType.Pulled); } private void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args) @@ -132,7 +133,7 @@ namespace Content.Shared.Pulling if (args.Pulled.Owner != uid) return; - _alertsSystem.ClearAlert(component.Owner, AlertType.Pulled); + _alertsSystem.ClearAlert(uid, AlertType.Pulled); } public bool IsPulled(EntityUid uid, SharedPullableComponent? component = null) @@ -178,19 +179,17 @@ namespace Content.Shared.Pulling // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. private void HandleContainerInsert(EntInsertedIntoContainerMessage message) { - if (EntityManager.TryGetComponent(message.Entity, out SharedPullableComponent? pullable)) + if (TryComp(message.Entity, out SharedPullableComponent? pullable)) { TryStopPull(pullable); } - if (EntityManager.TryGetComponent(message.Entity, out SharedPullerComponent? puller)) + if (TryComp(message.Entity, out SharedPullerComponent? puller)) { if (puller.Pulling == null) return; - if (!EntityManager.TryGetComponent(puller.Pulling.Value, out SharedPullableComponent? pulling)) - { + if (!TryComp(puller.Pulling.Value, out SharedPullableComponent? pulling)) return; - } TryStopPull(pulling); } @@ -203,17 +202,12 @@ namespace Content.Shared.Pulling return false; if (!TryGetPulled(player, out var pulled)) - { return false; - } - if (!EntityManager.TryGetComponent(pulled.Value, out SharedPullableComponent? pullable)) - { + if (!TryComp(pulled.Value, out SharedPullableComponent? pullable)) return false; - } - if (_containerSystem.IsEntityInContainer(player) || - _gravity.IsWeightless(player)) + if (_containerSystem.IsEntityInContainer(player)) return false; TryMoveTo(pullable, coords); diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml index 4aac9097e7..f39938fd95 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml @@ -41,7 +41,7 @@ shape: !type:PhysShapeAabb bounds: "-0.25,-0.48,0.25,0.48" - density: 145 + density: 75 mask: - MachineMask layer: @@ -257,5 +257,5 @@ - type: Appearance - type: EntityStorageVisuals stateBase: base - stateDoorOpen: base + stateDoorOpen: base stateDoorClosed: closed diff --git a/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml b/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml index 2c433fa54b..af77b771a9 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml @@ -29,7 +29,7 @@ shape: !type:PhysShapeAabb bounds: "-0.4,-0.4,0.4,0.29" - density: 190 + density: 50 mask: - SmallMobMask #this is so they can go under plastic flaps layer: diff --git a/Resources/Prototypes/Tiles/floors.yml b/Resources/Prototypes/Tiles/floors.yml index 9c755fb240..1592b4efdd 100644 --- a/Resources/Prototypes/Tiles/floors.yml +++ b/Resources/Prototypes/Tiles/floors.yml @@ -79,7 +79,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemSteel heatCapacity: 10000 @@ -94,7 +93,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemSteel heatCapacity: 10000 @@ -109,7 +107,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemSteel heatCapacity: 10000 @@ -124,7 +121,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemSteel heatCapacity: 10000 @@ -169,7 +165,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -184,7 +179,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -199,7 +193,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -214,7 +207,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -229,7 +221,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -244,7 +235,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -259,7 +249,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -274,7 +263,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -289,7 +277,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -304,7 +291,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemWhite heatCapacity: 10000 @@ -375,7 +361,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemDark heatCapacity: 10000 @@ -390,7 +375,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemDark heatCapacity: 10000 @@ -405,7 +389,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemDark heatCapacity: 10000 @@ -420,7 +403,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemDark heatCapacity: 10000 @@ -435,7 +417,6 @@ canCrowbar: true footstepSounds: collection: FootstepTile - friction: 0.25 itemDrop: FloorTileItemDark heatCapacity: 10000 @@ -672,7 +653,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemArcadeBlue heatCapacity: 10000 @@ -687,7 +668,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemArcadeBlue2 heatCapacity: 10000 @@ -702,7 +683,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemArcadeRed heatCapacity: 10000 @@ -717,7 +698,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemEighties heatCapacity: 10000 @@ -732,7 +713,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemCarpetClown heatCapacity: 10000 @@ -747,7 +728,7 @@ collection: FootstepCarpet barestepSounds: collection: BarestepCarpet - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemCarpetOffice heatCapacity: 10000 @@ -762,7 +743,7 @@ canCrowbar: true footstepSounds: collection: FootstepFloor - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemBoxing heatCapacity: 10000 @@ -777,7 +758,7 @@ canCrowbar: true footstepSounds: collection: FootstepFloor - friction: 0.40 + friction: 0.25 itemDrop: FloorTileItemGym heatCapacity: 10000 @@ -1136,7 +1117,7 @@ footstepSounds: collection: BarestepCarpet itemDrop: FloorTileItemFlesh - friction: 0.20 #slippy + friction: 0.05 #slippy heatCapacity: 10000 - type: tile diff --git a/Resources/Prototypes/Tiles/plating.yml b/Resources/Prototypes/Tiles/plating.yml index 26f1c56b52..e790e98c6f 100644 --- a/Resources/Prototypes/Tiles/plating.yml +++ b/Resources/Prototypes/Tiles/plating.yml @@ -6,7 +6,7 @@ isSubfloor: true footstepSounds: collection: FootstepPlating - friction: 0.5 + friction: 0.3 heatCapacity: 10000 - type: tile @@ -19,7 +19,7 @@ weather: true footstepSounds: collection: FootstepPlating - friction: 0.5 + friction: 0.3 isSpace: true itemDrop: PartRodMetal1 heatCapacity: 10000