forked from space-syndicate/space-station-14-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] Laying System (space-syndicate#83)
* [Port] Laying System Barebones port of Rxup/space-station-14#745 * aaa * Update GhostSystem.cs * Update GhostSystem.cs * Feature: Back in Round Button * Update CCVars.cs * up1 * up2 * upd * update test --------- Co-authored-by: Zack Backmen <[email protected]> Co-authored-by: Trest <[email protected]> * all fixes of laying system at once --------- Co-authored-by: Zack Backmen <[email protected]> Co-authored-by: Trest <[email protected]> Co-authored-by: Roudenn <[email protected]> * backmen to _CorvaxNext and move to appropriate folders * laying system hotkey on Shift C * let me pass tests --------- Co-authored-by: Trest <[email protected]> Co-authored-by: Zack Backmen <[email protected]> Co-authored-by: Roudenn <[email protected]>
- Loading branch information
1 parent
744d490
commit 6bae52d
Showing
20 changed files
with
890 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
Content.Client/_CorvaxNext/Standing/LayingDownSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
using Content.Shared.ActionBlocker; | ||
using Content.Shared._CorvaxNext.NextVars; | ||
using Content.Shared._CorvaxNext.Standing; | ||
using Content.Shared.Buckle; | ||
using Content.Shared.Rotation; | ||
using Content.Shared.Standing; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client._CorvaxNext.Standing; | ||
|
||
public sealed class LayingDownSystem : SharedLayingDownSystem | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
[Dependency] private readonly IEyeManager _eyeManager = default!; | ||
[Dependency] private readonly StandingStateSystem _standing = default!; | ||
[Dependency] private readonly AnimationPlayerSystem _animation = default!; | ||
[Dependency] private readonly SharedBuckleSystem _buckle = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly SharedRotationVisualsSystem _rotationVisuals = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<LayingDownComponent, MoveEvent>(OnMovementInput); | ||
SubscribeLocalEvent<LayingDownComponent, AfterAutoHandleStateEvent>(OnChangeDraw); | ||
SubscribeLocalEvent<StandingStateComponent, AfterAutoHandleStateEvent>(OnChangeStanding); | ||
|
||
_cfg.OnValueChanged(NextVars.AutoGetUp, b => _autoGetUp = b, true); | ||
|
||
//SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp); | ||
} | ||
|
||
private void OnChangeStanding(Entity<StandingStateComponent> ent, ref AfterAutoHandleStateEvent args) | ||
{ | ||
if (_animation.HasRunningAnimation(ent, "rotate")) | ||
return; | ||
|
||
if (!TryComp<SpriteComponent>(ent, out var sprite)) | ||
{ | ||
return; | ||
} | ||
|
||
if (ent.Comp.Standing) | ||
{ | ||
sprite.Rotation = Angle.Zero; | ||
return; | ||
} | ||
|
||
if (sprite.Rotation != Angle.FromDegrees(270) && sprite.Rotation != Angle.FromDegrees(90)) | ||
{ | ||
sprite.Rotation = Angle.FromDegrees(270); | ||
} | ||
} | ||
|
||
private void OnChangeDraw(Entity<LayingDownComponent> ent, ref AfterAutoHandleStateEvent args) | ||
{ | ||
if (!TryComp<SpriteComponent>(ent, out var sprite)) | ||
return; | ||
|
||
if (ent.Comp.DrawDowned) | ||
{ | ||
sprite.DrawDepth = (int)Shared.DrawDepth.DrawDepth.SmallMobs; | ||
} | ||
else if (!ent.Comp.DrawDowned && sprite.DrawDepth == (int)Shared.DrawDepth.DrawDepth.SmallMobs) | ||
{ | ||
sprite.DrawDepth = (int)Shared.DrawDepth.DrawDepth.Mobs; | ||
} | ||
} | ||
|
||
private bool _autoGetUp; | ||
|
||
protected override bool GetAutoGetUp(Entity<LayingDownComponent> ent, ICommonSession session) | ||
{ | ||
return _autoGetUp; | ||
} | ||
|
||
private void OnMovementInput(EntityUid uid, LayingDownComponent component, MoveEvent args) | ||
{ | ||
if (!_timing.IsFirstTimePredicted) | ||
return; | ||
if (!_standing.IsDown(uid) || _animation.HasRunningAnimation(uid, "rotate") || _buckle.IsBuckled(uid)) | ||
return; | ||
if (TerminatingOrDeleted(uid)) | ||
return; | ||
|
||
if (!TryComp<SpriteComponent>(uid, out var sprite) | ||
|| !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals)) | ||
{ | ||
return; | ||
} | ||
|
||
ProcessVisuals((uid, Transform(uid), sprite, rotationVisuals)); | ||
} | ||
|
||
private void ProcessVisuals(Entity<TransformComponent, SpriteComponent?, RotationVisualsComponent> entity) | ||
{ | ||
var rotation = entity.Comp1.LocalRotation + (_eyeManager.CurrentEye.Rotation - (entity.Comp1.LocalRotation - _transform.GetWorldRotation(entity.Comp1))); | ||
|
||
if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North) | ||
{ | ||
_rotationVisuals.SetHorizontalAngle((entity.Owner, entity.Comp3), Angle.FromDegrees(270)); | ||
if (entity.Comp2 != null) | ||
entity.Comp2.Rotation = Angle.FromDegrees(270); | ||
return; | ||
} | ||
|
||
_rotationVisuals.ResetHorizontalAngle((entity.Owner, entity.Comp3)); | ||
if (entity.Comp2 != null) | ||
entity.Comp2.Rotation = entity.Comp3.DefaultRotation; | ||
} | ||
|
||
public override void AutoGetUp(Entity<LayingDownComponent> ent) | ||
{ | ||
if (!_timing.IsFirstTimePredicted) | ||
return; | ||
|
||
if (TerminatingOrDeleted(ent)) | ||
return; | ||
|
||
var transform = Transform(ent); | ||
|
||
if (!TryComp<RotationVisualsComponent>(ent, out var rotationVisuals)) | ||
return; | ||
|
||
ProcessVisuals((ent.Owner, transform, null, rotationVisuals)); | ||
} | ||
|
||
/* | ||
private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args) | ||
{ | ||
if (!_timing.IsFirstTimePredicted) | ||
return; | ||
var uid = GetEntity(ev.User); | ||
if (!TryComp<TransformComponent>(uid, out var transform) || !TryComp<RotationVisualsComponent>(uid, out var rotationVisuals)) | ||
return; | ||
var rotation = transform.LocalRotation + (_eyeManager.CurrentEye.Rotation - (transform.LocalRotation - transform.WorldRotation)); | ||
if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North) | ||
{ | ||
rotationVisuals.HorizontalRotation = Angle.FromDegrees(270); | ||
return; | ||
} | ||
rotationVisuals.HorizontalRotation = Angle.FromDegrees(90); | ||
}*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Content.Shared._CorvaxNext.NextVars; | ||
using Content.Shared._CorvaxNext.Standing; | ||
using Content.Shared.Rotation; | ||
using Content.Shared.Standing; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server._CorvaxNext.Standing; | ||
|
||
public sealed class LayingDownSystem : SharedLayingDownSystem // WD EDIT | ||
{ | ||
[Dependency] private readonly INetConfigurationManager _cfg = default!; | ||
[Dependency] private readonly SharedTransformSystem _transform = default!; | ||
[Dependency] private readonly SharedRotationVisualsSystem _rotationVisuals = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
//SubscribeNetworkEvent<CheckAutoGetUpEvent>(OnCheckAutoGetUp); | ||
SubscribeLocalEvent<LayingDownComponent, StoodEvent>(OnStoodEvent); | ||
SubscribeLocalEvent<LayingDownComponent, DownedEvent>(OnDownedEvent); | ||
} | ||
private void OnDownedEvent(Entity<LayingDownComponent> ent, ref DownedEvent args) | ||
{ | ||
// Raising this event will lower the entity's draw depth to the same as a small mob. | ||
if (CrawlUnderTables) | ||
{ | ||
ent.Comp.DrawDowned = true; | ||
Dirty(ent, ent.Comp); | ||
} | ||
} | ||
|
||
private void OnStoodEvent(Entity<LayingDownComponent> ent, ref StoodEvent args) | ||
{ | ||
if (CrawlUnderTables) | ||
{ | ||
ent.Comp.DrawDowned = false; | ||
Dirty(ent, ent.Comp); | ||
} | ||
} | ||
|
||
public override void AutoGetUp(Entity<LayingDownComponent> ent) | ||
{ | ||
if (!TryComp<EyeComponent>(ent, out var eyeComp) || !TryComp<RotationVisualsComponent>(ent, out var rotationVisualsComp)) | ||
return; | ||
|
||
var xform = Transform(ent); | ||
|
||
var rotation = xform.LocalRotation + (eyeComp.Rotation - (xform.LocalRotation - _transform.GetWorldRotation(xform))); | ||
|
||
if (rotation.GetDir() is Direction.SouthEast or Direction.East or Direction.NorthEast or Direction.North) | ||
{ | ||
_rotationVisuals.SetHorizontalAngle((ent, rotationVisualsComp), Angle.FromDegrees(270)); | ||
return; | ||
} | ||
|
||
_rotationVisuals.ResetHorizontalAngle((ent, rotationVisualsComp)); | ||
} | ||
|
||
protected override bool GetAutoGetUp(Entity<LayingDownComponent> ent, ICommonSession session) | ||
{ | ||
return _cfg.GetClientCVar(session.Channel, NextVars.AutoGetUp); | ||
} | ||
/* | ||
private void OnCheckAutoGetUp(CheckAutoGetUpEvent ev, EntitySessionEventArgs args) | ||
{ | ||
var uid = GetEntity(ev.User); | ||
if (!TryComp(uid, out LayingDownComponent? layingDown)) | ||
return; | ||
layingDown.AutoGetUp = _cfg.GetClientCVar(args.SenderSession.Channel, CCVars.AutoGetUp); | ||
Dirty(uid, layingDown); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.