Skip to content

Commit

Permalink
Fixed some announcements, centcom name change, atmosia fake
Browse files Browse the repository at this point in the history
  • Loading branch information
Eagle-0 committed Apr 29, 2024
1 parent ec92c56 commit c1287b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 41 deletions.
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 All @@ -72,7 +68,7 @@ private void UpdateHighPressure(float frameTime)
}
}

private void AddMobMovedByPressure(EntityUid uid, MovedByPressureComponent component, PhysicsComponent body)
private void AddMovedByPressure(EntityUid uid, MovedByPressureComponent component, PhysicsComponent body)
{
if (!TryComp<FixturesComponent>(uid, out var fixtures))
return;
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 @@ -183,12 +179,13 @@ private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere,
tile.PressureDirection = differenceDirection;
}

//The EE version of this function drops pressureResistanceProbDelta, since it's not needed. If you are for whatever reason calling this function
//And it isn't working, you've probably still got the ResistancePobDelta line included.
public void ExperiencePressureDifference(
Entity<MovedByPressureComponent> ent,
int cycle,
float pressureDifference,
AtmosDirection direction,
float pressureResistanceProbDelta,
EntityCoordinates throwTarget,
Angle gridWorldRotation,
TransformComponent? xform = null,
Expand All @@ -201,55 +198,34 @@ public void ExperiencePressureDifference(
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)
&& physics.Mass != 0)
{
if (HasComp<MobStateComponent>(uid))
{
AddMobMovedByPressure(uid, component, physics);
}
var moveForce = pressureDifference / physics.Mass;

if (maxForce > MovedByPressureComponent.ThrowForce)
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;
moveForce = MathF.Min(moveForce, maxSafeForceForObject);

AddMovedByPressure(uid, component, physics);
// Grid-rotation adjusted direction
var dirVec = (direction.ToAngle() + gridWorldRotation).ToWorldVec();
var maxSafeForceForObject = SpaceWindMaxVelocity * physics.Mass;

// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
if (throwTarget != EntityCoordinates.Invalid)
{
var pos = ((throwTarget.ToMap(EntityManager).Position - xform.WorldPosition).Normalized() + dirVec).Normalized();
_physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
_physics.ApplyLinearImpulse(uid, pos * Math.Clamp(moveForce, 0, maxSafeForceForObject), body: physics);
}
else
{
moveForce = MathF.Min(moveForce, SpaceWindMaxPushForce);
_physics.ApplyLinearImpulse(uid, dirVec * moveForce, body: physics);
_physics.ApplyLinearImpulse(uid, dirVec * Math.Clamp(moveForce, 0, maxSafeForceForObject), body: physics);
}

component.LastHighPressureMovementAirCycle = cycle;
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/shuttles/emergency.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ emergency-shuttle-command-dock-desc = Calls the emergency shuttle and docks it t
emergency-shuttle-command-launch-desc = Early launches the emergency shuttle if possible.
# Emergency shuttle
emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$transitTime} seconds until the shuttle arrives at CentCom.
emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$transitTime} seconds until the shuttle arrives at High Command.
emergency-shuttle-launch-time = The emergency shuttle will launch in {$consoleAccumulator} seconds.
emergency-shuttle-docked = The Emergency Shuttle has docked with the station on the {$direction} side. It will leave in {$time} seconds.
emergency-shuttle-good-luck = The Emergency Shuttle is unable to find a station. Good luck.
Expand Down
2 changes: 1 addition & 1 deletion Resources/Maps/centcomm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ entities:
- uid: 1668
components:
- type: MetaData
name: Central Command
name: High Command
- type: Transform
parent: 434
- type: MapGrid
Expand Down

0 comments on commit c1287b8

Please sign in to comment.