EVENT BASED WEIGHTLESSNESS (#37971)
* 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>
This commit is contained in:
committed by
GitHub
parent
5cd9ba6016
commit
9de76e70c7
@@ -1,33 +1,35 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public sealed class MovementIgnoreGravitySystem : EntitySystem
|
||||
{
|
||||
[Dependency] SharedGravitySystem _gravity = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<MovementIgnoreGravityComponent, ComponentGetState>(GetState);
|
||||
SubscribeLocalEvent<MovementIgnoreGravityComponent, ComponentHandleState>(HandleState);
|
||||
SubscribeLocalEvent<MovementAlwaysTouchingComponent, CanWeightlessMoveEvent>(OnWeightless);
|
||||
SubscribeLocalEvent<MovementIgnoreGravityComponent, IsWeightlessEvent>(OnIsWeightless);
|
||||
SubscribeLocalEvent<MovementIgnoreGravityComponent, ComponentStartup>(OnComponentStartup);
|
||||
}
|
||||
|
||||
private void OnWeightless(EntityUid uid, MovementAlwaysTouchingComponent component, ref CanWeightlessMoveEvent args)
|
||||
private void OnWeightless(Entity<MovementAlwaysTouchingComponent> entity, ref CanWeightlessMoveEvent args)
|
||||
{
|
||||
args.CanMove = true;
|
||||
}
|
||||
|
||||
private void HandleState(EntityUid uid, MovementIgnoreGravityComponent component, ref ComponentHandleState args)
|
||||
private void OnIsWeightless(Entity<MovementIgnoreGravityComponent> entity, ref IsWeightlessEvent args)
|
||||
{
|
||||
if (args.Next is null)
|
||||
return;
|
||||
// We don't check if the event has been handled as this component takes precedent over other things.
|
||||
|
||||
component.Weightless = ((MovementIgnoreGravityComponentState) args.Next).Weightless;
|
||||
args.IsWeightless = entity.Comp.Weightless;
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void GetState(EntityUid uid, MovementIgnoreGravityComponent component, ref ComponentGetState args)
|
||||
private void OnComponentStartup(Entity<MovementIgnoreGravityComponent> entity, ref ComponentStartup args)
|
||||
{
|
||||
args.State = new MovementIgnoreGravityComponentState(component);
|
||||
EnsureComp<GravityAffectedComponent>(entity);
|
||||
_gravity.RefreshWeightless(entity.Owner, entity.Comp.Weightless);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user