diff --git a/Content.Client/Standing/LayingDownSystem.cs b/Content.Client/Standing/LayingDownSystem.cs index 594883ac001..3a1f438df05 100644 --- a/Content.Client/Standing/LayingDownSystem.cs +++ b/Content.Client/Standing/LayingDownSystem.cs @@ -4,6 +4,7 @@ using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Shared.Timing; +using DrawDepth = Content.Shared.DrawDepth.DrawDepth; namespace Content.Client.Standing; @@ -20,6 +21,8 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnMovementInput); + SubscribeNetworkEvent(OnDowned); + SubscribeLocalEvent(OnStood); SubscribeNetworkEvent(OnCheckAutoGetUp); } @@ -48,6 +51,29 @@ private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveE sprite.Rotation = Angle.FromDegrees(90); } + private void OnDowned(DrawDownedEvent args) + { + var uid = GetEntity(args.Uid); + + if (!TryComp(uid, out var sprite) + || !TryComp(uid, out var component)) + return; + + if (!component.OriginalDrawDepth.HasValue) + component.OriginalDrawDepth = sprite.DrawDepth; + + sprite.DrawDepth = (int) DrawDepth.SmallMobs; + } + + private void OnStood(EntityUid uid, LayingDownComponent component, StoodEvent args) + { + if (!TryComp(uid, out var sprite) + || !component.OriginalDrawDepth.HasValue) + return; + + sprite.DrawDepth = component.OriginalDrawDepth.Value; + } + private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args) { if (!_timing.IsFirstTimePredicted) diff --git a/Content.Server/Flight/FlightSystem.cs b/Content.Server/Flight/FlightSystem.cs index e056fc24ec0..39321b1e66c 100644 --- a/Content.Server/Flight/FlightSystem.cs +++ b/Content.Server/Flight/FlightSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Flight.Events; using Content.Shared.Mobs; using Content.Shared.Popups; +using Content.Shared.Standing; using Content.Shared.Stunnable; using Content.Shared.Zombies; using Robust.Shared.Audio.Systems; @@ -16,6 +17,7 @@ public sealed class FlightSystem : SharedFlightSystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; + [Dependency] private readonly StandingStateSystem _standing = default!; public override void Initialize() { @@ -27,6 +29,7 @@ public override void Initialize() SubscribeLocalEvent(OnZombified); SubscribeLocalEvent(OnKnockedDown); SubscribeLocalEvent(OnStunned); + SubscribeLocalEvent(OnDowned); SubscribeLocalEvent(OnSleep); } public override void Update(float frameTime) @@ -103,6 +106,13 @@ private bool CanFly(EntityUid uid, FlightComponent component) _popupSystem.PopupEntity(Loc.GetString("no-flight-while-zombified"), uid, uid, PopupType.Medium); return false; } + + if (HasComp(uid) && _standing.IsDown(uid)) + { + _popupSystem.PopupEntity(Loc.GetString("no-flight-while-lying"), uid, uid, PopupType.Medium); + return false; + } + return true; } @@ -142,6 +152,14 @@ private void OnStunned(EntityUid uid, FlightComponent component, ref StunnedEven ToggleActive(uid, false, component); } + private void OnDowned(EntityUid uid, FlightComponent component, ref DownedEvent args) + { + if (!component.On) + return; + + ToggleActive(uid, false, component); + } + private void OnSleep(EntityUid uid, FlightComponent component, ref SleepStateChangedEvent args) { if (!component.On diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 417817b5419..1b3bef5e333 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2470,9 +2470,16 @@ public static readonly CVarDef public static readonly CVarDef HoldLookUp = CVarDef.Create("rest.hold_look_up", false, CVar.CLIENT | CVar.ARCHIVE); - + + /// + /// When true, entities that fall to the ground will be able to crawl under tables and + /// plastic flaps, allowing them to take cover from gunshots. + /// + public static readonly CVarDef CrawlUnderTables = + CVarDef.Create("rest.crawlundertables", false, CVar.REPLICATED); + #endregion - + #region Material Reclaimer /// @@ -2498,5 +2505,6 @@ public static readonly CVarDef CVarDef.Create("jetpack.enable_in_no_gravity", true, CVar.REPLICATED); #endregion + } } diff --git a/Content.Shared/Standing/LayingDownComponent.cs b/Content.Shared/Standing/LayingDownComponent.cs index 1499704c53b..363c6f15987 100644 --- a/Content.Shared/Standing/LayingDownComponent.cs +++ b/Content.Shared/Standing/LayingDownComponent.cs @@ -14,6 +14,9 @@ public sealed partial class LayingDownComponent : Component [DataField, AutoNetworkedField] public bool AutoGetUp; + + [DataField, AutoNetworkedField] + public int? OriginalDrawDepth { get; set; } } [Serializable, NetSerializable] @@ -24,3 +27,9 @@ public sealed class CheckAutoGetUpEvent(NetEntity user) : CancellableEntityEvent { public NetEntity User = user; } + +[Serializable, NetSerializable] +public sealed class DrawDownedEvent(NetEntity uid) : EntityEventArgs +{ + public NetEntity Uid = uid; +} diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 69e72033bba..04c0a04547d 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -1,12 +1,15 @@ using Content.Shared.Buckle; using Content.Shared.Buckle.Components; +using Content.Shared.CCVar; using Content.Shared.Hands.Components; using Content.Shared.Movement.Systems; using Content.Shared.Physics; using Content.Shared.Rotation; using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; +using Robust.Shared.Serialization; namespace Content.Shared.Standing; @@ -17,6 +20,7 @@ public sealed class StandingStateSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly MovementSpeedModifierSystem _movement = default!; [Dependency] private readonly SharedBuckleSystem _buckle = default!; + [Dependency] private readonly IConfigurationManager _config = default!; // If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited. private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable; @@ -64,6 +68,10 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true Dirty(standingState); RaiseLocalEvent(uid, new DownedEvent(), false); + // Raising this event will lower the entity's draw depth to the same as a small mob. + if (_config.GetCVar(CCVars.CrawlUnderTables)) + RaiseNetworkEvent(new DrawDownedEvent(GetNetEntity(uid))); + // Seemed like the best place to put it _appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance); diff --git a/Resources/Locale/en-US/flight/flight_system.ftl b/Resources/Locale/en-US/flight/flight_system.ftl index 12693cc8467..3558ab9dc88 100644 --- a/Resources/Locale/en-US/flight/flight_system.ftl +++ b/Resources/Locale/en-US/flight/flight_system.ftl @@ -1,2 +1,3 @@ no-flight-while-restrained = You can't fly right now. -no-flight-while-zombified = You can't use your wings right now. \ No newline at end of file +no-flight-while-zombified = You can't use your wings right now. +no-flight-while-lying = You can't fly right now. \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml b/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml index c1b0cf0423b..dbef5a7504a 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml @@ -20,6 +20,7 @@ - TableMask layer: - TableLayer + - BulletImpassable - type: SpriteFade - type: Sprite - type: Icon @@ -38,7 +39,8 @@ - type: FootstepModifier footstepSoundCollection: collection: FootstepHull - + - type: RequireProjectileTarget + - type: entity id: CounterBase parent: TableBase diff --git a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml index e424b1b40b4..4c8427e46ee 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/Tables/tables.yml @@ -137,7 +137,7 @@ acts: [ "Destruction" ] - trigger: !type:DamageTrigger - damage: 25 + damage: 15 behaviors: - !type:PlaySoundBehavior sound: @@ -178,7 +178,7 @@ acts: [ "Destruction" ] - trigger: !type:DamageTrigger - damage: 25 + damage: 15 behaviors: - !type:PlaySoundBehavior sound: @@ -216,7 +216,7 @@ acts: [ "Destruction" ] - trigger: !type:DamageTrigger - damage: 75 + damage: 30 behaviors: - !type:PlaySoundBehavior sound: @@ -263,7 +263,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 25 + damage: 15 behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] @@ -379,7 +379,7 @@ collection: GlassBreak - trigger: !type:DamageTrigger - damage: 50 + damage: 30 behaviors: - !type:PlaySoundBehavior sound: @@ -426,7 +426,7 @@ acts: [ "Destruction" ] - trigger: !type:DamageTrigger - damage: 25 + damage: 40 behaviors: - !type:PlaySoundBehavior sound: @@ -546,7 +546,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 50 + damage: 40 behaviors: - !type:PlaySoundBehavior sound: @@ -573,7 +573,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 50 + damage: 20 behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] diff --git a/Resources/Prototypes/Entities/Structures/plastic_flaps.yml b/Resources/Prototypes/Entities/Structures/plastic_flaps.yml index c4ee507395f..207305d2327 100644 --- a/Resources/Prototypes/Entities/Structures/plastic_flaps.yml +++ b/Resources/Prototypes/Entities/Structures/plastic_flaps.yml @@ -26,6 +26,7 @@ - TabletopMachineMask layer: - MidImpassable + - BulletImpassable - type: Damageable damageContainer: StructuralInorganic damageModifierSet: Metallic @@ -33,7 +34,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 100 + damage: 50 behaviors: - !type:DoActsBehavior acts: ["Destruction"] @@ -45,7 +46,8 @@ node: plasticFlaps - type: StaticPrice price: 83 - + - type: RequireProjectileTarget + - type: entity id: PlasticFlapsOpaque parent: PlasticFlapsClear @@ -65,6 +67,7 @@ layer: - Opaque - MidImpassable + - BulletImpassable - type: Occluder - type: Construction graph: PlasticFlapsGraph @@ -81,7 +84,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 150 + damage: 75 behaviors: - !type:DoActsBehavior acts: ["Destruction"] @@ -103,7 +106,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 150 + damage: 75 behaviors: - !type:DoActsBehavior acts: ["Destruction"]