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

@@ -191,8 +191,6 @@ namespace Content.Server.GameObjects.Components.Buckle
if (!Owner.InRangeUnobstructed(strap, _range, predicate: Ignored, popup: true))
{
strap.Owner.PopupMessage(user, Loc.GetString("You can't reach there!"));
return false;
}
@@ -203,8 +201,6 @@ namespace Content.Server.GameObjects.Components.Buckle
if (!ContainerHelpers.TryGetContainer(strap.Owner, out var strapContainer) ||
ownerContainer != strapContainer)
{
strap.Owner.PopupMessage(user, Loc.GetString("You can't reach there!"));
return false;
}
}

View File

@@ -210,6 +210,9 @@ namespace Content.Server.GameObjects.Components.Movement
private async void TryClimb(IEntity user)
{
if (!user.TryGetComponent(out ClimbingComponent climbingComponent) || climbingComponent.IsClimbing)
return;
var doAfterEventArgs = new DoAfterEventArgs(user, _climbDelay, default, Owner)
{
BreakOnTargetMove = true,

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()

View File

@@ -11,7 +11,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
foreach (var comp in ComponentManager.EntityQuery<ClimbingComponent>())
{
comp.Update(frameTime);
comp.Update();
}
}
}