Fix Map Entity Updates
This commit is contained in:
@@ -134,7 +134,18 @@ namespace Barotrauma
|
||||
public bool disableDisconnectCharacter = false;
|
||||
public bool enableControlHusk = false;
|
||||
|
||||
public int mapEntityUpdateRate = 1;
|
||||
public int mapEntityUpdateInterval
|
||||
{
|
||||
get { return MapEntity.MapEntityUpdateInterval; }
|
||||
set { MapEntity.MapEntityUpdateInterval = value; }
|
||||
}
|
||||
|
||||
public int gapUpdateInterval
|
||||
{
|
||||
get { return MapEntity.GapUpdateInterval; }
|
||||
set { MapEntity.GapUpdateInterval = value; }
|
||||
}
|
||||
|
||||
public HashSet<Item> updatePriorityItems = new HashSet<Item>();
|
||||
|
||||
public void AddPriorityItem(Item item)
|
||||
|
||||
@@ -19,8 +19,9 @@ namespace Barotrauma
|
||||
protected List<ushort> linkedToID;
|
||||
public List<ushort> unresolvedLinkedToID;
|
||||
|
||||
private const int GapUpdateInterval = 4;
|
||||
private static int gapUpdateTimer;
|
||||
public static int MapEntityUpdateInterval = 1;
|
||||
public static int GapUpdateInterval = 4;
|
||||
private static int mapEntityUpdateTick;
|
||||
|
||||
/// <summary>
|
||||
/// List of upgrades this item has
|
||||
@@ -560,42 +561,61 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public static void UpdateAll(float deltaTime, Camera cam)
|
||||
{
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
mapEntityUpdateTick++;
|
||||
|
||||
if (mapEntityUpdateTick % MapEntityUpdateInterval == 0)
|
||||
{
|
||||
hull.Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
hull.Update(deltaTime * MapEntityUpdateInterval, cam);
|
||||
}
|
||||
#if CLIENT
|
||||
Hull.UpdateCheats(deltaTime, cam);
|
||||
Hull.UpdateCheats(deltaTime * MapEntityUpdateInterval, cam);
|
||||
#endif
|
||||
|
||||
foreach (Structure structure in Structure.WallList)
|
||||
{
|
||||
structure.Update(deltaTime, cam);
|
||||
foreach (Structure structure in Structure.WallList)
|
||||
{
|
||||
structure.Update(deltaTime * MapEntityUpdateInterval, cam);
|
||||
}
|
||||
}
|
||||
|
||||
//update gaps in random order, because otherwise in rooms with multiple gaps
|
||||
//the water/air will always tend to flow through the first gap in the list,
|
||||
//which may lead to weird behavior like water draining down only through
|
||||
//one gap in a room even if there are several
|
||||
gapUpdateTimer++;
|
||||
if (gapUpdateTimer >= GapUpdateInterval)
|
||||
if (mapEntityUpdateTick % GapUpdateInterval == 0)
|
||||
{
|
||||
foreach (Gap gap in Gap.GapList.OrderBy(g => Rand.Int(int.MaxValue)))
|
||||
{
|
||||
gap.Update(deltaTime * GapUpdateInterval, cam);
|
||||
}
|
||||
gapUpdateTimer = 0;
|
||||
}
|
||||
|
||||
Powered.UpdatePower(deltaTime);
|
||||
foreach (Item item in Item.ItemList)
|
||||
if (mapEntityUpdateTick % MapEntityUpdateInterval == 0)
|
||||
{
|
||||
Powered.UpdatePower(deltaTime * MapEntityUpdateInterval);
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (GameMain.Lua.game.updatePriorityItems.Contains(item)) continue;
|
||||
item.Update(deltaTime * MapEntityUpdateInterval, cam);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in GameMain.Lua.game.updatePriorityItems)
|
||||
{
|
||||
if (item.Removed) continue;
|
||||
|
||||
item.Update(deltaTime, cam);
|
||||
}
|
||||
|
||||
UpdateAllProjSpecific(deltaTime);
|
||||
if (mapEntityUpdateTick % MapEntityUpdateInterval == 0)
|
||||
{
|
||||
|
||||
Spawner?.Update();
|
||||
UpdateAllProjSpecific(deltaTime * MapEntityUpdateInterval);
|
||||
|
||||
Spawner?.Update();
|
||||
}
|
||||
}
|
||||
|
||||
static partial void UpdateAllProjSpecific(float deltaTime);
|
||||
|
||||
Reference in New Issue
Block a user