Remove explosion networking jank (#12733)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Explosion;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
@@ -10,26 +11,10 @@ namespace Content.Client.Explosion;
|
||||
[UsedImplicitly]
|
||||
public sealed class ExplosionOverlay : Overlay
|
||||
{
|
||||
/// <summary>
|
||||
/// The explosion that needs to be drawn. This explosion is currently being processed by the server and
|
||||
/// expanding outwards.
|
||||
/// </summary>
|
||||
internal Explosion? ActiveExplosion;
|
||||
|
||||
/// <summary>
|
||||
/// This index specifies what parts of the currently expanding explosion should be drawn.
|
||||
/// </summary>
|
||||
public int Index;
|
||||
|
||||
/// <summary>
|
||||
/// These explosions have finished expanding, but we will draw for a few more frames. This is important for
|
||||
/// small explosions, as otherwise they disappear far too quickly.
|
||||
/// </summary>
|
||||
internal List<Explosion> CompletedExplosions = new ();
|
||||
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
|
||||
|
||||
@@ -38,7 +23,7 @@ public sealed class ExplosionOverlay : Overlay
|
||||
public ExplosionOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>("unshaded").Instance();
|
||||
_shader = _proto.Index<ShaderPrototype>("unshaded").Instance();
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
@@ -48,22 +33,20 @@ public sealed class ExplosionOverlay : Overlay
|
||||
|
||||
var xforms = _entMan.GetEntityQuery<TransformComponent>();
|
||||
|
||||
if (ActiveExplosion != null && ActiveExplosion.Map == args.Viewport.Eye?.Position.MapId)
|
||||
foreach (var (comp, appearance) in _entMan.EntityQuery<ExplosionVisualsComponent, AppearanceComponent>(true))
|
||||
{
|
||||
DrawExplosion(drawHandle, args.WorldBounds, ActiveExplosion, Index, xforms);
|
||||
}
|
||||
if (!appearance.TryGetData(ExplosionAppearanceData.Progress, out int index))
|
||||
continue;
|
||||
|
||||
foreach (var exp in CompletedExplosions)
|
||||
{
|
||||
if (exp.Map == args.Viewport.Eye?.Position.MapId)
|
||||
DrawExplosion(drawHandle, args.WorldBounds, exp, exp.Intensity.Count, xforms);
|
||||
index = Math.Min(index, comp.Intensity.Count - 1);
|
||||
DrawExplosion(drawHandle, args.WorldBounds, comp, index, xforms);
|
||||
}
|
||||
|
||||
drawHandle.SetTransform(Matrix3.Identity);
|
||||
drawHandle.UseShader(null);
|
||||
}
|
||||
|
||||
private void DrawExplosion(DrawingHandleWorld drawHandle, Box2Rotated worldBounds, Explosion exp, int index, EntityQuery<TransformComponent> xforms)
|
||||
private void DrawExplosion(DrawingHandleWorld drawHandle, Box2Rotated worldBounds, ExplosionVisualsComponent exp, int index, EntityQuery<TransformComponent> xforms)
|
||||
{
|
||||
Box2 gridBounds;
|
||||
foreach (var (gridId, tiles) in exp.Tiles)
|
||||
@@ -94,10 +77,10 @@ public sealed class ExplosionOverlay : Overlay
|
||||
Box2 gridBounds,
|
||||
int index,
|
||||
Dictionary<int, List<Vector2i>> tileSets,
|
||||
Explosion exp,
|
||||
ExplosionVisualsComponent exp,
|
||||
ushort tileSize)
|
||||
{
|
||||
for (var j = 0; j < index; j++)
|
||||
for (var j = 0; j <= index; j++)
|
||||
{
|
||||
if (!tileSets.TryGetValue(j, out var tiles))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user