Climbing changes (#2236)

Climbing now can't be done if you're already climbing. Rest of the changes are just formatting.

I also removed the buckle messages as they were being duplicated for click-drag.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-10-12 02:12:46 +11:00
committed by GitHub
parent 53cc5abdcd
commit ecfe470298
4 changed files with 30 additions and 35 deletions

View File

@@ -14,15 +14,15 @@ namespace Content.Server.GameObjects.Components.Movement
public override bool IsClimbing
{
get
{
return _isClimbing;
}
get => _isClimbing;
set
{
if (!value && Body != null)
if (_isClimbing == value)
return;
if (!value)
{
Body.TryRemoveController<ClimbController>();
Body?.TryRemoveController<ClimbController>();
}
_isClimbing = value;
@@ -35,37 +35,33 @@ namespace Content.Server.GameObjects.Components.Movement
/// </summary>
public void TryMoveTo(Vector2 from, Vector2 to)
{
if (Body != null)
{
_climbController = Body.EnsureController<ClimbController>();
_climbController.TryMoveTo(from, to);
}
if (Body == null)
return;
_climbController = Body.EnsureController<ClimbController>();
_climbController.TryMoveTo(from, to);
}
public void Update(float frameTime)
public void Update()
{
if (Body != null && IsClimbing)
if (!IsClimbing || Body == null)
return;
if (_climbController != null && (_climbController.IsBlocked || !_climbController.IsActive))
{
if (_climbController != null && (_climbController.IsBlocked || !_climbController.IsActive))
if (Body.TryRemoveController<ClimbController>())
{
if (Body.TryRemoveController<ClimbController>())
{
_climbController = null;
}
_climbController = null;
}
if (IsClimbing)
{
Body.WakeBody();
}
if (!IsOnClimbableThisFrame && IsClimbing && _climbController == null)
{
IsClimbing = false;
}
IsOnClimbableThisFrame = false;
}
if (IsClimbing)
Body.WakeBody();
if (!IsOnClimbableThisFrame && IsClimbing && _climbController == null)
IsClimbing = false;
IsOnClimbableThisFrame = false;
}
public override ComponentState GetComponentState()