forked from space-wizards/space-station-14
-
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.
Rework climbing (space-wizards#7706)
- Loading branch information
1 parent
7198173
commit 0e945b4
Showing
11 changed files
with
508 additions
and
626 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
using Content.Client.Interactable; | ||
using Content.Client.Movement.Components; | ||
using Content.Shared.Climbing; | ||
using Content.Shared.DragDrop; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Client.Movement; | ||
|
||
public sealed class ClimbSystem : SharedClimbSystem | ||
{ | ||
[Dependency] private readonly InteractionSystem _interactionSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ClimbingComponent, ComponentHandleState>(OnClimbingState); | ||
} | ||
|
||
private static void OnClimbingState(EntityUid uid, ClimbingComponent component, ref ComponentHandleState args) | ||
{ | ||
if (args.Current is not SharedClimbingComponent.ClimbModeComponentState climbModeState) | ||
return; | ||
|
||
component.IsClimbing = climbModeState.Climbing; | ||
component.OwnerIsTransitioning = climbModeState.IsTransitioning; | ||
} | ||
|
||
protected override void OnCanDragDropOn(EntityUid uid, SharedClimbableComponent component, CanDragDropOnEvent args) | ||
{ | ||
base.OnCanDragDropOn(uid, component, args); | ||
|
||
if (!args.CanDrop) | ||
return; | ||
|
||
var user = args.User; | ||
var target = args.Target; | ||
var dragged = args.Dragged; | ||
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged; | ||
|
||
args.CanDrop = _interactionSystem.InRangeUnobstructed(user, target, component.Range, predicate: Ignored) | ||
&& _interactionSystem.InRangeUnobstructed(user, dragged, component.Range, predicate: Ignored); | ||
args.Handled = true; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,34 +1,8 @@ | ||
using Content.Shared.Climbing; | ||
using Content.Shared.DragDrop; | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Interaction.Helpers; | ||
using Robust.Shared.GameObjects; | ||
|
||
namespace Content.Client.Movement.Components | ||
{ | ||
[RegisterComponent] | ||
[ComponentReference(typeof(IClimbable))] | ||
public sealed class ClimbableComponent : SharedClimbableComponent | ||
{ | ||
public override bool CanDragDropOn(DragDropEvent eventArgs) | ||
{ | ||
if (!base.CanDragDropOn(eventArgs)) | ||
return false; | ||
namespace Content.Client.Movement.Components; | ||
|
||
var user = eventArgs.User; | ||
var target = eventArgs.Target; | ||
var dragged = eventArgs.Dragged; | ||
bool Ignored(EntityUid entity) => entity == target || entity == user || entity == dragged; | ||
|
||
var sys = EntitySystem.Get<SharedInteractionSystem>(); | ||
|
||
return sys.InRangeUnobstructed(user, target, Range, predicate: Ignored) | ||
&& sys.InRangeUnobstructed(user, dragged, Range, predicate: Ignored); | ||
} | ||
|
||
public override bool DragDropOn(DragDropEvent eventArgs) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
[RegisterComponent] | ||
[Friend(typeof(ClimbSystem))] | ||
[ComponentReference(typeof(SharedClimbableComponent))] | ||
public sealed class ClimbableComponent : SharedClimbableComponent { } |
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 |
---|---|---|
@@ -1,23 +1,8 @@ | ||
using Content.Shared.Climbing; | ||
using Robust.Shared.GameObjects; | ||
|
||
namespace Content.Client.Movement.Components | ||
{ | ||
[RegisterComponent] | ||
[ComponentReference(typeof(SharedClimbingComponent))] | ||
public sealed class ClimbingComponent : SharedClimbingComponent | ||
{ | ||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) | ||
{ | ||
base.HandleComponentState(curState, nextState); | ||
namespace Content.Client.Movement.Components; | ||
|
||
if (curState is not ClimbModeComponentState climbModeState) | ||
{ | ||
return; | ||
} | ||
|
||
IsClimbing = climbModeState.Climbing; | ||
OwnerIsTransitioning = climbModeState.IsTransitioning; | ||
} | ||
} | ||
} | ||
[RegisterComponent] | ||
[Friend(typeof(ClimbSystem))] | ||
[ComponentReference(typeof(SharedClimbingComponent))] | ||
public sealed class ClimbingComponent : SharedClimbingComponent { } |
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.