Add pathfinding support for NPCs climbing tables (#17415)

This commit is contained in:
Vordenburg
2023-07-28 02:37:29 -04:00
committed by GitHub
parent 494b9e5b93
commit 49f3f07e30
11 changed files with 114 additions and 15 deletions

View File

@@ -95,7 +95,7 @@ public sealed class ClimbSystem : SharedClimbSystem
// TODO VERBS ICON add a climbing icon?
args.Verbs.Add(new AlternativeVerb
{
Act = () => TryClimb(args.User, args.User, args.Target, component),
Act = () => TryClimb(args.User, args.User, args.Target, out _, component),
Text = Loc.GetString("comp-climbable-verb-climb")
});
}
@@ -106,22 +106,25 @@ public sealed class ClimbSystem : SharedClimbSystem
// but don't have computer access and i have to do this without syntax
if (args.Handled || args.User != args.Dragged && !HasComp<HandsComponent>(args.User))
return;
TryClimb(args.User, args.Dragged, uid, component);
TryClimb(args.User, args.Dragged, uid, out _, component);
}
public void TryClimb(EntityUid user,
public bool TryClimb(EntityUid user,
EntityUid entityToMove,
EntityUid climbable,
out DoAfterId? id,
ClimbableComponent? comp = null,
ClimbingComponent? climbing = null)
{
id = null;
if (!Resolve(climbable, ref comp) || !Resolve(entityToMove, ref climbing))
return;
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;
return true;
var args = new DoAfterArgs(user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
{
@@ -130,7 +133,8 @@ public sealed class ClimbSystem : SharedClimbSystem
BreakOnDamage = true
};
_doAfterSystem.TryStartDoAfter(args);
_doAfterSystem.TryStartDoAfter(args, out id);
return true;
}
private void OnDoAfter(EntityUid uid, ClimbingComponent component, ClimbDoAfterEvent args)
@@ -279,7 +283,7 @@ public sealed class ClimbSystem : SharedClimbSystem
/// <param name="target">The object that is being vaulted</param>
/// <param name="reason">The reason why it cant be dropped</param>
/// <returns></returns>
private bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid target, out string reason)
{
if (!_actionBlockerSystem.CanInteract(user, target))
{
@@ -315,7 +319,7 @@ public sealed class ClimbSystem : SharedClimbSystem
/// <param name="target">The object that is being vaulted onto</param>
/// <param name="reason">The reason why it cant be dropped</param>
/// <returns></returns>
private bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
public bool CanVault(ClimbableComponent component, EntityUid user, EntityUid dragged, EntityUid target,
out string reason)
{
if (!_actionBlockerSystem.CanInteract(user, dragged) || !_actionBlockerSystem.CanInteract(user, target))