SubscribeLocalEvent<LavaComponent, StepTriggerAttemptEvent>(OnLavaStepTriggerAttempt);
}
-
private void OnLavaStepTriggerAttempt(EntityUid uid, LavaComponent component, ref StepTriggerAttemptEvent args)
{
if (!HasComp<FlammableComponent>(args.Tripper))
using Content.Shared.ActionBlocker;
+using Content.Shared.Buckle.Components;
using Content.Shared.Movement.Events;
using Content.Shared.StepTrigger.Systems;
using Robust.Shared.Network;
if (HasComp<ChasmFallingComponent>(args.Tripper))
return;
- var falling = AddComp<ChasmFallingComponent>(args.Tripper);
+ StartFalling(uid, component, args.Tripper);
+ }
+
+ public void StartFalling(EntityUid chasm, ChasmComponent component, EntityUid tripper, bool playSound = true)
+ {
+ var falling = AddComp<ChasmFallingComponent>(tripper);
falling.NextDeletionTime = _timing.CurTime + falling.DeletionTime;
- _blocker.UpdateCanMove(args.Tripper);
- _audio.PlayPredicted(component.FallingSound, uid, args.Tripper);
+ _blocker.UpdateCanMove(tripper);
+
+ if (playSound)
+ _audio.PlayPredicted(component.FallingSound, chasm, tripper);
}
private void OnStepTriggerAttempt(EntityUid uid, ChasmComponent component, ref StepTriggerAttemptEvent args)
{
- if (TryComp<PhysicsComponent>(args.Tripper, out var physics) && physics.BodyStatus == BodyStatus.InAir)
- return;
-
args.Continue = true;
}
--- /dev/null
+using Robust.Shared.GameStates;
+using Robust.Shared.Physics.Components;
+
+namespace Content.Shared.Movement.Components;
+
+/// <summary>
+/// On mobs that are allowed to move while their body status is <see cref="BodyStatus.InAir"/>
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class CanMoveInAirComponent : Component
+{
+}
using Content.Shared.Popups;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
+using Robust.Shared.Physics.Components;
+using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;
namespace Content.Shared.Movement.Systems;
[Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
{
var userComp = EnsureComp<JetpackUserComponent>(user);
_mover.SetRelay(user, jetpackUid);
+
+ if (TryComp<PhysicsComponent>(user, out var physics))
+ _physics.SetBodyStatus(physics, BodyStatus.InAir);
+
userComp.Jetpack = jetpackUid;
}
if (!RemComp<JetpackUserComponent>(uid))
return;
+ if (TryComp<PhysicsComponent>(uid, out var physics))
+ _physics.SetBodyStatus(physics, BodyStatus.OnGround);
+
RemComp<RelayInputMoverComponent>(uid);
}
protected EntityQuery<RelayInputMoverComponent> RelayQuery;
protected EntityQuery<SharedPullableComponent> PullableQuery;
protected EntityQuery<TransformComponent> XformQuery;
+ protected EntityQuery<CanMoveInAirComponent> CanMoveInAirQuery;
private const float StepSoundMoveDistanceRunning = 2;
private const float StepSoundMoveDistanceWalking = 1.5f;
RelayQuery = GetEntityQuery<RelayInputMoverComponent>();
PullableQuery = GetEntityQuery<SharedPullableComponent>();
XformQuery = GetEntityQuery<TransformComponent>();
+ CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
InitializeFootsteps();
InitializeInput();
LerpRotation(uid, mover, frameTime);
if (!canMove
- || physicsComponent.BodyStatus != BodyStatus.OnGround
+ || physicsComponent.BodyStatus != BodyStatus.OnGround && !CanMoveInAirQuery.HasComponent(uid)
|| PullableQuery.TryGetComponent(uid, out var pullable) && pullable.BeingPulled)
{
UsedMobMovement[uid] = false;
return;
}
- // Get current tile def for things like speed/weightless mods
- ContentTileDefinition? tileDef = null;
-
- if (_mapManager.TryFindGridAt(xform.MapPosition, out var grid, out var gridComp)
- && _mapSystem.TryGetTileRef(grid, gridComp, xform.Coordinates, out var tile))
- {
- tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
- }
UsedMobMovement[uid] = true;
// Specifically don't use mover.Owner because that may be different to the actual physics body being moved.
-
- // We differentiate between grav/other sources of weightless for tiles which want to use weightless accel (like ice)
- // but don't care about requiring touching etc
var weightless = _gravity.IsWeightless(physicsUid, physicsComponent, xform);
var (walkDir, sprintDir) = GetVelocityInput(mover);
var touching = false;
}
}
+ // Get current tile def for things like speed/friction mods
+ ContentTileDefinition? tileDef = null;
+
+ // Don't bother getting the tiledef here if we're weightless or in-air
+ // since no tile-based modifiers should be applying in that situation
+ if (_mapManager.TryFindGridAt(xform.MapPosition, out var grid, out var gridComp)
+ && _mapSystem.TryGetTileRef(grid, gridComp, xform.Coordinates, out var tile)
+ && !(weightless || physicsComponent.BodyStatus == BodyStatus.InAir))
+ {
+ tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
+ }
+
// Regular movement.
// Target velocity.
// This is relative to the map / grid we're on.
/// <param name="args">The event arguments.</param>
private void UpdateBody(EntityUid uid, PhysicsComponent comp, SingularityLevelChangedEvent args)
{
- _physics.SetBodyStatus(comp, (args.NewValue > 1) ? BodyStatus.InAir : BodyStatus.OnGround);
if (args.NewValue <= 1 && args.OldValue > 1) // Apparently keeps singularities from getting stuck in the corners of containment fields.
_physics.SetLinearVelocity(uid, Vector2.Zero, body: comp); // No idea how stopping the singularities movement keeps it from getting stuck though.
}
public float RequiredTriggerSpeed = 3.5f;
/// <summary>
- /// If any entities occupy the blacklist on the same tile then steptrigger won't work.
+ /// If any entities occupy the blacklist on the same tile then steptrigger won't work.
/// </summary>
[DataField("blacklist")]
public EntityWhitelist? Blacklist;
+
+ /// <summary>
+ /// If this is true, steptrigger will still occur on entities that are in air / weightless. They do not
+ /// by default.
+ /// </summary>
+ [DataField("ignoreWeightless")]
+ public bool IgnoreWeightless = false;
}
[RegisterComponent]
+using Content.Shared.Gravity;
using Content.Shared.StepTrigger.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Map.Components;
public sealed class StepTriggerSystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
+ [Dependency] private readonly SharedGravitySystem _gravity = default!;
public override void Initialize()
{
if (!component.Active || component.CurrentlySteppedOn.Contains(otherUid))
return false;
+ // Can't trigger if we don't ignore weightless entities
+ // and the entity is flying or currently weightless
+ // Makes sense simulation wise to have this be part of steptrigger directly IMO
+ if (!component.IgnoreWeightless && TryComp<PhysicsComponent>(otherUid, out var physics) &&
+ (physics.BodyStatus == BodyStatus.InAir || _gravity.IsWeightless(otherUid, physics)))
+ return false;
+
var msg = new StepTriggerAttemptEvent { Source = uid, Tripper = otherUid };
RaiseLocalEvent(uid, ref msg, true);
- type: entity
name: bat
- parent: SimpleMobBase
+ parent: [ SimpleMobBase, FlyingMobBase ]
id: MobBat
description: Some cultures find them terrifying, others crunchy on the teeth.
components:
- map: ["enum.DamageStateVisualLayers.Base"]
state: bat
sprite: Mobs/Animals/bat.rsi
- - type: Physics
- type: Speech
speechSounds: Squeak
speechVerb: SmallMob
damage:
types:
Piercing: 5
- - type: NoSlip
- type: Puller
needsHands: true
- type: Tag
- type: entity
name: bee
- parent: SimpleMobBase
+ parent: [ SimpleMobBase, FlyingMobBase ]
id: MobBee
description: Nice to have, but you can't build a civilization on a foundation of honey alone.
components:
- map: ["enum.DamageStateVisualLayers.Base"]
state: 0
sprite: Mobs/Animals/bee.rsi
- - type: Physics
- type: Fixtures
fixtures:
fix1:
- Bee
- type: Bloodstream
bloodMaxVolume: 0.1
- - type: NoSlip
- type: MobPrice
price: 50
- type: Puller
- type: entity
name: butterfly
- parent: SimpleMobBase
+ parent: [ SimpleMobBase, FlyingMobBase ]
id: MobButterfly
description: Despite popular misconceptions, it's not actually made of butter.
components:
- map: ["enum.DamageStateVisualLayers.Base"]
state: butterfly
sprite: Mobs/Animals/butterfly.rsi
- - type: Physics
- type: Fixtures
fixtures:
fix1:
Base: dead
- type: Bloodstream
bloodMaxVolume: 0.1
- - type: NoSlip
- type: MobPrice
price: 50
- type: Puller
# Would be cool to have some functionality for the parrot to be able to sit on stuff
- type: entity
name: parrot
- parent: SimpleMobBase
+ parent: [ SimpleMobBase, FlyingMobBase ]
id: MobParrot
description: Infiltrates your domain, spies on you, and somehow still a cool pet.
components:
- map: ["enum.DamageStateVisualLayers.Base"]
state: parrot
sprite: Mobs/Animals/parrot.rsi
- - type: Physics
- type: Fixtures
fixtures:
fix1:
path: /Audio/Animals/parrot_raught.ogg
- type: Bloodstream
bloodMaxVolume: 50
- - type: NoSlip
- type: entity
name: penguin
- type: entity
name: behonker
- parent: SimpleSpaceMobBase
+ parent: [ SimpleSpaceMobBase, FlyingMobBase ]
id: BaseMobBehonker
abstract: true
description: A floating demon aspect of the honkmother.
groups:
- id: Medicine
- id: Poison
- - type: MovementAlwaysTouching
- - type: NoSlip
- type: Butcherable
spawned:
- id: MaterialBananium1
- type: entity
name: space carp
id: BaseMobCarp
- parent: SimpleSpaceMobBase
+ parent: [ SimpleSpaceMobBase, FlyingMobBase ]
description: It's a space carp.
abstract: true
components:
50: Dead
- type: Stamina
critThreshold: 100
- - type: MovementAlwaysTouching
- type: DamageStateVisuals
states:
Alive:
Slash: 10
- type: TypingIndicator
proto: alien
- - type: NoSlip
- type: Tag
tags:
- Carp
--- /dev/null
+# Used for entities that are considered flying,
+# i.e. shouldnt slip, have free movement in weightlesness, and should go over chasms/lava
+- type: entity
+ id: FlyingMobBase
+ abstract: true
+ components:
+ - type: Physics
+ bodyStatus: InAir
+ - type: NoSlip
+ - type: MovementAlwaysTouching
+ - type: CanMoveInAir
- type: entity
name: watcher
id: MobWatcherBase
- parent: SimpleSpaceMobBase
+ parent: [ SimpleSpaceMobBase, FlyingMobBase ]
abstract: true
description: It's like its staring right through you.
components:
- type: MovementSpeedModifier
baseWalkSpeed: 5
baseSprintSpeed: 7
- - type: MovementAlwaysTouching
- - type: NoSlip
- type: ProjectileBatteryAmmoProvider
proto: WatcherBolt
fireCost: 50
- type: entity
- parent: SimpleSpaceMobBase
+ parent: [ SimpleSpaceMobBase, FlyingMobBase ]
id: BaseMobDragon
suffix: ""
name: space dragon
groups:
- id: Medicine
- id: Poison
- - type: MovementAlwaysTouching
- - type: NoSlip
- type: Butcherable
spawned:
- id: FoodMeatDragon
- type: MindContainer
- type: Clickable
- type: InteractionOutline
- - type: Physics
- bodyType: KinematicController
- fixedRotation: true
- type: Fixtures
fixtures:
fix1:
baseSprintSpeed: 12
baseWalkSpeed: 8
- type: MovementIgnoreGravity
+ - type: Physics
+ bodyType: KinematicController
+ bodyStatus: InAir
+ - type: CanMoveInAir
- type: Tag
tags:
- BypassInteractionRangeChecks
weightlessAcceleration: 1
weightlessFriction: 0.3
weightlessModifier: 1.2
+ - type: CanMoveInAir
- type: Sprite
sprite: Objects/Tanks/Jetpacks/blue.rsi
state: icon
path: /Audio/Effects/singularity.ogg
- type: Physics
bodyType: Dynamic
+ bodyStatus: InAir
+ - type: CanMoveInAir
- type: EventHorizon # To make the singularity consume things.
radius: 0.5
canBreachContainment: false