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

This reverts commit 177cf89756, reversing
changes made to 42ba733cd4.
This commit is contained in:
Eero
2025-12-29 11:18:11 +08:00
parent 177cf89756
commit 046483b9da
86 changed files with 800 additions and 2496 deletions
@@ -5,10 +5,8 @@ using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using Barotrauma.Extensions;
using LimbParams = Barotrauma.RagdollParams.LimbParams;
@@ -27,33 +25,7 @@ namespace Barotrauma
/// </summary>
const float MaxImpactDamage = 0.1f;
// Thread-safe list using copy-on-write pattern (ConcurrentBag doesn't support indexer/Remove)
private static volatile List<Ragdoll> _list = new List<Ragdoll>();
private static readonly object _listLock = new object();
private static List<Ragdoll> list => _list;
private static void ListAdd(Ragdoll ragdoll)
{
lock (_listLock)
{
var newList = new List<Ragdoll>(_list) { ragdoll };
Interlocked.Exchange(ref _list, newList);
}
}
private static bool ListRemove(Ragdoll ragdoll)
{
lock (_listLock)
{
var newList = new List<Ragdoll>(_list);
bool removed = newList.Remove(ragdoll);
if (removed)
{
Interlocked.Exchange(ref _list, newList);
}
return removed;
}
}
private static readonly List<Ragdoll> list = new List<Ragdoll>();
struct Impact
{
@@ -73,8 +45,7 @@ namespace Barotrauma
}
}
// Thread-safe queue for physics collision callbacks
private readonly ConcurrentQueue<Impact> impactQueue = new ConcurrentQueue<Impact>();
private readonly Queue<Impact> impactQueue = new Queue<Impact>();
protected Hull currentHull;
@@ -496,7 +467,7 @@ namespace Barotrauma
public Ragdoll(Character character, string seed, RagdollParams ragdollParams = null)
{
ListAdd(this);
list.Add(this);
this.character = character;
Recreate(ragdollParams ?? RagdollParams);
}
@@ -773,7 +744,10 @@ namespace Barotrauma
{
if (!f2.IsSensor)
{
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
lock (impactQueue)
{
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
}
}
return true;
}
@@ -845,7 +819,10 @@ namespace Barotrauma
}
}
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
lock (impactQueue)
{
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
}
return true;
}
@@ -1297,8 +1274,9 @@ namespace Barotrauma
{
if (!character.Enabled || character.Removed || Frozen || Invalid || Collider == null || Collider.Removed) { return; }
while (impactQueue.TryDequeue(out var impact))
while (impactQueue.Count > 0)
{
var impact = impactQueue.Dequeue();
ApplyImpact(impact.F1, impact.F2, impact.LocalNormal, impact.ImpactPos, impact.Velocity);
}
@@ -2347,7 +2325,7 @@ namespace Barotrauma
LimbJoints = null;
}
ListRemove(this);
list.Remove(this);
}
public static void RemoveAll()