Skip to content

Commit

Permalink
Merge pull request #4 from spess-empyrean/cherrypicking
Browse files Browse the repository at this point in the history
Cherry-picks some commits from Wizden Codebase
  • Loading branch information
spess-empyrean authored Jan 11, 2025
2 parents 7f32e00 + 3c4ee31 commit c774009
Show file tree
Hide file tree
Showing 12 changed files with 556 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Content.IntegrationTests/Tests/Movement/PullingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task PullTest()
var pullable = Comp<PullableComponent>(Target);

// Player is initially to the left of the target and not pulling anything
Assert.That(Delta(), Is.InRange(0.9f, 1.1f));
Assert.That(Delta(), Is.InRange(0.8f, 1.1f));
Assert.That(puller.Pulling, Is.Null);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);
Expand All @@ -39,7 +39,7 @@ public async Task PullTest()

// Move to the left and check that the target moves with the player and is still being pulled.
await Move(DirectionFlag.West, 1);
Assert.That(Delta(), Is.InRange(0.9f, 1.3f));
Assert.That(Delta(), Is.InRange(0.8f, 1.3f));
Assert.That(puller.Pulling, Is.EqualTo(STarget));
Assert.That(pullable.Puller, Is.EqualTo(SPlayer));
Assert.That(pullable.BeingPulled, Is.True);
Expand All @@ -48,7 +48,7 @@ public async Task PullTest()

// Move in the other direction
await Move(DirectionFlag.East, 2);
Assert.That(Delta(), Is.InRange(-1.3f, -0.9f));
Assert.That(Delta(), Is.InRange(-1.3f, -0.8f));
Assert.That(puller.Pulling, Is.EqualTo(STarget));
Assert.That(pullable.Puller, Is.EqualTo(SPlayer));
Assert.That(pullable.BeingPulled, Is.True);
Expand All @@ -58,7 +58,7 @@ public async Task PullTest()
// Stop pulling
await PressKey(ContentKeyFunctions.ReleasePulledObject);
await RunTicks(5);
Assert.That(Delta(), Is.InRange(-1.3f, -0.9f));
Assert.That(Delta(), Is.InRange(-1.3f, -0.8f));
Assert.That(puller.Pulling, Is.Null);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Content.Server.Chemistry.TileReactions
public sealed partial class SpillTileReaction : ITileReaction
{
[DataField("launchForwardsMultiplier")] private float _launchForwardsMultiplier = 1;
[DataField("requiredSlipSpeed")] private float _requiredSlipSpeed = 6;
[DataField("requiredSlipSpeed")] private float _requiredSlipSpeed = 9;
[DataField("paralyzeTime")] private float _paralyzeTime = 1;

/// <summary>
Expand Down
45 changes: 43 additions & 2 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Content.Shared.Weapons.Melee;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
Expand Down Expand Up @@ -95,13 +96,53 @@ private void OnActivateInWorld(EntityUid uid, AbsorbentComponent component, User

private void OnAfterInteract(EntityUid uid, AbsorbentComponent component, AfterInteractEvent args)
{
if (!args.CanReach || args.Handled || args.Target == null)
if (!args.CanReach || args.Handled)
return;

Mop(args.User, args.Target.Value, args.Used, component);
if (args.Target == null)
{
SpillMop(args.User, args.ClickLocation, args.Used, component);
}
else
{
Mop(args.User, args.Target.Value, args.Used, component);
}

args.Handled = true;
}

public void SpillMop(EntityUid user, EntityCoordinates clickLocation, EntityUid used, AbsorbentComponent component)
{
if (!_solutionContainerSystem.TryGetSolution(used, AbsorbentComponent.SolutionName, out var absorberSoln))
{
return;
}

if (TryComp<UseDelayComponent>(used, out var useDelay)
&& _useDelay.IsDelayed((used, useDelay)))
return;

var solution = absorberSoln.Value.Comp.Solution;
// spill 20% of the mop contents down to 1u, then floor(1, remaining)
var spillAmount = solution.Volume > 5 ?
solution.Volume * 0.2
: solution.Volume > 1 ?
1
: solution.Volume;


if (spillAmount == FixedPoint2.Zero)
return;

var spill = _solutionContainerSystem.SplitSolution(absorberSoln.Value, spillAmount);

if (!_puddleSystem.TrySpillAt(clickLocation, spill, out _))
{
// failed to create puddle, put the solution back in the absorber
_solutionContainerSystem.TryAddSolution(absorberSoln.Value, spill);
}
}

public void Mop(EntityUid user, EntityUid target, EntityUid used, AbsorbentComponent component)
{
if (!_solutionContainerSystem.TryGetSolution(used, AbsorbentComponent.SolutionName, out var absorberSoln))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ public sealed partial class MovementSpeedModifierComponent : Component
// Weightless
public const float DefaultMinimumFrictionSpeed = 0.005f;
public const float DefaultWeightlessFriction = 1f;
public const float DefaultWeightlessFrictionNoInput = 0f;
public const float DefaultWeightlessFrictionNoInput = 0.2f;
public const float DefaultOffGridFriction = 0.05f;
public const float DefaultWeightlessModifier = 0.7f;
public const float DefaultWeightlessAcceleration = 1f;

public const float DefaultAcceleration = 20f;
public const float DefaultFriction = 20f;
public const float DefaultFrictionNoInput = 20f;

public const float DefaultBaseWalkSpeed = 3f;
public const float DefaultBaseSprintSpeed = 5f;
public const float DefaultBaseWalkSpeed = 4.0f;
public const float DefaultBaseSprintSpeed = 7.0f;

[AutoNetworkedField, ViewVariables]
public float WalkSpeedModifier = 1.0f;
Expand Down Expand Up @@ -72,6 +73,12 @@ private float _baseSprintSpeedVV
[ViewVariables(VVAccess.ReadWrite), DataField]
public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput;

/// <summary>
/// The negative velocity applied for friction when weightless and not standing on a grid or mapgrid
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public float OffGridFriction = DefaultOffGridFriction;

/// <summary>
/// The movement speed modifier applied to a mob's total input velocity when weightless.
/// </summary>
Expand Down
58 changes: 58 additions & 0 deletions Content.Shared/Movement/Components/TileMovementComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Numerics;
using Content.Shared.Movement.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Map;

namespace Content.Shared.TileMovement;

/// <summary>
/// When attached to an entity with an InputMoverComponent, all mob movement on that entity will
/// be tile-based. Contains info used to facilitate that movement.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class TileMovementComponent : Component
{
/// <summary>
/// Whether a tile movement slide is currently in progress.
/// </summary>
[AutoNetworkedField]
public bool SlideActive;

/// <summary>
/// Local coordinates from which the current slide first began.
/// </summary>
[AutoNetworkedField]
public EntityCoordinates Origin;

/// <summary>
/// Local coordinates of the target of the current slide.
/// </summary>
[AutoNetworkedField]
public Vector2 Destination;

/// <summary>
/// This helps determine how long a slide should last. A slide will continue so long
/// as a movement key (WASD) is being held down, but if it was held down for less than
/// a certain time period then it will continue for a minimum period.
/// </summary>
[AutoNetworkedField]
public TimeSpan? MovementKeyInitialDownTime;

/// <summary>
/// Move buttons used to initiate the current slide.
/// </summary>
[AutoNetworkedField]
public MoveButtons CurrentSlideMoveButtons;

/// <summary>
/// Local coordinates of the entity on the last physics tick.
/// </summary>
[AutoNetworkedField]
public Vector2 LastTickPosition;

/// <summary>
/// Whether this entity was weightless last physics tick.
/// </summary>
[AutoNetworkedField]
public bool WasWeightlessLastTick;
}
Loading

0 comments on commit c774009

Please sign in to comment.