InAir tweaks & chasm fixes (#19707)

This commit is contained in:
Kara
2023-09-10 23:03:16 -07:00
committed by GitHub
parent 414755b455
commit 64a29f0d8a
17 changed files with 91 additions and 48 deletions

View File

@@ -15,7 +15,6 @@ public sealed class LavaSystem : EntitySystem
SubscribeLocalEvent<LavaComponent, StepTriggerAttemptEvent>(OnLavaStepTriggerAttempt); SubscribeLocalEvent<LavaComponent, StepTriggerAttemptEvent>(OnLavaStepTriggerAttempt);
} }
private void OnLavaStepTriggerAttempt(EntityUid uid, LavaComponent component, ref StepTriggerAttemptEvent args) private void OnLavaStepTriggerAttempt(EntityUid uid, LavaComponent component, ref StepTriggerAttemptEvent args)
{ {
if (!HasComp<FlammableComponent>(args.Tripper)) if (!HasComp<FlammableComponent>(args.Tripper))

View File

@@ -1,4 +1,5 @@
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Buckle.Components;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.StepTrigger.Systems; using Content.Shared.StepTrigger.Systems;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -51,18 +52,22 @@ public sealed class ChasmSystem : EntitySystem
if (HasComp<ChasmFallingComponent>(args.Tripper)) if (HasComp<ChasmFallingComponent>(args.Tripper))
return; 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; falling.NextDeletionTime = _timing.CurTime + falling.DeletionTime;
_blocker.UpdateCanMove(args.Tripper); _blocker.UpdateCanMove(tripper);
_audio.PlayPredicted(component.FallingSound, uid, args.Tripper);
if (playSound)
_audio.PlayPredicted(component.FallingSound, chasm, tripper);
} }
private void OnStepTriggerAttempt(EntityUid uid, ChasmComponent component, ref StepTriggerAttemptEvent args) 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; args.Continue = true;
} }

View File

@@ -0,0 +1,12 @@
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
{
}

View File

@@ -6,6 +6,8 @@ using Content.Shared.Movement.Events;
using Content.Shared.Popups; using Content.Shared.Popups;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Movement.Systems; namespace Content.Shared.Movement.Systems;
@@ -17,6 +19,7 @@ public abstract class SharedJetpackSystem : EntitySystem
[Dependency] protected readonly SharedContainerSystem Container = default!; [Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] private readonly SharedMoverController _mover = default!; [Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -98,6 +101,10 @@ public abstract class SharedJetpackSystem : EntitySystem
{ {
var userComp = EnsureComp<JetpackUserComponent>(user); var userComp = EnsureComp<JetpackUserComponent>(user);
_mover.SetRelay(user, jetpackUid); _mover.SetRelay(user, jetpackUid);
if (TryComp<PhysicsComponent>(user, out var physics))
_physics.SetBodyStatus(physics, BodyStatus.InAir);
userComp.Jetpack = jetpackUid; userComp.Jetpack = jetpackUid;
} }
@@ -106,6 +113,9 @@ public abstract class SharedJetpackSystem : EntitySystem
if (!RemComp<JetpackUserComponent>(uid)) if (!RemComp<JetpackUserComponent>(uid))
return; return;
if (TryComp<PhysicsComponent>(uid, out var physics))
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
RemComp<RelayInputMoverComponent>(uid); RemComp<RelayInputMoverComponent>(uid);
} }

View File

@@ -53,6 +53,7 @@ namespace Content.Shared.Movement.Systems
protected EntityQuery<RelayInputMoverComponent> RelayQuery; protected EntityQuery<RelayInputMoverComponent> RelayQuery;
protected EntityQuery<SharedPullableComponent> PullableQuery; protected EntityQuery<SharedPullableComponent> PullableQuery;
protected EntityQuery<TransformComponent> XformQuery; protected EntityQuery<TransformComponent> XformQuery;
protected EntityQuery<CanMoveInAirComponent> CanMoveInAirQuery;
private const float StepSoundMoveDistanceRunning = 2; private const float StepSoundMoveDistanceRunning = 2;
private const float StepSoundMoveDistanceWalking = 1.5f; private const float StepSoundMoveDistanceWalking = 1.5f;
@@ -83,6 +84,7 @@ namespace Content.Shared.Movement.Systems
RelayQuery = GetEntityQuery<RelayInputMoverComponent>(); RelayQuery = GetEntityQuery<RelayInputMoverComponent>();
PullableQuery = GetEntityQuery<SharedPullableComponent>(); PullableQuery = GetEntityQuery<SharedPullableComponent>();
XformQuery = GetEntityQuery<TransformComponent>(); XformQuery = GetEntityQuery<TransformComponent>();
CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
InitializeFootsteps(); InitializeFootsteps();
InitializeInput(); InitializeInput();
@@ -150,27 +152,16 @@ namespace Content.Shared.Movement.Systems
LerpRotation(uid, mover, frameTime); LerpRotation(uid, mover, frameTime);
if (!canMove if (!canMove
|| physicsComponent.BodyStatus != BodyStatus.OnGround || physicsComponent.BodyStatus != BodyStatus.OnGround && !CanMoveInAirQuery.HasComponent(uid)
|| PullableQuery.TryGetComponent(uid, out var pullable) && pullable.BeingPulled) || PullableQuery.TryGetComponent(uid, out var pullable) && pullable.BeingPulled)
{ {
UsedMobMovement[uid] = false; UsedMobMovement[uid] = false;
return; 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; UsedMobMovement[uid] = true;
// Specifically don't use mover.Owner because that may be different to the actual physics body being moved. // 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 weightless = _gravity.IsWeightless(physicsUid, physicsComponent, xform);
var (walkDir, sprintDir) = GetVelocityInput(mover); var (walkDir, sprintDir) = GetVelocityInput(mover);
var touching = false; var touching = false;
@@ -193,6 +184,18 @@ namespace Content.Shared.Movement.Systems
} }
} }
// 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. // Regular movement.
// Target velocity. // Target velocity.
// This is relative to the map / grid we're on. // This is relative to the map / grid we're on.

View File

@@ -354,7 +354,6 @@ public abstract class SharedSingularitySystem : EntitySystem
/// <param name="args">The event arguments.</param> /// <param name="args">The event arguments.</param>
private void UpdateBody(EntityUid uid, PhysicsComponent comp, SingularityLevelChangedEvent args) 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. 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. _physics.SetLinearVelocity(uid, Vector2.Zero, body: comp); // No idea how stopping the singularities movement keeps it from getting stuck though.
} }

View File

@@ -42,10 +42,17 @@ public sealed partial class StepTriggerComponent : Component
public float RequiredTriggerSpeed = 3.5f; public float RequiredTriggerSpeed = 3.5f;
/// <summary> /// <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> /// </summary>
[DataField("blacklist")] [DataField("blacklist")]
public EntityWhitelist? 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] [RegisterComponent]

View File

@@ -1,3 +1,4 @@
using Content.Shared.Gravity;
using Content.Shared.StepTrigger.Components; using Content.Shared.StepTrigger.Components;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
@@ -10,6 +11,7 @@ namespace Content.Shared.StepTrigger.Systems;
public sealed class StepTriggerSystem : EntitySystem public sealed class StepTriggerSystem : EntitySystem
{ {
[Dependency] private readonly EntityLookupSystem _entityLookup = default!; [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -121,6 +123,13 @@ public sealed class StepTriggerSystem : EntitySystem
if (!component.Active || component.CurrentlySteppedOn.Contains(otherUid)) if (!component.Active || component.CurrentlySteppedOn.Contains(otherUid))
return false; 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 }; var msg = new StepTriggerAttemptEvent { Source = uid, Tripper = otherUid };
RaiseLocalEvent(uid, ref msg, true); RaiseLocalEvent(uid, ref msg, true);

View File

@@ -1,6 +1,6 @@
- type: entity - type: entity
name: bat name: bat
parent: SimpleMobBase parent: [ SimpleMobBase, FlyingMobBase ]
id: MobBat id: MobBat
description: Some cultures find them terrifying, others crunchy on the teeth. description: Some cultures find them terrifying, others crunchy on the teeth.
components: components:
@@ -13,7 +13,6 @@
- map: ["enum.DamageStateVisualLayers.Base"] - map: ["enum.DamageStateVisualLayers.Base"]
state: bat state: bat
sprite: Mobs/Animals/bat.rsi sprite: Mobs/Animals/bat.rsi
- type: Physics
- type: Speech - type: Speech
speechSounds: Squeak speechSounds: Squeak
speechVerb: SmallMob speechVerb: SmallMob
@@ -59,7 +58,6 @@
damage: damage:
types: types:
Piercing: 5 Piercing: 5
- type: NoSlip
- type: Puller - type: Puller
needsHands: true needsHands: true
- type: Tag - type: Tag
@@ -68,7 +66,7 @@
- type: entity - type: entity
name: bee name: bee
parent: SimpleMobBase parent: [ SimpleMobBase, FlyingMobBase ]
id: MobBee id: MobBee
description: Nice to have, but you can't build a civilization on a foundation of honey alone. description: Nice to have, but you can't build a civilization on a foundation of honey alone.
components: components:
@@ -82,7 +80,6 @@
- map: ["enum.DamageStateVisualLayers.Base"] - map: ["enum.DamageStateVisualLayers.Base"]
state: 0 state: 0
sprite: Mobs/Animals/bee.rsi sprite: Mobs/Animals/bee.rsi
- type: Physics
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -112,7 +109,6 @@
- Bee - Bee
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 0.1 bloodMaxVolume: 0.1
- type: NoSlip
- type: MobPrice - type: MobPrice
price: 50 price: 50
- type: Puller - type: Puller
@@ -354,7 +350,7 @@
- type: entity - type: entity
name: butterfly name: butterfly
parent: SimpleMobBase parent: [ SimpleMobBase, FlyingMobBase ]
id: MobButterfly id: MobButterfly
description: Despite popular misconceptions, it's not actually made of butter. description: Despite popular misconceptions, it's not actually made of butter.
components: components:
@@ -367,7 +363,6 @@
- map: ["enum.DamageStateVisualLayers.Base"] - map: ["enum.DamageStateVisualLayers.Base"]
state: butterfly state: butterfly
sprite: Mobs/Animals/butterfly.rsi sprite: Mobs/Animals/butterfly.rsi
- type: Physics
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -396,7 +391,6 @@
Base: dead Base: dead
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 0.1 bloodMaxVolume: 0.1
- type: NoSlip
- type: MobPrice - type: MobPrice
price: 50 price: 50
- type: Puller - type: Puller
@@ -1233,7 +1227,7 @@
# Would be cool to have some functionality for the parrot to be able to sit on stuff # Would be cool to have some functionality for the parrot to be able to sit on stuff
- type: entity - type: entity
name: parrot name: parrot
parent: SimpleMobBase parent: [ SimpleMobBase, FlyingMobBase ]
id: MobParrot id: MobParrot
description: Infiltrates your domain, spies on you, and somehow still a cool pet. description: Infiltrates your domain, spies on you, and somehow still a cool pet.
components: components:
@@ -1246,7 +1240,6 @@
- map: ["enum.DamageStateVisualLayers.Base"] - map: ["enum.DamageStateVisualLayers.Base"]
state: parrot state: parrot
sprite: Mobs/Animals/parrot.rsi sprite: Mobs/Animals/parrot.rsi
- type: Physics
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -1276,7 +1269,6 @@
path: /Audio/Animals/parrot_raught.ogg path: /Audio/Animals/parrot_raught.ogg
- type: Bloodstream - type: Bloodstream
bloodMaxVolume: 50 bloodMaxVolume: 50
- type: NoSlip
- type: entity - type: entity
name: penguin name: penguin

View File

@@ -1,6 +1,6 @@
- type: entity - type: entity
name: behonker name: behonker
parent: SimpleSpaceMobBase parent: [ SimpleSpaceMobBase, FlyingMobBase ]
id: BaseMobBehonker id: BaseMobBehonker
abstract: true abstract: true
description: A floating demon aspect of the honkmother. description: A floating demon aspect of the honkmother.
@@ -70,8 +70,6 @@
groups: groups:
- id: Medicine - id: Medicine
- id: Poison - id: Poison
- type: MovementAlwaysTouching
- type: NoSlip
- type: Butcherable - type: Butcherable
spawned: spawned:
- id: MaterialBananium1 - id: MaterialBananium1

View File

@@ -1,7 +1,7 @@
- type: entity - type: entity
name: space carp name: space carp
id: BaseMobCarp id: BaseMobCarp
parent: SimpleSpaceMobBase parent: [ SimpleSpaceMobBase, FlyingMobBase ]
description: It's a space carp. description: It's a space carp.
abstract: true abstract: true
components: components:
@@ -42,7 +42,6 @@
50: Dead 50: Dead
- type: Stamina - type: Stamina
critThreshold: 100 critThreshold: 100
- type: MovementAlwaysTouching
- type: DamageStateVisuals - type: DamageStateVisuals
states: states:
Alive: Alive:
@@ -68,7 +67,6 @@
Slash: 10 Slash: 10
- type: TypingIndicator - type: TypingIndicator
proto: alien proto: alien
- type: NoSlip
- type: Tag - type: Tag
tags: tags:
- Carp - Carp

View File

@@ -0,0 +1,11 @@
# 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

View File

@@ -1,7 +1,7 @@
- type: entity - type: entity
name: watcher name: watcher
id: MobWatcherBase id: MobWatcherBase
parent: SimpleSpaceMobBase parent: [ SimpleSpaceMobBase, FlyingMobBase ]
abstract: true abstract: true
description: It's like its staring right through you. description: It's like its staring right through you.
components: components:
@@ -46,8 +46,6 @@
- type: MovementSpeedModifier - type: MovementSpeedModifier
baseWalkSpeed: 5 baseWalkSpeed: 5
baseSprintSpeed: 7 baseSprintSpeed: 7
- type: MovementAlwaysTouching
- type: NoSlip
- type: ProjectileBatteryAmmoProvider - type: ProjectileBatteryAmmoProvider
proto: WatcherBolt proto: WatcherBolt
fireCost: 50 fireCost: 50

View File

@@ -1,5 +1,5 @@
- type: entity - type: entity
parent: SimpleSpaceMobBase parent: [ SimpleSpaceMobBase, FlyingMobBase ]
id: BaseMobDragon id: BaseMobDragon
suffix: "" suffix: ""
name: space dragon name: space dragon
@@ -90,8 +90,6 @@
groups: groups:
- id: Medicine - id: Medicine
- id: Poison - id: Poison
- type: MovementAlwaysTouching
- type: NoSlip
- type: Butcherable - type: Butcherable
spawned: spawned:
- id: FoodMeatDragon - id: FoodMeatDragon

View File

@@ -10,9 +10,6 @@
- type: MindContainer - type: MindContainer
- type: Clickable - type: Clickable
- type: InteractionOutline - type: InteractionOutline
- type: Physics
bodyType: KinematicController
fixedRotation: true
- type: Fixtures - type: Fixtures
fixtures: fixtures:
fix1: fix1:
@@ -60,6 +57,10 @@
baseSprintSpeed: 12 baseSprintSpeed: 12
baseWalkSpeed: 8 baseWalkSpeed: 8
- type: MovementIgnoreGravity - type: MovementIgnoreGravity
- type: Physics
bodyType: KinematicController
bodyStatus: InAir
- type: CanMoveInAir
- type: Tag - type: Tag
tags: tags:
- BypassInteractionRangeChecks - BypassInteractionRangeChecks

View File

@@ -31,6 +31,7 @@
weightlessAcceleration: 1 weightlessAcceleration: 1
weightlessFriction: 0.3 weightlessFriction: 0.3
weightlessModifier: 1.2 weightlessModifier: 1.2
- type: CanMoveInAir
- type: Sprite - type: Sprite
sprite: Objects/Tanks/Jetpacks/blue.rsi sprite: Objects/Tanks/Jetpacks/blue.rsi
state: icon state: icon

View File

@@ -11,6 +11,8 @@
path: /Audio/Effects/singularity.ogg path: /Audio/Effects/singularity.ogg
- type: Physics - type: Physics
bodyType: Dynamic bodyType: Dynamic
bodyStatus: InAir
- type: CanMoveInAir
- type: EventHorizon # To make the singularity consume things. - type: EventHorizon # To make the singularity consume things.
radius: 0.5 radius: 0.5
canBreachContainment: false canBreachContainment: false