From 912da3f4f6c9c1f7dca6c23c389d1531e56fa026 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 11 Nov 2018 17:23:22 +0200 Subject: [PATCH] Made FindHull methods inclusive by default (= a position exactly at the edge of a hull is considered to be within the hull). Fixes characters being considered outside when they're exactly at the edge of 2 adjacent hulls, which sometimes caused the camera to twitch inwards and the character to get wet when moving between docked subs. --- Barotrauma/BarotraumaShared/Source/Map/Hull.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index fb8a5b7fd..32fc897f4 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -541,31 +541,31 @@ namespace Barotrauma } //returns the water block which contains the point (or null if it isn't inside any) - public static Hull FindHull(Vector2 position, Hull guess = null, bool useWorldCoordinates = true) + public static Hull FindHull(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = true) { if (entityGrids == null) return null; if (guess != null) { - if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess; + if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position, inclusive)) return guess; } var entities = EntityGrid.GetEntities(entityGrids, position, useWorldCoordinates); foreach (Hull hull in entities) { - if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position)) return hull; + if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position, inclusive)) return hull; } return null; } //returns the water block which contains the point (or null if it isn't inside any) - public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false) + public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = true) { return FindHullOld(position, hullList, guess, useWorldCoordinates, inclusive); } - public static Hull FindHullOld(Vector2 position, List hulls, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false) + public static Hull FindHullOld(Vector2 position, List hulls, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = true) { if (guess != null && hulls.Contains(guess)) {