* Init Commit * Typos * Commit 2 * Save Interaction Test Mob from failing * ssss * Confident I've gotten all the correct prototypes * Whoops forgot to edit those * aaaaa * Better solution * Test fail fixes * Yaml fix * THE FINAL TEST FIX * Final fix(?) * whoops * Added a WeightlessnessChangedEvent * Check out this diff * Wait I'm dumb * Final optimization and don't duplicate code * Death to IsWeightless * File scoped namespaces * REVIEW * Fix test fails * FIX TEST FAILS REAL * A * Commit of doom * borgar * We don't need to specify on map init apparently * Fuck it * LOAD BEARING COMMENT --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Content.Shared.Gravity;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Movement.Events;
|
|
|
|
namespace Content.Shared.Movement.Systems;
|
|
|
|
public sealed class MovementIgnoreGravitySystem : EntitySystem
|
|
{
|
|
[Dependency] SharedGravitySystem _gravity = default!;
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<MovementAlwaysTouchingComponent, CanWeightlessMoveEvent>(OnWeightless);
|
|
SubscribeLocalEvent<MovementIgnoreGravityComponent, IsWeightlessEvent>(OnIsWeightless);
|
|
SubscribeLocalEvent<MovementIgnoreGravityComponent, ComponentStartup>(OnComponentStartup);
|
|
}
|
|
|
|
private void OnWeightless(Entity<MovementAlwaysTouchingComponent> entity, ref CanWeightlessMoveEvent args)
|
|
{
|
|
args.CanMove = true;
|
|
}
|
|
|
|
private void OnIsWeightless(Entity<MovementIgnoreGravityComponent> entity, ref IsWeightlessEvent args)
|
|
{
|
|
// We don't check if the event has been handled as this component takes precedent over other things.
|
|
|
|
args.IsWeightless = entity.Comp.Weightless;
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnComponentStartup(Entity<MovementIgnoreGravityComponent> entity, ref ComponentStartup args)
|
|
{
|
|
EnsureComp<GravityAffectedComponent>(entity);
|
|
_gravity.RefreshWeightless(entity.Owner, entity.Comp.Weightless);
|
|
}
|
|
}
|