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

Code cleanup: Purge obsoleted SharedPhysicsSystem methods #26287

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -409,7 +409,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
var fixtures = Comp<FixturesComponent>(args.Target);
xform.Anchored = false; // Just in case.
_physics.SetBodyType(args.Target, BodyType.Dynamic, manager: fixtures, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir);
_physics.WakeBody(args.Target, manager: fixtures, body: physics);

foreach (var fixture in fixtures.Fixtures.Values)
Expand All @@ -424,8 +424,8 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)

_physics.SetLinearVelocity(args.Target, _random.NextVector2(1.5f, 1.5f), manager: fixtures, body: physics);
_physics.SetAngularVelocity(args.Target, MathF.PI * 12, manager: fixtures, body: physics);
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(args.Target, physics, 0f);
_physics.SetAngularDamping(args.Target, physics, 0f);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-pinball-description")
Expand All @@ -444,7 +444,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
xform.Anchored = false; // Just in case.

_physics.SetBodyType(args.Target, BodyType.Dynamic, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir);
_physics.WakeBody(args.Target, manager: fixtures, body: physics);

foreach (var fixture in fixtures.Fixtures.Values)
Expand All @@ -454,8 +454,8 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)

_physics.SetLinearVelocity(args.Target, _random.NextVector2(8.0f, 8.0f), manager: fixtures, body: physics);
_physics.SetAngularVelocity(args.Target, MathF.PI * 12, manager: fixtures, body: physics);
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(args.Target, physics, 0f);
_physics.SetAngularDamping(args.Target, physics, 0f);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-yeet-description")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void UpdateHighPressure(float frameTime)
if (HasComp<MobStateComponent>(uid) &&
TryComp<PhysicsComponent>(uid, out var body))
{
_physics.SetBodyStatus(body, BodyStatus.OnGround);
_physics.SetBodyStatus(uid, body, BodyStatus.OnGround);
}

if (TryComp<FixturesComponent>(uid, out var fixtures))
Expand All @@ -77,7 +77,7 @@ private void AddMobMovedByPressure(EntityUid uid, MovedByPressureComponent compo
if (!TryComp<FixturesComponent>(uid, out var fixtures))
return;

_physics.SetBodyStatus(body, BodyStatus.InAir);
_physics.SetBodyStatus(uid, body, BodyStatus.InAir);

foreach (var (id, fixture) in fixtures.Fixtures)
{
Expand All @@ -96,9 +96,9 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
// TODO ATMOS finish this

// Don't play the space wind sound on tiles that are on fire...
if(tile.PressureDifference > 15 && !tile.Hotspot.Valid)
if (tile.PressureDifference > 15 && !tile.Hotspot.Valid)
{
if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
if (_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
{
var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
_audio.PlayPvs(SpaceWindSound, coordinates, AudioParams.Default.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100)));
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void Start(Entity<VaporComponent> vapor, TransformComponent vaporXform, V
// Set Move
if (EntityManager.TryGetComponent(vapor, out PhysicsComponent? physics))
{
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(vapor, physics, 0f);
_physics.SetAngularDamping(vapor, physics, 0f);

_throwing.TryThrow(vapor, dir, speed, user: user);

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/ImmovableRod/ImmovableRodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ private void OnMapInit(EntityUid uid, ImmovableRodComponent component, MapInitEv
{
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? phys))
{
_physics.SetLinearDamping(phys, 0f);
_physics.SetFriction(phys, 0f);
_physics.SetBodyStatus(phys, BodyStatus.InAir);
_physics.SetLinearDamping(uid, phys, 0f);
_physics.SetFriction(uid, phys, 0f);
_physics.SetBodyStatus(uid, phys, BodyStatus.InAir);

if (!component.RandomizeVelocity)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void FireEmitter(EntityUid uid, ParticleAcceleratorPowerState strength,
if (TryComp<PhysicsComponent>(emitted, out var particlePhys))
{
var angle = _transformSystem.GetWorldRotation(uid, xformQuery);
_physicsSystem.SetBodyStatus(particlePhys, BodyStatus.InAir);
_physicsSystem.SetBodyStatus(emitted, particlePhys, BodyStatus.InAir);

var velocity = angle.ToWorldVec() * 20f;
if (TryComp<PhysicsComponent>(uid, out var phys))
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Physics/Controllers/ChasingWalkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ private void ForceImpulse(EntityUid uid, ChasingWalkComponent component)
var speed = delta.Length() > 0 ? delta.Normalized() * component.Speed : Vector2.Zero;

_physics.SetLinearVelocity(uid, speed);
_physics.SetBodyStatus(physics, BodyStatus.InAir); //If this is not done, from the explosion up close, the tesla will "Fall" to the ground, and almost stop moving.
_physics.SetBodyStatus(uid, physics, BodyStatus.InAir); //If this is not done, from the explosion up close, the tesla will "Fall" to the ground, and almost stop moving.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ private void UpdateFTLStarting(Entity<FTLComponent, ShuttleComponent> entity)
Enable(uid, component: body);
_physics.SetLinearVelocity(uid, new Vector2(0f, 20f), body: body);
_physics.SetAngularVelocity(uid, 0f, body: body);
_physics.SetLinearDamping(body, 0f);
_physics.SetAngularDamping(body, 0f);
_physics.SetLinearDamping(uid, body, 0f);
_physics.SetAngularDamping(uid, body, 0f);

_dockSystem.SetDockBolts(uid, true);
_console.RefreshShuttleConsoles(uid);
Expand Down Expand Up @@ -426,8 +426,8 @@ private void UpdateFTLArriving(Entity<FTLComponent, ShuttleComponent> entity)

_physics.SetLinearVelocity(uid, Vector2.Zero, body: body);
_physics.SetAngularVelocity(uid, 0f, body: body);
_physics.SetLinearDamping(body, entity.Comp2.LinearDamping);
_physics.SetAngularDamping(body, entity.Comp2.AngularDamping);
_physics.SetLinearDamping(uid, body, entity.Comp2.LinearDamping);
_physics.SetAngularDamping(uid, body, entity.Comp2.AngularDamping);

var target = entity.Comp1.TargetCoordinates;

Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Shuttles/Systems/ShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ public void Enable(EntityUid uid, FixturesComponent? manager = null, PhysicsComp
return;

_physics.SetBodyType(uid, BodyType.Dynamic, manager: manager, body: component);
_physics.SetBodyStatus(component, BodyStatus.InAir);
_physics.SetBodyStatus(uid, component, BodyStatus.InAir);
_physics.SetFixedRotation(uid, false, manager: manager, body: component);
_physics.SetLinearDamping(component, shuttle.LinearDamping);
_physics.SetAngularDamping(component, shuttle.AngularDamping);
_physics.SetLinearDamping(uid, component, shuttle.LinearDamping);
_physics.SetAngularDamping(uid, component, shuttle.AngularDamping);
}

public void Disable(EntityUid uid, FixturesComponent? manager = null, PhysicsComponent? component = null)
Expand All @@ -141,7 +141,7 @@ public void Disable(EntityUid uid, FixturesComponent? manager = null, PhysicsCom
return;

_physics.SetBodyType(uid, BodyType.Static, manager: manager, body: component);
_physics.SetBodyStatus(component, BodyStatus.OnGround);
_physics.SetBodyStatus(uid, component, BodyStatus.OnGround);
_physics.SetFixedRotation(uid, true, manager: manager, body: component);
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/StationEvents/Events/MeteorSwarmRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ protected override void ActiveTick(EntityUid uid, MeteorSwarmRuleComponent compo
var spawnPosition = new MapCoordinates(center + offset, mapId);
var meteor = Spawn("MeteorLarge", spawnPosition);
var physics = EntityManager.GetComponent<PhysicsComponent>(meteor);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetBodyStatus(meteor, physics, BodyStatus.InAir);
_physics.SetLinearDamping(meteor, physics, 0f);
_physics.SetAngularDamping(meteor, physics, 0f);
_physics.ApplyLinearImpulse(meteor, -offset.Normalized() * component.MeteorVelocity * physics.Mass, body: physics);
_physics.ApplyAngularImpulse(
meteor,
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public bool TryBuckle(EntityUid buckleUid, EntityUid userUid, EntityUid strapUid

if (TryComp<PhysicsComponent>(buckleUid, out var physics))
{
_physics.ResetDynamics(physics);
_physics.ResetDynamics(buckleUid, physics);
}

if (!buckleComp.PullStrap && TryComp<PullableComponent>(strapUid, out var toPullable))
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Movement/Systems/SharedJetpackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void SetupUser(EntityUid user, EntityUid jetpackUid)
_mover.SetRelay(user, jetpackUid);

if (TryComp<PhysicsComponent>(user, out var physics))
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(user, physics, BodyStatus.InAir);

userComp.Jetpack = jetpackUid;
}
Expand All @@ -103,7 +103,7 @@ private void RemoveUser(EntityUid uid)
return;

if (TryComp<PhysicsComponent>(uid, out var physics))
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
_physics.SetBodyStatus(uid, physics, BodyStatus.OnGround);

RemComp<RelayInputMoverComponent>(uid);
}
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Throwing/ThrowingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void TryThrow(EntityUid uid,
}
else
{
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(uid, physics, BodyStatus.InAir);
}

if (user == null)
Expand All @@ -191,10 +191,10 @@ public void TryThrow(EntityUid uid,
{
var msg = new ThrowPushbackAttemptEvent();
RaiseLocalEvent(uid, msg);
const float MassLimit = 5f;
const float massLimit = 5f;

if (!msg.Cancelled)
_physics.ApplyLinearImpulse(user.Value, -impulseVector / physics.Mass * pushbackRatio * MathF.Min(MassLimit, physics.Mass), body: userPhysics);
_physics.ApplyLinearImpulse(user.Value, -impulseVector / physics.Mass * pushbackRatio * MathF.Min(massLimit, physics.Mass), body: userPhysics);
}
}
}
2 changes: 1 addition & 1 deletion Content.Shared/Throwing/ThrownItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent)
{
if (TryComp<PhysicsComponent>(uid, out var physics))
{
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
_physics.SetBodyStatus(uid, physics, BodyStatus.OnGround);

if (physics.Awake)
_broadphase.RegenerateContacts(uid, physics);
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void OnThrownStartup(Entity<MeleeThrownComponent> ent, ref ComponentStar
comp.PreviousStatus = body.BodyStatus;
comp.ThrownEndTime = _timing.CurTime + TimeSpan.FromSeconds(comp.Lifetime);
comp.MinLifetimeTime = _timing.CurTime + TimeSpan.FromSeconds(comp.MinLifetime);
_physics.SetBodyStatus(body, BodyStatus.InAir);
_physics.SetBodyStatus(ent, body, BodyStatus.InAir);
_physics.SetLinearVelocity(ent, Vector2.Zero, body: body);
_physics.ApplyLinearImpulse(ent, comp.Velocity * body.Mass, body: body);
Dirty(ent, ent.Comp);
Expand All @@ -83,7 +83,7 @@ private void OnThrownStartup(Entity<MeleeThrownComponent> ent, ref ComponentStar
private void OnThrownShutdown(Entity<MeleeThrownComponent> ent, ref ComponentShutdown args)
{
if (TryComp<PhysicsComponent>(ent, out var body))
_physics.SetBodyStatus(body,ent.Comp.PreviousStatus);
_physics.SetBodyStatus(ent, body, ent.Comp.PreviousStatus);
var ev = new MeleeThrowOnHitEndEvent();
RaiseLocalEvent(ent, ref ev);
}
Expand Down
10 changes: 5 additions & 5 deletions Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ protected virtual void StartTether(EntityUid gunUid, BaseForceGunComponent compo
TransformSystem.Unanchor(target, targetXform);
component.Tethered = target;
var tethered = EnsureComp<TetheredComponent>(target);
_physics.SetBodyStatus(targetPhysics, BodyStatus.InAir, false);
_physics.SetBodyStatus(target, targetPhysics, BodyStatus.InAir, false);
_physics.SetSleepingAllowed(target, targetPhysics, false);
tethered.Tetherer = gunUid;
tethered.OriginalAngularDamping = targetPhysics.AngularDamping;
_physics.SetAngularDamping(targetPhysics, 0f);
_physics.SetLinearDamping(targetPhysics, 0f);
_physics.SetAngularDamping(target, targetPhysics, 0f);
_physics.SetLinearDamping(target, targetPhysics, 0f);
_physics.SetAngularVelocity(target, SpinVelocity, body: targetPhysics);
_physics.WakeBody(target, body: targetPhysics);
var thrown = EnsureComp<ThrownItemComponent>(component.Tethered.Value);
Expand Down Expand Up @@ -264,9 +264,9 @@ protected virtual void StopTether(EntityUid gunUid, BaseForceGunComponent compon
_thrown.StopThrow(component.Tethered.Value, thrown);
}

_physics.SetBodyStatus(targetPhysics, BodyStatus.OnGround);
_physics.SetBodyStatus(component.Tethered.Value, targetPhysics, BodyStatus.OnGround);
_physics.SetSleepingAllowed(component.Tethered.Value, targetPhysics, true);
_physics.SetAngularDamping(targetPhysics, Comp<TetheredComponent>(component.Tethered.Value).OriginalAngularDamping);
_physics.SetAngularDamping(component.Tethered.Value, targetPhysics, Comp<TetheredComponent>(component.Tethered.Value).OriginalAngularDamping);
}

if (!transfer)
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public abstract void Shoot(
public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocity, EntityUid gunUid, EntityUid? user = null, float speed = 20f)
{
var physics = EnsureComp<PhysicsComponent>(uid);
Physics.SetBodyStatus(physics, BodyStatus.InAir);
Physics.SetBodyStatus(uid, physics, BodyStatus.InAir);

var targetMapVelocity = gunVelocity + direction.Normalized() * speed;
var currentMapVelocity = Physics.GetMapLinearVelocity(uid, physics);
Expand Down
Loading