From edb8c39c580b5b5c0f8a29f8ff349ecb2f910e4e Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 16 Apr 2019 17:11:23 +0300 Subject: [PATCH] (7dc4f5c23) Fix the doors: - Don't allow to pick, if the doors has no requirments. In this case the door should be opened by using the [select] key. - Display "UNAUTHORIZED ACCESS" when the door has integrated buttons but the requirements are not met. Display the cannot open the door text when the door doesn't have integrated buttons and the player is trying to open the door with the [select] key. --- .../BarotraumaShared/Source/Items/Components/Door.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs index e1fb31846..973b7e655 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs @@ -127,6 +127,9 @@ namespace Barotrauma.Items.Components OpenState = (isOpen) ? 1.0f : 0.0f; } } + + [Serialize(false, false)] + public bool HasIntegratedButtons { get; private set; } public float OpenState { @@ -220,11 +223,11 @@ namespace Barotrauma.Items.Components var idCard = character.Inventory.FindItemByIdentifier("idcard"); hasValidIdCard = requiredItems.Any(ri => ri.Value.Any(r => r.MatchesItem(idCard))); - Msg = hasValidIdCard ? "ItemMsgOpen" : "ItemMsgForceOpenCrowbar"; + Msg = requiredItems.None() || hasValidIdCard ? "ItemMsgOpen" : "ItemMsgForceOpenCrowbar"; ParseMsg(); if (addMessage) { - msg = msg ?? (requiredItems.Any(ri => ri.Value.Any(r => r.Identifiers.Contains("idcard"))) ? accessDeniedTxt : cannotOpenText); + msg = msg ?? (HasIntegratedButtons ? accessDeniedTxt : cannotOpenText); } //this is a bit pointless atm because if canBePicked is false it won't allow you to do Pick() anyway, however it's still good for future-proofing. @@ -234,6 +237,7 @@ namespace Barotrauma.Items.Components public override bool Pick(Character picker) { if (item.Condition <= RepairThreshold) { return true; } + if (requiredItems.None()) { return false; } if (HasRequiredItems(picker, false) && hasValidIdCard) { return false; } return base.Pick(picker); }