@@ -46,11 +46,11 @@ namespace Barotrauma
|
||||
public const string LuaSetupFile = "Lua/LuaSetup.lua";
|
||||
public const string VersionFile = "luacsversion.txt";
|
||||
#if WINDOWS
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2559634234);
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3629459376);
|
||||
#elif LINUX
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970628943);
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3632586273);
|
||||
#elif OSX
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970890020);
|
||||
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3672543756);
|
||||
#endif
|
||||
|
||||
public static ContentPackageId CsForBarotraumaId = new SteamWorkshopId(2795927223);
|
||||
|
||||
@@ -18,13 +18,10 @@ namespace Barotrauma
|
||||
{
|
||||
partial class GameScreen : Screen
|
||||
{
|
||||
private object updateLock = new object();
|
||||
private double physicsTime;
|
||||
|
||||
// -2 here bcuz we alread have a SEEM thread there
|
||||
// Use default instead. Hopefully this wont cause issues in long-running servers.
|
||||
private static readonly ParallelOptions parallelOptions = new ParallelOptions
|
||||
{
|
||||
MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 2)
|
||||
//MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 1)
|
||||
};
|
||||
|
||||
#if CLIENT
|
||||
@@ -62,13 +59,13 @@ namespace Barotrauma
|
||||
#if CLIENT
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
cam.Position = Character.Controlled.WorldPosition;
|
||||
cam.UpdateTransform(true);
|
||||
Cam.Position = Character.Controlled.WorldPosition;
|
||||
Cam.UpdateTransform(true);
|
||||
}
|
||||
else if (Submarine.MainSub != null)
|
||||
{
|
||||
cam.Position = Submarine.MainSub.WorldPosition;
|
||||
cam.UpdateTransform(true);
|
||||
Cam.Position = Submarine.MainSub.WorldPosition;
|
||||
Cam.UpdateTransform(true);
|
||||
}
|
||||
GameMain.GameSession?.CrewManager?.ResetCrewListOpenState();
|
||||
ChatBox.ResetChatBoxOpenState();
|
||||
@@ -108,14 +105,12 @@ namespace Barotrauma
|
||||
var submarines = Submarine.Loaded.ToList();
|
||||
var physicsBodies = PhysicsBody.List.ToList();
|
||||
|
||||
#warning For now CL side performance counter is partly useless bucz multiple changes on such things. Need time to take care of it
|
||||
|
||||
#if DEBUG && CLIENT
|
||||
if (GameMain.GameSession != null && !DebugConsole.IsOpen && GUI.KeyboardDispatcher.Subscriber == null)
|
||||
{
|
||||
if (GameMain.GameSession.Level != null && GameMain.GameSession.Submarine != null)
|
||||
{
|
||||
Submarine closestSub = Submarine.FindClosest(cam.WorldViewCenter) ?? GameMain.GameSession.Submarine;
|
||||
Submarine closestSub = Submarine.FindClosest(Cam.WorldViewCenter) ?? GameMain.GameSession.Submarine;
|
||||
|
||||
Vector2 targetMovement = Vector2.Zero;
|
||||
if (PlayerInput.KeyDown(Keys.I)) { targetMovement.Y += 1.0f; }
|
||||
@@ -145,27 +140,38 @@ namespace Barotrauma
|
||||
body.Update();
|
||||
}
|
||||
});
|
||||
GameMain.GameSession?.Update((float)deltaTime);
|
||||
|
||||
MapEntity.ClearHighlightedEntities();
|
||||
|
||||
#if CLIENT
|
||||
var sw = new System.Diagnostics.Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
Parallel.Invoke(parallelOptions,
|
||||
() => GameMain.ParticleManager.Update((float)deltaTime),
|
||||
() => { if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime, cam); }
|
||||
);
|
||||
|
||||
#endif
|
||||
GameMain.GameSession?.Update((float)deltaTime);
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Particles+Level", sw.ElapsedTicks);
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:GameSession", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Particle", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
#endif
|
||||
|
||||
if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Cam); }
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Level", sw.ElapsedTicks);
|
||||
|
||||
if (Character.Controlled is { } controlled)
|
||||
{
|
||||
if (controlled.SelectedItem != null && controlled.CanInteractWith(controlled.SelectedItem))
|
||||
{
|
||||
controlled.SelectedItem.UpdateHUD(cam, controlled, (float)deltaTime);
|
||||
controlled.SelectedItem.UpdateHUD(Cam, controlled, (float)deltaTime);
|
||||
}
|
||||
if (controlled.Inventory != null)
|
||||
{
|
||||
@@ -173,7 +179,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (controlled.HasEquippedItem(item))
|
||||
{
|
||||
item.UpdateHUD(cam, controlled, (float)deltaTime);
|
||||
item.UpdateHUD(Cam, controlled, (float)deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,11 +187,19 @@ namespace Barotrauma
|
||||
|
||||
sw.Restart();
|
||||
|
||||
Character.UpdateAll((float)deltaTime, cam);
|
||||
#endif
|
||||
Character.UpdateAll((float)deltaTime, Cam);
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:Character", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
#endif
|
||||
|
||||
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
|
||||
StatusEffect.UpdateAll((float)deltaTime);
|
||||
|
||||
#if CLIENT
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Update:StatusEffects", sw.ElapsedTicks);
|
||||
@@ -211,24 +225,15 @@ namespace Barotrauma
|
||||
}
|
||||
Vector2 screenOffset = screenTargetPos - new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight / 2);
|
||||
screenOffset.Y = -screenOffset.Y;
|
||||
targetPos -= screenOffset / cam.Zoom;
|
||||
targetPos -= screenOffset / Cam.Zoom;
|
||||
}
|
||||
}
|
||||
cam.TargetPos = targetPos;
|
||||
Cam.TargetPos = targetPos;
|
||||
}
|
||||
|
||||
cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null && !Inventory.IsMouseOnInventory);
|
||||
Cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null && !Inventory.IsMouseOnInventory);
|
||||
|
||||
Character.Controlled?.UpdateLocalCursor(cam);
|
||||
|
||||
#elif SERVER
|
||||
|
||||
// Don't parallize these things here or the server may got stuck but why idk
|
||||
if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Camera.Instance); }
|
||||
Character.UpdateAll((float)deltaTime, Camera.Instance);
|
||||
|
||||
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
|
||||
StatusEffect.UpdateAll((float)deltaTime);
|
||||
Character.Controlled?.UpdateLocalCursor(Cam);
|
||||
#endif
|
||||
|
||||
foreach (Submarine sub in submarines)
|
||||
@@ -244,12 +249,7 @@ namespace Barotrauma
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
#if CLIENT
|
||||
MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions);
|
||||
#elif SERVER
|
||||
MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions);
|
||||
#endif
|
||||
MapEntity.UpdateAll((float)deltaTime, Cam, parallelOptions);
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
@@ -259,12 +259,9 @@ namespace Barotrauma
|
||||
//Character.UpdateAnimAll is not thread-safe and must be executed on the main thread
|
||||
Character.UpdateAnimAll((float)deltaTime);
|
||||
|
||||
#if CLIENT
|
||||
Ragdoll.UpdateAll((float)deltaTime, cam);
|
||||
#elif SERVER
|
||||
Ragdoll.UpdateAll((float)deltaTime, Camera.Instance);
|
||||
|
||||
Ragdoll.UpdateAll((float)deltaTime, Cam);
|
||||
SingleThreadWorker.GlobalWorker.RunActions();
|
||||
#endif
|
||||
|
||||
#if CLIENT
|
||||
sw.Stop();
|
||||
@@ -301,20 +298,5 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific(double deltaTime);
|
||||
|
||||
private void ExecutePhysics()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
while (physicsTime >= Timing.Step)
|
||||
{
|
||||
lock (updateLock)
|
||||
{
|
||||
GameMain.World.Step((float)Timing.Step);
|
||||
physicsTime -= Timing.Step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user