@@ -104,6 +104,9 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
104
104
}
105
105
}
106
106
107
+ // Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
108
+ var gridWorldRotation = xforms . GetComponent ( gridAtmosphere . Owner ) . WorldRotation ;
109
+
107
110
foreach ( var entity in _lookup . GetEntitiesIntersecting ( tile . GridIndex , tile . GridIndices ) )
108
111
{
109
112
// Ideally containers would have their own EntityQuery internally or something given recursively it may need to slam GetComp<T> anyway.
@@ -125,6 +128,7 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
125
128
tile . PressureDifference ,
126
129
tile . PressureDirection , 0 ,
127
130
tile . PressureSpecificTarget ? . GridIndices . ToEntityCoordinates ( tile . GridIndex , _mapManager ) ?? EntityCoordinates . Invalid ,
131
+ gridWorldRotation ,
128
132
xforms . GetComponent ( entity ) ,
129
133
body ) ;
130
134
}
@@ -140,6 +144,7 @@ private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileA
140
144
_spaceWindSoundCooldown = 0 ;
141
145
}
142
146
147
+ // Called from AtmosphereSystem.LINDA.cs with SpaceWind CVar check handled there.
143
148
private void ConsiderPressureDifference ( GridAtmosphereComponent gridAtmosphere , TileAtmosphere tile , TileAtmosphere other , float difference )
144
149
{
145
150
gridAtmosphere . HighPressureDelta . Add ( tile ) ;
@@ -157,6 +162,7 @@ public void ExperiencePressureDifference(
157
162
AtmosDirection direction ,
158
163
float pressureResistanceProbDelta ,
159
164
EntityCoordinates throwTarget ,
165
+ Angle gridWorldRotation ,
160
166
TransformComponent ? xform = null ,
161
167
PhysicsComponent ? physics = null )
162
168
{
@@ -188,18 +194,28 @@ public void ExperiencePressureDifference(
188
194
189
195
if ( maxForce > MovedByPressureComponent . ThrowForce )
190
196
{
197
+ var moveForce = maxForce ;
198
+ moveForce /= ( throwTarget != EntityCoordinates . Invalid ) ? SpaceWindPressureForceDivisorThrow : SpaceWindPressureForceDivisorPush ;
199
+ moveForce *= MathHelper . Clamp ( moveProb , 0 , 100 ) ;
200
+
201
+ // Apply a sanity clamp to prevent being thrown through objects.
202
+ var maxSafeForceForObject = SpaceWindMaxVelocity * physics . Mass ;
203
+ moveForce = MathF . Min ( moveForce , maxSafeForceForObject ) ;
204
+
205
+ // Grid-rotation adjusted direction
206
+ var dirVec = ( direction . ToAngle ( ) + gridWorldRotation ) . ToWorldVec ( ) ;
207
+
191
208
// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
192
209
if ( throwTarget != EntityCoordinates . Invalid )
193
210
{
194
- var moveForce = maxForce * MathHelper . Clamp ( moveProb , 0 , 100 ) / 15f ;
195
- var pos = ( ( throwTarget . Position - xform . Coordinates . Position ) . Normalized + direction . ToDirection ( ) . ToVec ( ) ) . Normalized ;
211
+ var pos = ( ( throwTarget . ToMap ( EntityManager ) . Position - xform . WorldPosition ) . Normalized + dirVec ) . Normalized ;
196
212
physics . ApplyLinearImpulse ( pos * moveForce ) ;
197
213
}
198
214
199
215
else
200
216
{
201
- var moveForce = MathF . Min ( maxForce * MathHelper . Clamp ( moveProb , 0 , 100 ) / 2500f , 20f ) ;
202
- physics . ApplyLinearImpulse ( direction . ToDirection ( ) . ToVec ( ) * moveForce ) ;
217
+ moveForce = MathF . Min ( moveForce , SpaceWindMaxPushForce ) ;
218
+ physics . ApplyLinearImpulse ( dirVec * moveForce ) ;
203
219
}
204
220
205
221
component . LastHighPressureMovementAirCycle = cycle ;
0 commit comments