If focused on both a character and an item, the one that's closer to the cursor can be interacted with (instead of characters having higher priority, because that would make it impossible to interact with items that are next to a dead/unconscious character). Selected characters can also be deselected without highlighting the character with the cursor.
+ extra null check in HasRequiredItems
This commit is contained in:
@@ -1232,13 +1232,14 @@ namespace Barotrauma
|
||||
if ((!isLocalPlayer && IsKeyHit(InputType.Select) && GameMain.Server == null) || (isLocalPlayer && (findFocusedTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)))
|
||||
{
|
||||
focusedCharacter = FindCharacterAtPosition(mouseSimPos);
|
||||
if (focusedCharacter != null)
|
||||
focusedItem = FindItemAtPosition(mouseSimPos, AnimController.InWater ? 0.5f : 0.25f);
|
||||
|
||||
if (focusedCharacter != null && focusedItem != null)
|
||||
{
|
||||
focusedItem = null; // We can only focus one thing at a time
|
||||
}
|
||||
else
|
||||
{
|
||||
focusedItem = FindItemAtPosition(mouseSimPos, AnimController.InWater ? 0.5f : 0.25f);
|
||||
if (Vector2.DistanceSquared(mouseSimPos, focusedCharacter.SimPosition) > Vector2.DistanceSquared(mouseSimPos, focusedItem.SimPosition))
|
||||
{
|
||||
focusedCharacter = null;
|
||||
}
|
||||
}
|
||||
findFocusedTimer = 0.05f;
|
||||
}
|
||||
@@ -1247,16 +1248,13 @@ namespace Barotrauma
|
||||
findFocusedTimer -= deltaTime;
|
||||
}
|
||||
|
||||
if (focusedCharacter != null && IsKeyHit(InputType.Select))
|
||||
if (selectedCharacter != null && IsKeyHit(InputType.Select))
|
||||
{
|
||||
if (selectedCharacter != null)
|
||||
{
|
||||
DeselectCharacter();
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectCharacter(focusedCharacter);
|
||||
}
|
||||
DeselectCharacter();
|
||||
}
|
||||
else if (focusedCharacter != null && IsKeyHit(InputType.Select))
|
||||
{
|
||||
SelectCharacter(focusedCharacter);
|
||||
}
|
||||
else if (focusedItem != null)
|
||||
{
|
||||
|
||||
@@ -437,6 +437,7 @@ namespace Barotrauma.Items.Components
|
||||
public bool HasRequiredItems(Character character, bool addMessage)
|
||||
{
|
||||
if (!requiredItems.Any()) return true;
|
||||
if (character.Inventory == null) return false;
|
||||
|
||||
foreach (RelatedItem ri in requiredItems)
|
||||
{
|
||||
@@ -449,7 +450,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
if (!hasItem && ri.Type.HasFlag(RelatedItem.RelationType.Picked))
|
||||
{
|
||||
if (character.Inventory.Items.FirstOrDefault(x => x!=null && x.Condition>0.0f && ri.MatchesItem(x))!=null) hasItem = true;
|
||||
if (character.Inventory.Items.FirstOrDefault(x => x != null && x.Condition > 0.0f && ri.MatchesItem(x)) != null) hasItem = true;
|
||||
}
|
||||
if (!hasItem)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user