From 4421c8a5dec77526abc60cb69ca00594578eb648 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 8 Mar 2018 10:43:54 +0200 Subject: [PATCH 1/2] Fixed camera shake continuing indefinitely if a character falls unconscious due to impact damage --- .../Animation/HumanoidAnimController.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index aebc19264..ae83fb868 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -80,6 +80,14 @@ namespace Barotrauma ColliderIndex = Crouching ? 1 : 0; if (!Crouching && ColliderIndex == 1) Crouching = true; + //stun (= disable the animations) if the ragdoll receives a large enough impact + if (strongestImpact > 0.0f) + { + character.SetStun(MathHelper.Min(strongestImpact * 0.5f, 5.0f)); + strongestImpact = 0.0f; + return; + } + if (!character.AllowInput) { levitatingCollider = false; @@ -95,15 +103,6 @@ namespace Barotrauma return; } - //stun (= disable the animations) if the ragdoll receives a large enough impact - if (strongestImpact > 0.0f) - { - character.SetStun(MathHelper.Min(strongestImpact * 0.5f, 5.0f)); - strongestImpact = 0.0f; - return; - } - - //re-enable collider if (!Collider.Enabled) { From df746db421477968be3b22e521ffb18c0c5348c6 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 8 Mar 2018 11:01:17 +0200 Subject: [PATCH 2/2] Ladders can be climbed by holding up/down while standing next to them without having to select them first. --- .../Source/Characters/Character.cs | 28 +++++++++++++++++++ .../Source/Items/Components/Ladder.cs | 15 ++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index dff432aeb..0c111ab7a 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1405,6 +1405,34 @@ namespace Barotrauma { 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 { diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs index 71d3a79eb..5d949fc94 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Ladder.cs @@ -1,13 +1,20 @@ -using System.Xml.Linq; +using System.Collections.Generic; +using System.Xml.Linq; namespace Barotrauma.Items.Components { class Ladder : ItemComponent { + private static List list = new List(); + public static List List + { + get { return list; } + } public Ladder(Item item, XElement element) : base(item, element) { + list.Add(this); } public override bool Select(Character character) @@ -15,9 +22,13 @@ namespace Barotrauma.Items.Components if (character == null || character.LockHands || character.Removed) return false; character.AnimController.Anim = AnimController.Animation.Climbing; - //picker.SelectedConstruction = item; return true; } + + protected override void RemoveComponentSpecific() + { + list.Remove(this); + } } }