]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
`InAir` tweaks & chasm fixes (#19707)
authorKara <lunarautomaton6@gmail.com>
Mon, 11 Sep 2023 06:03:16 +0000 (23:03 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Sep 2023 06:03:16 +0000 (16:03 +1000)
17 files changed:
Content.Server/Tiles/LavaSystem.cs
Content.Shared/Chasm/ChasmSystem.cs
Content.Shared/Movement/Components/CanMoveInAirComponent.cs [new file with mode: 0644]
Content.Shared/Movement/Systems/SharedJetpackSystem.cs
Content.Shared/Movement/Systems/SharedMoverController.cs
Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs
Content.Shared/StepTrigger/Components/StepTriggerComponent.cs
Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs
Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Resources/Prototypes/Entities/Mobs/NPCs/behonker.yml
Resources/Prototypes/Entities/Mobs/NPCs/carp.yml
Resources/Prototypes/Entities/Mobs/NPCs/flying_animals.yml [new file with mode: 0644]
Resources/Prototypes/Entities/Mobs/NPCs/lavaland.yml
Resources/Prototypes/Entities/Mobs/Player/dragon.yml
Resources/Prototypes/Entities/Mobs/Player/observer.yml
Resources/Prototypes/Entities/Objects/Tools/jetpacks.yml
Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml

index bdba76784ea18cfc76ae84b55458e12228a4452b..7aee0b65010a01695d9c3eadc901612b8f03b729 100644 (file)
@@ -15,7 +15,6 @@ public sealed class LavaSystem : EntitySystem
         SubscribeLocalEvent<LavaComponent, StepTriggerAttemptEvent>(OnLavaStepTriggerAttempt);
     }
 
-
     private void OnLavaStepTriggerAttempt(EntityUid uid, LavaComponent component, ref StepTriggerAttemptEvent args)
     {
         if (!HasComp<FlammableComponent>(args.Tripper))
index 123fa5b9982c01e75bf8df900402385d848b1f61..7353bd0e9c74c6a6aa36ef9f53dcd4339f349759 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Shared.ActionBlocker;
+using Content.Shared.Buckle.Components;
 using Content.Shared.Movement.Events;
 using Content.Shared.StepTrigger.Systems;
 using Robust.Shared.Network;
@@ -51,18 +52,22 @@ public sealed class ChasmSystem : EntitySystem
         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;
     }
 
diff --git a/Content.Shared/Movement/Components/CanMoveInAirComponent.cs b/Content.Shared/Movement/Components/CanMoveInAirComponent.cs
new file mode 100644 (file)
index 0000000..9d24661
--- /dev/null
@@ -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
+{
+}
index f5516d9ec97a2922d67a3632192724a1763ab11c..26373da25679d2e6eb5ecfbde21342397f8955e9 100644 (file)
@@ -6,6 +6,8 @@ using Content.Shared.Movement.Events;
 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;
@@ -17,6 +19,7 @@ public abstract class SharedJetpackSystem : EntitySystem
     [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()
     {
@@ -98,6 +101,10 @@ public abstract class SharedJetpackSystem : EntitySystem
     {
         var userComp = EnsureComp<JetpackUserComponent>(user);
         _mover.SetRelay(user, jetpackUid);
+
+        if (TryComp<PhysicsComponent>(user, out var physics))
+            _physics.SetBodyStatus(physics, BodyStatus.InAir);
+
         userComp.Jetpack = jetpackUid;
     }
 
@@ -106,6 +113,9 @@ public abstract class SharedJetpackSystem : EntitySystem
         if (!RemComp<JetpackUserComponent>(uid))
             return;
 
+        if (TryComp<PhysicsComponent>(uid, out var physics))
+            _physics.SetBodyStatus(physics, BodyStatus.OnGround);
+
         RemComp<RelayInputMoverComponent>(uid);
     }
 
index 725cc274c03a6cab11cc72ffd1fda49d88472409..2b95b5909f9889069ab6710adaeac145211e3988 100644 (file)
@@ -53,6 +53,7 @@ namespace Content.Shared.Movement.Systems
         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;
@@ -83,6 +84,7 @@ namespace Content.Shared.Movement.Systems
             RelayQuery = GetEntityQuery<RelayInputMoverComponent>();
             PullableQuery = GetEntityQuery<SharedPullableComponent>();
             XformQuery = GetEntityQuery<TransformComponent>();
+            CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
 
             InitializeFootsteps();
             InitializeInput();
@@ -150,27 +152,16 @@ namespace Content.Shared.Movement.Systems
             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;
@@ -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.
             // Target velocity.
             // This is relative to the map / grid we're on.
index 676987b0175f2b06096bbdf565d1e38c6ee847f6..56be197e1df4dac779b4a4ae09e8f3ad03391564 100644 (file)
@@ -354,7 +354,6 @@ public abstract class SharedSingularitySystem : EntitySystem
     /// <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.
     }
index 7c84e54bdc48ad696ae82bf83ca975a7e302a3b0..21cf5397a1f8fb440f322545ba031ee5fc6634c1 100644 (file)
@@ -42,10 +42,17 @@ public sealed partial class StepTriggerComponent : Component
     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]
index 081262de0f3f26f87d526805de5e40e953a07ebc..335d9bea9f4f060a7672e19ba20a76d835828322 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Shared.Gravity;
 using Content.Shared.StepTrigger.Components;
 using Robust.Shared.GameStates;
 using Robust.Shared.Map.Components;
@@ -10,6 +11,7 @@ namespace Content.Shared.StepTrigger.Systems;
 public sealed class StepTriggerSystem : EntitySystem
 {
     [Dependency] private readonly EntityLookupSystem _entityLookup = default!;
+    [Dependency] private readonly SharedGravitySystem _gravity = default!;
 
     public override void Initialize()
     {
@@ -121,6 +123,13 @@ public sealed class StepTriggerSystem : EntitySystem
         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);
index 7ff922bc0128018fd4982e8db8a3c002ad0b20be..bd339291f0b45d7352c76cb3988176c4844c7d65 100644 (file)
@@ -1,6 +1,6 @@
 - type: entity
   name: bat
-  parent: SimpleMobBase
+  parent: [ SimpleMobBase, FlyingMobBase ]
   id: MobBat
   description: Some cultures find them terrifying, others crunchy on the teeth.
   components:
@@ -13,7 +13,6 @@
     - map: ["enum.DamageStateVisualLayers.Base"]
       state: bat
       sprite: Mobs/Animals/bat.rsi
-  - type: Physics
   - type: Speech
     speechSounds: Squeak
     speechVerb: SmallMob
@@ -59,7 +58,6 @@
     damage:
       types:
         Piercing: 5
-  - type: NoSlip
   - type: Puller
     needsHands: true
   - type: Tag
@@ -68,7 +66,7 @@
 
 - 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:
@@ -82,7 +80,6 @@
     - 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
index a613c7c4ad0a3964fa40bebde9f5229ab4d7e5be..cb7b9f4c015501e65c8453fc8e22dc89fbdb0b6e 100644 (file)
@@ -1,6 +1,6 @@
 - type: entity
   name: behonker
-  parent: SimpleSpaceMobBase
+  parent: [ SimpleSpaceMobBase, FlyingMobBase ]
   id: BaseMobBehonker
   abstract: true
   description: A floating demon aspect of the honkmother.
@@ -70,8 +70,6 @@
       groups:
         - id: Medicine
         - id: Poison
-    - type: MovementAlwaysTouching
-    - type: NoSlip
     - type: Butcherable
       spawned:
         - id: MaterialBananium1
index 6c088d7f758072acc7141c49144b21b1783a23a7..2d490ddb1c840abdf7d4396af9f9ab14a1476b31 100644 (file)
@@ -1,7 +1,7 @@
 - type: entity
   name: space carp
   id: BaseMobCarp
-  parent: SimpleSpaceMobBase
+  parent: [ SimpleSpaceMobBase, FlyingMobBase ]
   description: It's a space carp.
   abstract: true
   components:
@@ -42,7 +42,6 @@
         50: Dead
     - type: Stamina
       critThreshold: 100
-    - type: MovementAlwaysTouching
     - type: DamageStateVisuals
       states:
         Alive:
@@ -68,7 +67,6 @@
           Slash: 10
     - type: TypingIndicator
       proto: alien
-    - type: NoSlip
     - type: Tag
       tags:
         - Carp
diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/flying_animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/flying_animals.yml
new file mode 100644 (file)
index 0000000..c6846b8
--- /dev/null
@@ -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
index aa6d63820b93d43678c615a15394c8d19976a4ae..23cc31a179cc138fe36797a86408b8d96a9f2328 100644 (file)
@@ -1,7 +1,7 @@
 - type: entity
   name: watcher
   id: MobWatcherBase
-  parent: SimpleSpaceMobBase
+  parent: [ SimpleSpaceMobBase, FlyingMobBase ]
   abstract: true
   description: It's like its staring right through you.
   components:
@@ -46,8 +46,6 @@
   - type: MovementSpeedModifier
     baseWalkSpeed: 5
     baseSprintSpeed: 7
-  - type: MovementAlwaysTouching
-  - type: NoSlip
   - type: ProjectileBatteryAmmoProvider
     proto: WatcherBolt
     fireCost: 50
index 9ef481583f54b461256ab7298b439061cf30cbd0..2d64a0a531c6a6cd4c2af9428923f119f6f9aa29 100644 (file)
@@ -1,5 +1,5 @@
 - type: entity
-  parent: SimpleSpaceMobBase
+  parent: [ SimpleSpaceMobBase, FlyingMobBase ]
   id: BaseMobDragon
   suffix: ""
   name: space dragon
@@ -90,8 +90,6 @@
     groups:
     - id: Medicine
     - id: Poison
-  - type: MovementAlwaysTouching
-  - type: NoSlip
   - type: Butcherable
     spawned:
     - id: FoodMeatDragon
index 9752d45c35359f4918c5c09573d6fafb87a589a3..1a90b0cb50b388154668768305068f3295d5aee0 100644 (file)
@@ -10,9 +10,6 @@
   - 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
index 6870ca5f0dddf5eb866dd7ab112318a5759ed543..cbe47a17bda404198b0693065f678640682dc155 100644 (file)
@@ -31,6 +31,7 @@
       weightlessAcceleration: 1
       weightlessFriction: 0.3
       weightlessModifier: 1.2
+    - type: CanMoveInAir
     - type: Sprite
       sprite: Objects/Tanks/Jetpacks/blue.rsi
       state: icon
index d2fea2870a001c4e7d84e10e903a956e891f9369..25d219ab9459fe2f82ac72355d040d102b5dc20b 100644 (file)
@@ -11,6 +11,8 @@
       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