Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Мёртвый Космос, Licensed under custom terms with restrictions on public hosting and commercial use, full text: https://raw.githubusercontent.com/dead-space-server/space-station-14-fobos/master/LICENSE.TXT

using Robust.Shared.Audio;
using Robust.Shared.GameStates;

namespace Content.Shared.DeadSpace.Abilities.Slide;

[RegisterComponent, NetworkedComponent]
public sealed partial class SpeedSlidingComponent : Component
{
[DataField]
public float MinSlideSpeed = 4.9f;

[DataField]
public float SlideDistance = 6.5f;

[DataField]
public float SlideSpeed = 3.5f;

[DataField]
public SoundSpecifier? SlideSound;

[ViewVariables]
public bool IsSliding = false;
}
62 changes: 62 additions & 0 deletions Content.Shared/DeadSpace/Movement/System/SpeedSlidingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Мёртвый Космос, Licensed under custom terms with restrictions on public hosting and commercial use, full text: https://raw.githubusercontent.com/dead-space-server/space-station-14-fobos/master/LICENSE.TXT

using Content.Shared.Standing;
using Content.Shared.Stunnable;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Network;
using System.Numerics;

namespace Content.Shared.DeadSpace.Abilities.Slide;

public sealed class SpeedSlidingSystem : EntitySystem
{
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly INetManager _net = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpeedSlidingComponent, DownAttemptEvent>(OnDownAttempt);
}

private void OnDownAttempt(Entity<SpeedSlidingComponent> ent, ref DownAttemptEvent args)
{
if (ent.Comp.IsSliding || args.Cancelled)
return;

if (!TryComp<PhysicsComponent>(ent.Owner, out var physics))
return;

var velocity = physics.LinearVelocity;
if (velocity.Length() < ent.Comp.MinSlideSpeed)
return;

ent.Comp.IsSliding = true;

try
{
if (_net.IsServer)
{
_stun.TryKnockdown(ent.Owner, TimeSpan.FromSeconds(1.2f), false);
}

var direction = velocity.Normalized();
var impulseMagnitude = ent.Comp.SlideSpeed * ent.Comp.SlideDistance * physics.Mass;
var impulse = direction * impulseMagnitude;

_physics.SetLinearVelocity(ent.Owner, Vector2.Zero);
_physics.ApplyLinearImpulse(ent.Owner, impulse);

_audio.PlayPredicted(ent.Comp.SlideSound, ent.Owner, ent.Owner);
}
finally
{
ent.Comp.IsSliding = false;
}
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.DeadSpace.Abilities.Slide; // DS14
using Content.Shared.Storage.Components;
using Content.Shared.Tag;
using Robust.Shared.Containers;
Expand Down Expand Up @@ -226,6 +227,11 @@ public virtual void DoDrop(Entity<HandsComponent?> ent,
if (!Resolve(ent, ref ent.Comp, false))
return;

//DS14-start
if (TryComp<SpeedSlidingComponent>(ent, out var slide) && slide.IsSliding)
return;
//DS14-end

if (!ContainerSystem.TryGetContainer(ent, handId, out var container))
return;

Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
- DoorBumpOpener
- AnomalyHost
- type: EmoteAnimation # ADT-Emotes
- type: SpeedSliding # DS14
# DS14-Languages-start
- type: Language
selectedLanguage: GeneralLanguage
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Species/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
sprite: Mobs/Species/Human/displacement.rsi
state: jumpsuit-female
# DS14-start
- type: SpeedSliding
slideDistance: 5.5
slideSpeed: 2.5
- type: Sanity
- type: Tag
tags:
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/Species/vulpkanin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
name: Urist McBark
components:
# DS14-start
- type: SpeedSliding
slideDistance: 4
- type: Language
selectedLanguage: GeneralLanguage
knownLanguages:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
knownLanguages:
- ReptilianLanguage
- GeneralLanguage
- type: SpeedSliding
minSlideSpeed: 5.1

- type: entity
parent: BaseSpeciesDummy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
types:
Heat : 0.1 #per second, scales with temperature & other constants
- type: Perishable
- type: Sanity # DS14
- type: Sanity
- type: TypingIndicator
proto: plafeim
- type: Language
Expand All @@ -55,6 +55,8 @@
# - type: FootPrints
# leftBarePrint: "footprint-left-bare-lizard"
# rightBarePrint: "footprint-right-bare-lizard"
- type: SpeedSliding
slideDistance: 8

- type: entity
parent: BaseSpeciesDummy
Expand Down
Loading