Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

ЛЯЖАНИЯ 4 #341

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Content.Server/Nyanotrasen/Carrying/CarryingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Storage;
using Content.Shared.LieDown;
using Robust.Shared.Map.Components;

namespace Content.Server.Carrying
Expand All @@ -46,6 +47,7 @@ public sealed class CarryingSystem : EntitySystem
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
[Dependency] private readonly PseudoItemSystem _pseudoItem = default!;
[Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
[Dependency] private readonly SharedLieDownSystem _lieDown = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -279,7 +281,8 @@ public void DropCarried(EntityUid carrier, EntityUid carried)
RemComp<KnockedDownComponent>(carried);
_actionBlockerSystem.UpdateCanMove(carried);
Transform(carried).AttachToGridOrMap();
_standingState.Stand(carried);
if (!_standingState.IsDown(carried))
_standingState.Stand(carried);
_movementSpeed.RefreshMovementSpeedModifiers(carrier);
_virtualItemSystem.DeleteInHandsMatching(carrier, carried);
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/LieDown/LyingDownComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public sealed partial class LyingDownComponent : Component
/// <summary>
/// The action to lie down or stand up.
/// </summary>
[DataField]
public bool Disabling = false;

[DataField]
public EntProtoId? MakeToStandUpAction = "action-name-make-standup";
}
Expand Down
26 changes: 7 additions & 19 deletions Content.Shared/LieDown/SharedLieDownSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public override void Initialize()

SubscribeLocalEvent<LyingDownComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<LyingDownComponent, ComponentShutdown>(OnComponentShutdown);
SubscribeLocalEvent<LyingDownComponent, BuckleChangeEvent>(OnBuckleChange);
SubscribeLocalEvent<LyingDownComponent, CarryDoAfterEvent>(OnDoAfter);


// Bind keybinds to lie down action
Expand All @@ -41,26 +39,16 @@ public override void Initialize()
.Register<SharedLieDownSystem>();
}

private void OnDoAfter(EntityUid uid, LyingDownComponent component, CarryDoAfterEvent args) {
_standing.Stand(uid);
RemCompDeferred<LyingDownComponent>(uid);
}

private void OnBuckleChange(EntityUid uid, LyingDownComponent component, ref BuckleChangeEvent args) {
if (args.Buckling) {
RemCompDeferred<LyingDownComponent>(uid);
}
}

private void OnComponentShutdown(EntityUid uid, LyingDownComponent component, ComponentShutdown args)
{
SwitchActions(uid);
component.Disabling = true;
SwitchActions(uid, false);
_movement.RefreshMovementSpeedModifiers(uid);
}

private void OnComponentStartup(EntityUid uid, LyingDownComponent component, ComponentStartup args)
{
SwitchActions(uid);
SwitchActions(uid, true);
_movement.RefreshMovementSpeedModifiers(uid);
}

Expand Down Expand Up @@ -96,7 +84,7 @@ private void OnChangeAction(ChangeStandingStateEvent msg, EntitySessionEventArgs
/// </summary>
private void OnRefresh(EntityUid uid, LyingDownComponent component, RefreshMovementSpeedModifiersEvent args)
{
if (_standing.IsDown(uid))
if (!component.Disabling)
{
args.ModifySpeed(0f, 0f);
}
Expand All @@ -109,10 +97,10 @@ private void OnRefresh(EntityUid uid, LyingDownComponent component, RefreshMovem
/// <summary>
/// Change available to player actions.
/// </summary>
private void SwitchActions(EntityUid uid)
private void SwitchActions(EntityUid uid, bool choose)
{
var standingComponent = Comp<StandingStateComponent>(uid);
if (_standing.IsDown(uid))
if (choose)
{
_actions.AddAction(uid, ref standingComponent.StandUpActionEntity, standingComponent.StandUpAction);
_actions.RemoveAction(uid, standingComponent.LieDownActionEntity);
Expand Down Expand Up @@ -180,7 +168,7 @@ public void TryStandUp(EntityUid uid)

public void TryLieDown(EntityUid uid)
{
if (_standing.IsDown(uid) || !_standing.Down(uid, false, false))
if (_standing.IsDown(uid) || !_standing.Down(uid))
return;

EnsureComp<LyingDownComponent>(uid);
Expand Down
17 changes: 10 additions & 7 deletions Content.Shared/Standing/StandingStateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public override void Initialize()
SubscribeLocalEvent<StandingStateComponent, MapInitEvent>(OnMapInit);
}

public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null, LyingDownComponent? liedownComp = null)
{
if (!Resolve(uid, ref standingState, false))
return false;

return !standingState.Standing && !_buckle.IsBuckled(uid);
return Resolve(uid, ref liedownComp, false);
}

private void OnMapInit(EntityUid uid, StandingStateComponent component, MapInitEvent args)
Expand Down Expand Up @@ -69,7 +69,7 @@ private void OnLieDownAction(EntityUid uid, StandingStateComponent component, Li
/// <summary>
/// Event that being risen on stand up attempt.
/// </summary>
private void OnStandUpAction(EntityUid uid, StandingStateComponent component, StandUpActionEvent args)
private void OnStandUpAction(EntityUid uid, StandingStateComponent? component, StandUpActionEvent args)
{
_lieDown.TryStandUp(uid);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true
// Optional component.
Resolve(uid, ref appearance, ref hands, false);

if (!standingState.Standing)
if (IsDown(uid))
return true;

// This is just to avoid most callers doing this manually saving boilerplate
Expand All @@ -118,7 +118,6 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true
if (msg.Cancelled)
return false;

standingState.Standing = false;
Dirty(uid, standingState);
RaiseLocalEvent(uid, new DownedEvent(), false);

Expand Down Expand Up @@ -166,7 +165,7 @@ public bool Stand(EntityUid uid,
// Optional component.
Resolve(uid, ref appearance, false);

if (standingState.Standing)
if (!IsDown(uid))
return true;

if (!force)
Expand All @@ -178,7 +177,6 @@ public bool Stand(EntityUid uid,
return false;
}

standingState.Standing = true;
Dirty(uid, standingState);
RaiseLocalEvent(uid, new StoodEvent(), false);

Expand All @@ -194,6 +192,11 @@ public bool Stand(EntityUid uid,
}
standingState.ChangedFixtures.Clear();

LyingDownComponent? liedownComp = null;
//if (Resolve(uid, ref liedownComp, false)) {
// RemCompDeferred<LyingDownComponent>(uid);
//}

return true;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Resources/Prototypes/Actions/liedown.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- type: entity
id: ActionStandUp
name: Stand Up
description: Toggles all glove actions on left click. Includes your doorjack, draining power, stunning enemies, downloading research and calling in a threat.
name: Встать
description: Встать с пола. Надеюсь вам было удобно лежать на холодном, грязном полу.
noSpawn: true
components:
- type: InstantAction
Expand All @@ -10,8 +10,8 @@

- type: entity
id: ActionLieDown
name: Lie Down
description: Toggles all glove actions on left click. Includes your doorjack, draining power, stunning enemies, downloading research and calling in a threat.
name: Лечь
description: Лечь на грязный пол.
noSpawn: true
components:
- type: InstantAction
Expand Down
Binary file modified Resources/Textures/Interface/Actions/lie-down-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Textures/Interface/Actions/stand-up-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading