From ebd916e95cd0d779ddf9f84b91547af7ff960f72 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jun 2019 15:29:36 +0300 Subject: [PATCH] (9a7d83a40) Fullscreen bug workarounds --- .../BarotraumaClient/ClientCode.projitems | 1 - .../BarotraumaClient/LinuxClient.csproj | 9 --- .../Characters/Health/CharacterHealth.cs | 2 +- .../Source/EventInput/EventInput.cs | 2 +- .../BarotraumaClient/Source/GUI/GUIStyle.cs | 6 ++ .../BarotraumaClient/Source/GameMain.cs | 55 +++++++++++++++++-- .../BarotraumaClient/Source/GameSettings.cs | 4 +- Barotrauma/BarotraumaClient/Source/Program.cs | 2 +- .../Source/Screens/SteamWorkshopScreen.cs | 4 +- .../Source/Screens/SubEditorScreen.cs | 2 +- .../Source/Characters/AI/HumanAIController.cs | 23 ++++---- .../AI/Objectives/AIObjectiveFindSafety.cs | 3 +- .../Animation/Params/Ragdoll/RagdollParams.cs | 3 +- .../Characters/Health/CharacterHealth.cs | 4 +- .../Items/Components/Holdable/RepairTool.cs | 30 +++------- .../BarotraumaShared/Source/Map/Submarine.cs | 25 ++------- 16 files changed, 93 insertions(+), 82 deletions(-) diff --git a/Barotrauma/BarotraumaClient/ClientCode.projitems b/Barotrauma/BarotraumaClient/ClientCode.projitems index 96e169d05..991ce2d39 100644 --- a/Barotrauma/BarotraumaClient/ClientCode.projitems +++ b/Barotrauma/BarotraumaClient/ClientCode.projitems @@ -223,7 +223,6 @@ Never - diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 0b95e4306..c3c50da75 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -247,9 +247,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -271,12 +268,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs index 90748c3f2..afa1d3daf 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Health/CharacterHealth.cs @@ -606,7 +606,7 @@ namespace Barotrauma .ThenByDescending(a => a.Strength).FirstOrDefault(); if (affliction.DamagePerSecond > 0 || affliction.Strength > 0) { - var limbHealth = GetMatchingLimbHealth(affliction); + var limbHealth = GetMathingLimbHealth(affliction); if (limbHealth != null) { selectedLimbIndex = limbHealths.IndexOf(limbHealth); diff --git a/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs b/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs index ee3619634..e156dd669 100644 --- a/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs +++ b/Barotrauma/BarotraumaClient/Source/EventInput/EventInput.cs @@ -256,4 +256,4 @@ namespace EventInput } #endif } -} \ No newline at end of file +} diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs index e93f22c76..9a02dd655 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -118,21 +118,27 @@ namespace Barotrauma switch (subElement.Name.ToString().ToLowerInvariant()) { case "font": + if (Font == null) { continue; } Font.Size = GetFontSize(subElement); break; case "smallfont": + if (SmallFont == null) { continue; } SmallFont.Size = GetFontSize(subElement); break; case "largefont": + if (LargeFont == null) { continue; } LargeFont.Size = GetFontSize(subElement); break; case "objectivetitle": + if (ObjectiveTitleFont == null) { continue; } ObjectiveTitleFont.Size = GetFontSize(subElement); break; case "objectivename": + if (ObjectiveNameFont == null) { continue; } ObjectiveNameFont.Size = GetFontSize(subElement); break; case "videotitle": + if (VideoTitleFont == null) { continue; } VideoTitleFont.Size = GetFontSize(subElement); break; } diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 983fa9c6c..0ce77a2bb 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -120,7 +120,7 @@ namespace Barotrauma get; private set; } - + public static int GraphicsWidth { get; @@ -192,7 +192,19 @@ namespace Barotrauma FarseerPhysics.Settings.PositionIterations = 1; } - public void ApplyGraphicsSettings() + public void RequestGraphicsSettings() + { +#if WINDOWS + if (WindowActive) + { +#endif + ApplyGraphicsSettings(); +#if WINDOWS + } +#endif + } + + private void ApplyGraphicsSettings() { GraphicsWidth = Config.GraphicsWidth; GraphicsHeight = Config.GraphicsHeight; @@ -208,13 +220,14 @@ namespace Barotrauma GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth; GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight; SetWindowMode(Config.WindowMode); + GraphicsDeviceManager.ApplyChanges(); defaultViewport = GraphicsDevice.Viewport; OnResolutionChanged?.Invoke(); } - public void SetWindowMode(WindowMode windowMode) + private void SetWindowMode(WindowMode windowMode) { WindowMode = windowMode; GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed; @@ -223,8 +236,6 @@ namespace Barotrauma GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth; GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight; - - GraphicsDeviceManager.ApplyChanges(); } public void ResetViewPort() @@ -242,7 +253,7 @@ namespace Barotrauma { base.Initialize(); - ApplyGraphicsSettings(); + RequestGraphicsSettings(); ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true }; @@ -281,6 +292,38 @@ namespace Barotrauma #endif loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread); + +#if WINDOWS + var gameForm = (System.Windows.Forms.Form)System.Windows.Forms.Form.FromHandle(Window.Handle); + gameForm.Activated += new EventHandler(HandleFocus); + gameForm.Deactivate += new EventHandler(HandleDefocus); + if (WindowActive) { HandleFocus(null, null); } +#endif + } + +#if WINDOWS + private void HandleFocus(object sender, EventArgs e) + { + CoroutineManager.StopCoroutines("FocusCoroutine"); + CoroutineManager.StartCoroutine(FocusCoroutine(),"FocusCoroutine"); + } + + private IEnumerable FocusCoroutine() + { + yield return new WaitForSeconds(0.01f); + ApplyGraphicsSettings(); + yield return CoroutineStatus.Success; + } + + private void HandleDefocus(object sender, EventArgs e) + { + CoroutineManager.StopCoroutines("FocusCoroutine"); + GraphicsDeviceManager.IsFullScreen = false; + GraphicsDeviceManager.ApplyChanges(); + } +#endif + + loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "", canLoadInSeparateThread); } private void InitUserStats() diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 212acdc56..859933c16 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -841,7 +841,7 @@ namespace Barotrauma GraphicsWidth = mode.Width; GraphicsHeight = mode.Height; - GameMain.Instance.ApplyGraphicsSettings(); + GameMain.Instance.RequestGraphicsSettings(); UnsavedSettings = true; return true; @@ -980,7 +980,7 @@ namespace Barotrauma if (GameMain.WindowMode != GameMain.Config.WindowMode) { - GameMain.Instance.ApplyGraphicsSettings(); + GameMain.Instance.RequestGraphicsSettings(); } if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight) diff --git a/Barotrauma/BarotraumaClient/Source/Program.cs b/Barotrauma/BarotraumaClient/Source/Program.cs index 37646cf3f..6ecc1d63b 100644 --- a/Barotrauma/BarotraumaClient/Source/Program.cs +++ b/Barotrauma/BarotraumaClient/Source/Program.cs @@ -138,7 +138,7 @@ namespace Barotrauma DebugConsole.NewMessage("Display size set to " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight, Microsoft.Xna.Framework.Color.Red); - game.ApplyGraphicsSettings(); + game.RequestGraphicsSettings(); return true; default: diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs index 4ac368ed7..a1799b683 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SteamWorkshopScreen.cs @@ -967,7 +967,7 @@ namespace Barotrauma { try { - Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() + OpenFileDialog ofd = new OpenFileDialog() { Multiselect = true, InitialDirectory = Path.GetFullPath(SteamManager.WorkshopItemStagingFolder), @@ -1078,7 +1078,7 @@ namespace Barotrauma { try { - Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() + OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Path.GetFullPath(SteamManager.WorkshopItemStagingFolder), Title = TextManager.Get("workshopitemaddfiles"), diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index baac2f33d..c45c37df1 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -1074,7 +1074,7 @@ namespace Barotrauma { OnClicked = (btn, userdata) => { - Barotrauma.OpenFileDialog ofd = new Barotrauma.OpenFileDialog() + OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Path.GetFullPath(Submarine.SavePath), Filter = "PNG file|*.png", diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index dbf996ddf..e1587cdfc 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -202,18 +202,22 @@ namespace Barotrauma if (run || speedMultiplier <= 0.0f) targetMovement *= speedMultiplier; Character.ResetSpeedMultiplier(); // Reset, items will set the value before the next update Character.AnimController.TargetMovement = targetMovement; + if (!NeedsDivingGear(Character.CurrentHull)) { bool oxygenLow = Character.OxygenAvailable < CharacterHealth.LowOxygenThreshold; bool highPressure = Character.CurrentHull == null || Character.CurrentHull.LethalPressure > 0 && Character.PressureProtection <= 0; bool shouldKeepTheGearOn = !ObjectiveManager.IsCurrentObjective(); - bool removeDivingSuit = oxygenLow && !highPressure; - if (!removeDivingSuit) - { - bool targetHasNoSuit = objectiveManager.CurrentOrder is AIObjectiveGoTo gtObj && gtObj.mimic && !HasDivingSuit(gtObj.Target as Character); - bool canDropTheSuit = Character.CurrentHull.WaterPercentage < 1 && !Character.IsClimbing && steeringManager == insideSteering && !PathSteering.InStairs; - removeDivingSuit = (!shouldKeepTheGearOn || targetHasNoSuit) && canDropTheSuit; - } + + // Don't allow to drop the diving suit in water or while climbing or if the current path has stairs + bool removeDivingSuit = + (oxygenLow && !highPressure) || + (!shouldKeepTheGearOn && + Character.CurrentHull.WaterPercentage < 1 && + !Character.IsClimbing && + steeringManager == insideSteering && + !PathSteering.InStairs); + if (removeDivingSuit) { var divingSuit = Character.Inventory.FindItemByIdentifier("divingsuit") ?? Character.Inventory.FindItemByTag("divingsuit"); @@ -223,8 +227,7 @@ namespace Barotrauma divingSuit.Drop(Character); } } - bool targetHasNoMask = objectiveManager.CurrentOrder is AIObjectiveGoTo gotoObjective && gotoObjective.mimic && !HasDivingMask(gotoObjective.Target as Character); - bool takeMaskOff = oxygenLow || (!shouldKeepTheGearOn && Character.CurrentHull.WaterPercentage < 20) || targetHasNoMask; + bool takeMaskOff = oxygenLow || (!shouldKeepTheGearOn && Character.CurrentHull.WaterPercentage < 20); if (takeMaskOff) { var mask = Character.Inventory.FindItemByIdentifier("divingmask"); @@ -333,7 +336,7 @@ namespace Barotrauma if (AIObjectiveFixLeaks.IsValidTarget(gap, Character)) { AddTargets(Character, gap); - if (newOrder == null && !gap.IsRoomToRoom) + if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbreach"); newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs index 3cdc8780b..851a0cd01 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs @@ -122,8 +122,9 @@ namespace Barotrauma goToObjective = null; } TryAddSubObjective(ref goToObjective, - constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: true) + constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: false) { + // If we need diving gear, we should already have it, if possible. AllowGoingOutside = HumanAIController.HasDivingSuit(character) }, onAbandon: () => unreachable.Add(goToObjective.Target as Hull)); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs index cec8bfc44..0ca685008 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Params/Ragdoll/RagdollParams.cs @@ -36,8 +36,7 @@ namespace Barotrauma [Serialize(1.0f, true), Editable(MIN_SCALE, MAX_SCALE, DecimalCount = 3)] public float JointScale { get; set; } - // Don't show in the editor, because shouldn't be edited in runtime. Requires that the limb scale and the collider sizes are adjusted. TODO: automatize. - [Serialize(1f, false)] + [Serialize(1f, true), Editable(DecimalCount = 2)] public float TextureScale { get; set; } [Serialize(45f, true), Editable(0f, 1000f)] diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs index 6425a776e..4f5769f34 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Health/CharacterHealth.cs @@ -232,13 +232,13 @@ namespace Barotrauma } private LimbHealth GetMatchingLimbHealth(Limb limb) => limbHealths[limb.HealthIndex]; - private LimbHealth GetMatchingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb)); + private LimbHealth GetMathingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb)); /// /// Returns the limb afflictions and non-limbspecific afflictions that are set to be displayed on this limb. /// private IEnumerable GetMatchingAfflictions(LimbHealth limb, Func predicate) - => limb.Afflictions.Where(predicate).Union(afflictions.Where(a => predicate(a) && GetMatchingLimbHealth(a) == limb)); + => limb.Afflictions.Where(predicate).Union(afflictions.Where(a => predicate(a) && GetMathingLimbHealth(a) == limb)); public Affliction GetAffliction(string afflictionType, bool allowLimbAfflictions = true) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs index a61ce2b23..e39877bdb 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RepairTool.cs @@ -40,9 +40,6 @@ namespace Barotrauma.Items.Components [Serialize(false, false)] public bool RepairThroughWalls { get; set; } - [Serialize(false, false)] - public bool RepairMultiple { get; set; } - public Vector2 TransformedBarrelPos { get @@ -161,22 +158,12 @@ namespace Barotrauma.Items.Components private void Repair(Vector2 rayStart, Vector2 rayEnd, float deltaTime, Character user, float degreeOfSuccess, List ignoredBodies) { var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel | Physics.CollisionRepair; - if (RepairMultiple) + if (RepairThroughWalls) { var bodies = Submarine.PickBodies(rayStart, rayEnd, ignoredBodies, collisionCategories, ignoreSensors: false, allowInsideFixture: true); - Type lastHitType = null; foreach (Body body in bodies) { - Type bodyType = body.UserData?.GetType(); - if (!RepairThroughWalls && bodyType != null && bodyType != lastHitType) - { - //stop the ray if it already hit a door/wall and is now about to hit some other type of entity - if (lastHitType == typeof(Item) || lastHitType == typeof(Structure)) { break; } - } - if (FixBody(user, deltaTime, degreeOfSuccess, body)) - { - if (bodyType != null) { lastHitType = bodyType; } - } + FixBody(user, deltaTime, degreeOfSuccess, body); } } else @@ -215,19 +202,19 @@ namespace Barotrauma.Items.Components } } - private bool FixBody(Character user, float deltaTime, float degreeOfSuccess, Body targetBody) + private void FixBody(Character user, float deltaTime, float degreeOfSuccess, Body targetBody) { - if (targetBody?.UserData == null) { return false; } + if (targetBody?.UserData == null) { return; } pickedPosition = Submarine.LastPickedPosition; if (targetBody.UserData is Structure targetStructure) { - if (!fixableEntities.Contains("structure") && !fixableEntities.Contains(targetStructure.Prefab.Identifier)) { return false; } - if (targetStructure.IsPlatform) { return false; } + if (!fixableEntities.Contains("structure") && !fixableEntities.Contains(targetStructure.Prefab.Identifier)) return; + if (targetStructure.IsPlatform) return; int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition)); - if (sectionIndex < 0) { return false; } + if (sectionIndex < 0) return; FixStructureProjSpecific(user, deltaTime, targetStructure, sectionIndex); targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess, user); @@ -252,14 +239,12 @@ namespace Barotrauma.Items.Components targetCharacter.LastDamageSource = item; ApplyStatusEffectsOnTarget(user, deltaTime, ActionType.OnUse, new List() { targetCharacter }); FixCharacterProjSpecific(user, deltaTime, targetCharacter); - return true; } else if (targetBody.UserData is Limb targetLimb) { targetLimb.character.LastDamageSource = item; ApplyStatusEffectsOnTarget(user, deltaTime, ActionType.OnUse, new List() { targetLimb.character, targetLimb }); FixCharacterProjSpecific(user, deltaTime, targetLimb.character); - return true; } else if (targetBody.UserData is Item targetItem) { @@ -284,7 +269,6 @@ namespace Barotrauma.Items.Components #endif } FixItemProjSpecific(user, deltaTime, targetItem, prevCondition); - return true; } return false; } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs index 2cb8f3192..f9620770f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs @@ -730,15 +730,7 @@ namespace Barotrauma return closestBody; } - private static readonly Dictionary bodyDist = new Dictionary(); - private static readonly List bodies = new List(); - - /// - /// Returns a list of physics bodies the ray intersects with, sorted according to distance (the closest body is at the beginning of the list). - /// - /// Can be used to filter the bodies based on some condition. If the predicate returns false, the body isignored. - /// Should fixtures that the start of the ray is inside be returned - public static IEnumerable PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate customPredicate = null, bool allowInsideFixture = false) + public static List PickBodies(Vector2 rayStart, Vector2 rayEnd, IEnumerable ignoredBodies = null, Category? collisionCategory = null, bool ignoreSensors = true, Predicate customPredicate = null, bool allowInsideFixture = false) { if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f) { @@ -746,25 +738,20 @@ namespace Barotrauma } float closestFraction = 1.0f; - bodies.Clear(); - bodyDist.Clear(); + List bodies = new List(); GameMain.World.RayCast((fixture, point, normal, fraction) => { if (!CheckFixtureCollision(fixture, ignoredBodies, collisionCategory, ignoreSensors, customPredicate)) { return -1; } - if (fixture.Body != null) - { - bodies.Add(fixture.Body); - bodyDist[fixture.Body] = fraction; - } + if (fixture.Body != null) { bodies.Add(fixture.Body); } if (fraction < closestFraction) { lastPickedPosition = rayStart + (rayEnd - rayStart) * fraction; lastPickedFraction = fraction; lastPickedNormal = normal; } - //continue - return -1; + + return fraction; }, rayStart, rayEnd); if (allowInsideFixture) @@ -783,12 +770,10 @@ namespace Barotrauma lastPickedFraction = 0.0f; lastPickedNormal = Vector2.Normalize(rayEnd - rayStart); bodies.Add(fixture.Body); - bodyDist[fixture.Body] = 0.0f; return false; }, ref aabb); } - bodies.Sort((b1, b2) => { return bodyDist[b1].CompareTo(bodyDist[b2]); }); return bodies; }