Skip to content

Commit

Permalink
little bobby tables
Browse files Browse the repository at this point in the history
  • Loading branch information
gluesniffler committed Sep 20, 2024
1 parent 7bce1e9 commit 0d78a12
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 15 deletions.
27 changes: 27 additions & 0 deletions Content.Client/Standing/LayingDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,6 +21,8 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput);
SubscribeNetworkEvent<DownedEvent>(OnDowned);
SubscribeLocalEvent<LayingDownComponent, StoodEvent>(OnStood);

SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp);
}
Expand Down Expand Up @@ -48,6 +51,30 @@ private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveE
sprite.Rotation = Angle.FromDegrees(90);
}

private void OnDowned(DownedEvent ev, EntitySessionEventArgs args)
{
if (!args.SenderSession.AttachedEntity.HasValue)
return;

var uid = args.SenderSession.AttachedEntity.Value;

if (!TryComp<SpriteComponent>(uid, out var sprite) || !TryComp<LayingDownComponent>(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<SpriteComponent>(uid, out var sprite) || !component.OriginalDrawDepth.HasValue)
return;

sprite.DrawDepth = component.OriginalDrawDepth.Value;
}

private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args)
{
if (!_timing.IsFirstTimePredicted)
Expand Down
12 changes: 10 additions & 2 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2470,9 +2470,16 @@ public static readonly CVarDef<float>

public static readonly CVarDef<bool> HoldLookUp =
CVarDef.Create("rest.hold_look_up", false, CVar.CLIENT | CVar.ARCHIVE);


/// <summary>
/// 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.
/// </summary>
public static readonly CVarDef<bool> CrawlUnderTables =
CVarDef.Create("rest.crawlundertables", false, CVar.REPLICATED);

#endregion

#region Material Reclaimer

/// <summary>
Expand All @@ -2498,5 +2505,6 @@ public static readonly CVarDef<float>
CVarDef.Create("jetpack.enable_in_no_gravity", true, CVar.REPLICATED);

#endregion

}
}
3 changes: 3 additions & 0 deletions Content.Shared/Standing/LayingDownComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public sealed partial class LayingDownComponent : Component

[DataField, AutoNetworkedField]
public bool AutoGetUp;

[DataField, AutoNetworkedField]
public int? OriginalDrawDepth { get; set; }
}

[Serializable, NetSerializable]
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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 DownedEvent(), uid);

// Seemed like the best place to put it
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance);

Expand Down Expand Up @@ -157,4 +165,6 @@ public sealed class StoodEvent : EntityEventArgs { }
/// <summary>
/// Raised when an entity is not standing
/// </summary>

[Serializable, NetSerializable]
public sealed class DownedEvent : EntityEventArgs { }
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- TableMask
layer:
- TableLayer
- BulletImpassable
- type: SpriteFade
- type: Sprite
- type: Icon
Expand All @@ -38,7 +39,8 @@
- type: FootstepModifier
footstepSoundCollection:
collection: FootstepHull

- type: RequireProjectileTarget

- type: entity
id: CounterBase
parent: TableBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
acts: [ "Destruction" ]
- trigger:
!type:DamageTrigger
damage: 25
damage: 15
behaviors:
- !type:PlaySoundBehavior
sound:
Expand Down Expand Up @@ -178,7 +178,7 @@
acts: [ "Destruction" ]
- trigger:
!type:DamageTrigger
damage: 25
damage: 15
behaviors:
- !type:PlaySoundBehavior
sound:
Expand Down Expand Up @@ -216,7 +216,7 @@
acts: [ "Destruction" ]
- trigger:
!type:DamageTrigger
damage: 75
damage: 30
behaviors:
- !type:PlaySoundBehavior
sound:
Expand Down Expand Up @@ -263,7 +263,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 25
damage: 15
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
Expand Down Expand Up @@ -379,7 +379,7 @@
collection: GlassBreak
- trigger:
!type:DamageTrigger
damage: 50
damage: 30
behaviors:
- !type:PlaySoundBehavior
sound:
Expand Down Expand Up @@ -426,7 +426,7 @@
acts: [ "Destruction" ]
- trigger:
!type:DamageTrigger
damage: 25
damage: 40
behaviors:
- !type:PlaySoundBehavior
sound:
Expand Down Expand Up @@ -546,7 +546,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 50
damage: 40
behaviors:
- !type:PlaySoundBehavior
sound:
Expand All @@ -573,7 +573,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 50
damage: 20
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
Expand Down
11 changes: 7 additions & 4 deletions Resources/Prototypes/Entities/Structures/plastic_flaps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
- TabletopMachineMask
layer:
- MidImpassable
- BulletImpassable
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: Metallic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 100
damage: 50
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
Expand All @@ -45,7 +46,8 @@
node: plasticFlaps
- type: StaticPrice
price: 83

- type: RequireProjectileTarget

- type: entity
id: PlasticFlapsOpaque
parent: PlasticFlapsClear
Expand All @@ -65,6 +67,7 @@
layer:
- Opaque
- MidImpassable
- BulletImpassable
- type: Occluder
- type: Construction
graph: PlasticFlapsGraph
Expand All @@ -81,7 +84,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 150
damage: 75
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
Expand All @@ -103,7 +106,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 150
damage: 75
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
Expand Down

0 comments on commit 0d78a12

Please sign in to comment.