Fix bypassing vaulting clumsy check with verb action. (#24977)

* Fix bypassing bonking with verb

* Revert "Fix bypassing bonking with verb"

This reverts commit efa0f0f5777b893bcee5a852994cfa1e3fda3e71.

* Properly refactored BonkSystem.

* Oh hey, this is redundant now

* Better solution

* Reduced default bonk chance from 75% to 50%

* Also do a little grammar fix

* Moved BonkChance from BonkableComponent to ClumsyComponent.

* Revert "Moved BonkChance from BonkableComponent to ClumsyComponent."

This reverts commit 0acbd9273f20ec478692603781adf15e06e5ed41.

* Another little grammar fix

* Matched default bonk doAfter length to default climb doAfter length

* Fixed duplicate popups

* Check CanVault with verb use too. Add granularity to ClimbingComponent and remove Leg/Foot requirement.

* Don't show verb if you can't climb

* Removed CanForceClimb

* byref record struct
This commit is contained in:
Tayrtahn
2024-03-23 15:29:43 -04:00
committed by GitHub
parent 18b99ed8a2
commit 225bc3c5ae
7 changed files with 101 additions and 39 deletions

View File

@@ -1,6 +1,4 @@
using Content.Shared.ActionBlocker;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
using Content.Shared.Body.Systems;
using Content.Shared.Buckle.Components;
using Content.Shared.Climbing.Components;
@@ -151,7 +149,6 @@ public sealed partial class ClimbSystem : VirtualController
if (args.Handled)
return;
var canVault = args.User == args.Dragged
? CanVault(component, args.User, uid, out _)
: CanVault(component, args.User, args.Dragged, uid, out _);
@@ -169,7 +166,7 @@ public sealed partial class ClimbSystem : VirtualController
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
return;
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing || !climbingComponent.CanClimb)
return;
// TODO VERBS ICON add a climbing icon?
@@ -198,14 +195,28 @@ public sealed partial class ClimbSystem : VirtualController
{
id = null;
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing))
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing, false))
return false;
var canVault = user == entityToMove
? CanVault(comp, user, climbable, out var reason)
: CanVault(comp, user, entityToMove, climbable, out reason);
if (!canVault)
{
_popupSystem.PopupClient(reason, user, user);
return false;
}
// Note, IsClimbing does not mean a DoAfter is active, it means the target has already finished a DoAfter and
// is currently on top of something..
if (climbing.IsClimbing)
return true;
var ev = new AttemptClimbEvent(user, entityToMove, climbable);
RaiseLocalEvent(climbable, ref ev);
if (ev.Cancelled)
return false;
var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(),
entityToMove,
target: climbable,
@@ -244,7 +255,7 @@ public sealed partial class ClimbSystem : VirtualController
var (worldPos, worldRot) = _xformSystem.GetWorldPositionRotation(xform);
var worldDirection = _xformSystem.GetWorldPosition(climbable) - worldPos;
var distance = worldDirection.Length();
var parentRot = (worldRot - xform.LocalRotation);
var parentRot = worldRot - xform.LocalRotation;
// Need direction relative to climber's parent.
var localDirection = (-parentRot).RotateVec(worldDirection);
@@ -399,10 +410,8 @@ public sealed partial class ClimbSystem : VirtualController
return false;
}
if (!HasComp<ClimbingComponent>(user)
|| !TryComp(user, out BodyComponent? body)
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Leg, body)
|| !_bodySystem.BodyHasPartType(user, BodyPartType.Foot, body))
if (!TryComp<ClimbingComponent>(user, out var climbingComp)
|| !climbingComp.CanClimb)
{
reason = Loc.GetString("comp-climbable-cant-climb");
return false;
@@ -438,7 +447,7 @@ public sealed partial class ClimbSystem : VirtualController
if (!HasComp<ClimbingComponent>(dragged))
{
reason = Loc.GetString("comp-climbable-cant-climb");
reason = Loc.GetString("comp-climbable-target-cant-climb", ("moved-user", Identity.Entity(dragged, EntityManager)));
return false;
}