added a way to decrease character updates
This commit is contained in:
@@ -28,6 +28,9 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<Character> CharacterList = new List<Character>();
|
||||
|
||||
public static int CharacterUpdateInterval = 1;
|
||||
private static int characterUpdateTick = 1;
|
||||
|
||||
partial void UpdateLimbLightSource(Limb limb);
|
||||
|
||||
private bool enabled = true;
|
||||
@@ -2667,9 +2670,23 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < CharacterList.Count; i++)
|
||||
characterUpdateTick++;
|
||||
|
||||
if (characterUpdateTick % CharacterUpdateInterval == 0)
|
||||
{
|
||||
CharacterList[i].Update(deltaTime, cam);
|
||||
for (int i = 0; i < CharacterList.Count; i++)
|
||||
{
|
||||
if (GameMain.Lua.game.updatePriorityCharacters.Contains(CharacterList[i])) continue;
|
||||
|
||||
CharacterList[i].Update(deltaTime * CharacterUpdateInterval, cam);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Character character in GameMain.Lua.game.updatePriorityCharacters)
|
||||
{
|
||||
if (character.Removed) continue;
|
||||
|
||||
character.Update(deltaTime, cam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,14 @@ namespace Barotrauma
|
||||
set { MapEntity.GapUpdateInterval = value; }
|
||||
}
|
||||
|
||||
public int characterUpdateInterval
|
||||
{
|
||||
get { return Character.CharacterUpdateInterval; }
|
||||
set { Character.CharacterUpdateInterval = value; }
|
||||
}
|
||||
|
||||
public HashSet<Item> updatePriorityItems = new HashSet<Item>();
|
||||
public HashSet<Character> updatePriorityCharacters = new HashSet<Character>();
|
||||
|
||||
public void AddPriorityItem(Item item)
|
||||
{
|
||||
@@ -79,6 +86,21 @@ namespace Barotrauma
|
||||
updatePriorityItems.Clear();
|
||||
}
|
||||
|
||||
public void AddPriorityCharacter(Character character)
|
||||
{
|
||||
updatePriorityCharacters.Add(character);
|
||||
}
|
||||
|
||||
public void RemovePriorityCharacter(Character character)
|
||||
{
|
||||
updatePriorityCharacters.Remove(character);
|
||||
}
|
||||
|
||||
public void ClearPriorityCharacter()
|
||||
{
|
||||
updatePriorityCharacters.Clear();
|
||||
}
|
||||
|
||||
public bool RoundStarted
|
||||
{
|
||||
|
||||
@@ -476,6 +498,7 @@ namespace Barotrauma
|
||||
{
|
||||
mapEntityUpdateInterval = 1;
|
||||
gapUpdateInterval = 4;
|
||||
characterUpdateInterval = 1;
|
||||
|
||||
foreach (var cmd in luaAddedCommand)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user