Reapply "OBT1.1.0 Merge branch 'dev_pte' into dev"

This reverts commit 046483b9da.
This commit is contained in:
NotAlwaysTrue
2026-04-30 21:59:54 +08:00
parent 02689d0d86
commit 25683dcf39
85 changed files with 2413 additions and 779 deletions
@@ -890,7 +890,8 @@ namespace Barotrauma.Items.Components
RelatedItem containableItem = FindContainableItem(containedItem);
if (containableItem != null && containableItem.SetActive)
{
foreach (var ic in containedItem.Components)
// Use ToArray() snapshot for thread-safe iteration
foreach (var ic in containedItem.Components.ToArray())
{
ic.IsActive = active;
}
@@ -1016,7 +1017,11 @@ namespace Barotrauma.Items.Components
if (flippedX ^ flippedY) { rotation = -rotation; }
rotation += -item.RotationRad;
}
contained.Item.body.FarseerBody.SetTransformIgnoreContacts(ref simPos, rotation);
// Defer physics operation if in parallel context (Farseer is not thread-safe)
var capturedBody = contained.Item.body.FarseerBody;
var capturedSimPos = simPos;
var capturedRotation = rotation;
PhysicsBodyQueue.ExecuteOrDefer(() => capturedBody.SetTransformIgnoreContacts(ref capturedSimPos, capturedRotation));
contained.Item.body.UpdateDrawPosition(interpolate: false);
}
catch (Exception e)