mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
* Removed the Interfaces folder. * All objects inside the GameObjects subfolders are now in the GameObjects namespace. * Added a Resharper DotSettings file to mark the GameObjects subfolders as not providing namespaces. * Simplified Robust.client.Graphics namespace. * Automated remove redundant using statements.
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Robust.Client.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Updates the layer animation for every visible sprite.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public class SpriteSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
|
|
|
/// <inheritdoc />
|
|
public override void FrameUpdate(float frameTime)
|
|
{
|
|
var renderTreeSystem = EntitySystemManager.GetEntitySystem<RenderingTreeSystem>();
|
|
|
|
// So we could calculate the correct size of the entities based on the contents of their sprite...
|
|
// Or we can just assume that no entity is larger than 10x10 and get a stupid easy check.
|
|
var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5);
|
|
|
|
var currentMap = _eyeManager.CurrentMap;
|
|
if (currentMap == MapId.Nullspace)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap);
|
|
|
|
mapTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) =>
|
|
{
|
|
if (value.IsInert)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
value.FrameUpdate(state);
|
|
return true;
|
|
}, pvsBounds, approx: true);
|
|
}
|
|
}
|
|
}
|