Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics Based Air Throws #342

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4212fbb
Physics based air throws
VMSolidus Apr 29, 2024
bddb87b
Update base_structureclosets.yml
VMSolidus Apr 29, 2024
162c284
Updates for review
VMSolidus Apr 29, 2024
3374757
Hello, this is an asymptote. Divide by zero must be an exit condition.
VMSolidus Apr 29, 2024
3dc71fb
Adding the clamp back in
VMSolidus Apr 29, 2024
b3c503c
I found another small optimization
VMSolidus May 1, 2024
68e0510
Another one
VMSolidus May 1, 2024
9e7aa5d
New Cvar
VMSolidus May 4, 2024
3d03262
Update comments for documentation
VMSolidus May 4, 2024
67fdaff
Apply suggestions from code review
VMSolidus May 6, 2024
6cc4704
MORE
VMSolidus May 16, 2024
54ca8ce
Update AtmosphereSystem.HighPressureDelta.cs
VMSolidus May 16, 2024
7500efd
guh, last push
VMSolidus May 16, 2024
3440636
Merge branch 'Simple-Station:master' into Atmos-optimization-test
VMSolidus May 16, 2024
7470ba7
Fix for objects getting stuck on walls, new CVar for more expensive a…
VMSolidus May 16, 2024
b328725
Update animals.yml
VMSolidus May 16, 2024
f7e2f70
Fix tiny mobs boiling themselves to death
VMSolidus May 16, 2024
53d221f
Merge branch 'master' into Atmos-optimization-test
VMSolidus May 29, 2024
eba2d1d
Merge branch 'master' into Atmos-optimization-test
VMSolidus May 29, 2024
7c1ba29
Merge branch 'master' into Atmos-optimization-test
VMSolidus Jun 11, 2024
9d81e24
Initial Beta for Rip Tile Rework
VMSolidus Jun 12, 2024
70a9345
Tentative fixes for wall quantum tunneling
VMSolidus Jun 12, 2024
4d1cf7d
More fixes
VMSolidus Jun 12, 2024
c9286a5
Update CCVars.cs
VMSolidus Jun 12, 2024
9c00871
Update CCVars.cs
VMSolidus Jun 12, 2024
adf3745
Apply suggestions from code review
VMSolidus Jun 16, 2024
351c4ec
Add System for making Humanoids get thrown harder
VMSolidus Jun 25, 2024
9b544bf
Update CCVars.cs
VMSolidus Jun 25, 2024
c9eadac
1984 move by pressure, reroute to ThrowingSystem because its more adv…
VMSolidus Jun 25, 2024
bc25b78
This is significantly smoother
VMSolidus Jun 25, 2024
c5946ee
Update AtmosphereSystem.HighPressureDelta.cs
VMSolidus Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Audio;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;

namespace Content.Server.Atmos.EntitySystems
Expand Down Expand Up @@ -51,8 +48,7 @@ private void UpdateHighPressure(float frameTime)
comp.Accumulator = 0f;
toRemove.Add(ent);

if (HasComp<MobStateComponent>(uid) &&
TryComp<PhysicsComponent>(uid, out var body))
if (TryComp<PhysicsComponent>(uid, out var body))
{
_physics.SetBodyStatus(body, BodyStatus.OnGround);
}
Expand Down Expand Up @@ -162,7 +158,7 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
(entity, pressureMovements),
gridAtmosphere.Comp.UpdateCounter,
tile.PressureDifference,
tile.PressureDirection, 0,
tile.PressureDirection,
tile.PressureSpecificTarget != null ? _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.PressureSpecificTarget.GridIndices) : EntityCoordinates.Invalid,
gridWorldRotation,
xforms.GetComponent(entity),
Expand All @@ -188,7 +184,6 @@ private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere,
int cycle,
float pressureDifference,
AtmosDirection direction,
float pressureResistanceProbDelta,
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
EntityCoordinates throwTarget,
Angle gridWorldRotation,
TransformComponent? xform = null,
Expand All @@ -201,37 +196,14 @@ private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere,
if (!Resolve(uid, ref xform))
return;

// TODO ATMOS stuns?

var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
var moveProb = 100f;

if (component.PressureResistance > 0)
moveProb = MathF.Abs((pressureDifference / component.PressureResistance * MovedByPressureComponent.ProbabilityBasePercent) -
MovedByPressureComponent.ProbabilityOffset);

// Can we yeet the thing (due to probability, strength, etc.)
if (moveProb > MovedByPressureComponent.ProbabilityOffset && _robustRandom.Prob(MathF.Min(moveProb / 100f, 1f))
&& !float.IsPositiveInfinity(component.MoveResist)
&& (physics.BodyType != BodyType.Static
&& (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForcePushRatio)))
|| (physics.BodyType == BodyType.Static && (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForceForcePushRatio))))
if (physics.BodyType != BodyType.Static && !float.IsPositiveInfinity(component.MoveResist))
{
if (HasComp<MobStateComponent>(uid))
{
AddMobMovedByPressure(uid, component, physics);
}
var moveForce = pressureDifference / physics.Mass;

if (maxForce > MovedByPressureComponent.ThrowForce)
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
if (moveForce > physics.Mass)
{
var moveForce = maxForce;
moveForce /= (throwTarget != EntityCoordinates.Invalid) ? SpaceWindPressureForceDivisorThrow : SpaceWindPressureForceDivisorPush;
moveForce *= MathHelper.Clamp(moveProb, 0, 100);

// Apply a sanity clamp to prevent being thrown through objects.
var maxSafeForceForObject = SpaceWindMaxVelocity * physics.Mass;
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
moveForce = MathF.Min(moveForce, maxSafeForceForObject);

AddMobMovedByPressure(uid, component, physics);
VMSolidus marked this conversation as resolved.
Show resolved Hide resolved
// Grid-rotation adjusted direction
var dirVec = (direction.ToAngle() + gridWorldRotation).ToWorldVec();

Expand All @@ -243,7 +215,6 @@ private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere,
}
else
{
moveForce = MathF.Min(moveForce, SpaceWindMaxPushForce);
_physics.ApplyLinearImpulse(uid, dirVec * moveForce, body: physics);
}

Expand Down
Loading