Ladders can be climbed by holding up/down while standing next to them without having to select them first.
This commit is contained in:
@@ -1406,6 +1406,34 @@ namespace Barotrauma
|
|||||||
findFocusedTimer -= deltaTime;
|
findFocusedTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//climb ladders automatically when pressing up/down inside their trigger area
|
||||||
|
if (selectedConstruction == null && !AnimController.InWater)
|
||||||
|
{
|
||||||
|
bool climbInput = IsKeyDown(InputType.Up) || IsKeyDown(InputType.Down);
|
||||||
|
|
||||||
|
Ladder nearbyLadder = null;
|
||||||
|
if (Controlled == this || climbInput)
|
||||||
|
{
|
||||||
|
float minDist = float.PositiveInfinity;
|
||||||
|
foreach (Ladder ladder in Ladder.List)
|
||||||
|
{
|
||||||
|
float dist;
|
||||||
|
if (CanInteractWith(ladder.Item, out dist) && dist < minDist)
|
||||||
|
{
|
||||||
|
minDist = dist;
|
||||||
|
nearbyLadder = ladder;
|
||||||
|
if (Controlled == this) ladder.Item.IsHighlighted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nearbyLadder != null && climbInput)
|
||||||
|
{
|
||||||
|
if (nearbyLadder.Select(this)) selectedConstruction = nearbyLadder.Item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SelectedCharacter != null && focusedItem == null && IsKeyHit(InputType.Select)) //Let people use ladders and buttons and stuff when dragging chars
|
if (SelectedCharacter != null && focusedItem == null && IsKeyHit(InputType.Select)) //Let people use ladders and buttons and stuff when dragging chars
|
||||||
{
|
{
|
||||||
DeselectCharacter();
|
DeselectCharacter();
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
using System.Xml.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
class Ladder : ItemComponent
|
class Ladder : ItemComponent
|
||||||
{
|
{
|
||||||
|
private static List<Ladder> list = new List<Ladder>();
|
||||||
|
public static List<Ladder> List
|
||||||
|
{
|
||||||
|
get { return list; }
|
||||||
|
}
|
||||||
|
|
||||||
public Ladder(Item item, XElement element)
|
public Ladder(Item item, XElement element)
|
||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
|
list.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Select(Character character)
|
public override bool Select(Character character)
|
||||||
@@ -15,9 +22,13 @@ namespace Barotrauma.Items.Components
|
|||||||
if (character == null || character.LockHands || character.Removed) return false;
|
if (character == null || character.LockHands || character.Removed) return false;
|
||||||
|
|
||||||
character.AnimController.Anim = AnimController.Animation.Climbing;
|
character.AnimController.Anim = AnimController.Animation.Climbing;
|
||||||
//picker.SelectedConstruction = item;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void RemoveComponentSpecific()
|
||||||
|
{
|
||||||
|
list.Remove(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user