Climbing system (#1750)
* Initial commit * Climbing uses its own controller now * Missed a check * Get rid of hands check * Cleanup * Get rid of speciescomponent stuff * Remove unneeded check, add separate case for moving other players. * Add DoAfter * IClientDraggable added to ClimbingComponent * Added some basic integration tests. Renamed ClimbMode to Climbing. * oops * Minor fixes * ffff * Table fix * Revamped system so its more predicted, uses proper logic for de-climbing. Get hype!!! * Flag check fix * Distance check and reset numticksblocked * get rid
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Movement
|
||||
{
|
||||
public abstract class SharedClimbingComponent : Component, IActionBlocker, ICollideSpecial
|
||||
{
|
||||
public sealed override string Name => "Climbing";
|
||||
public sealed override uint? NetID => ContentNetIDs.CLIMBING;
|
||||
|
||||
protected ICollidableComponent Body;
|
||||
protected bool IsOnClimbableThisFrame = false;
|
||||
|
||||
protected bool OwnerIsTransitioning
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Body.TryGetController<ClimbController>(out var controller))
|
||||
{
|
||||
return controller.IsActive;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract bool IsClimbing { get; set; }
|
||||
|
||||
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
|
||||
bool IActionBlocker.CanChangeDirection() => !OwnerIsTransitioning;
|
||||
|
||||
bool ICollideSpecial.PreventCollide(IPhysBody collided)
|
||||
{
|
||||
if (((CollisionGroup)collided.CollisionLayer).HasFlag(CollisionGroup.VaultImpassable) && collided.Entity.HasComponent<IClimbable>())
|
||||
{
|
||||
IsOnClimbableThisFrame = true;
|
||||
return IsClimbing;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Owner.TryGetComponent(out Body);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class ClimbModeComponentState : ComponentState
|
||||
{
|
||||
public ClimbModeComponentState(bool climbing) : base(ContentNetIDs.CLIMBING)
|
||||
{
|
||||
Climbing = climbing;
|
||||
}
|
||||
|
||||
public bool Climbing { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user