* Moves FlashComponent.cs, FlashOnTriggerComponent.cs, and SmokeOnTriggerComponent.cs to Shared * Moves ExplodeOnTriggerComponent.cs, OnUseTimerTriggerComponent.cs, ActiveTimerTriggerComponent.cs, and SmokeOnTriggerComponent.cs to Shared * Delete .run/Content Server+Client.run.xml HOW DID THIS GET IN HERE ITS NOT AHHHH * Update Content.Client/Explosion/SmokeOnTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/ActiveTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/OnUseTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/Components/OnUseTimerTriggerComponent.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/EntitySystems/SharedTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update Content.Shared/Explosion/EntitySystems/SharedSmokeOnTriggerSystem.cs Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> * Update ExplodeOnTriggerComponent.cs * Revert "Delete .run/Content Server+Client.run.xml" This reverts commit 29ee05f57de60eab5c92158d8eba5e3acba483c2. * Fix? * cannot figure out how to get this to go back please forgive * Fixes a network issue * leftovers * Fixes --------- Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
118 lines
4.0 KiB
C#
118 lines
4.0 KiB
C#
using System.Numerics;
|
|
using Content.Shared.Explosion.Components;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Client.Explosion;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class ExplosionOverlay : Overlay
|
|
{
|
|
[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;
|
|
|
|
private ShaderInstance _shader;
|
|
|
|
public ExplosionOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
_shader = _proto.Index<ShaderPrototype>("unshaded").Instance();
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
var drawHandle = args.WorldHandle;
|
|
drawHandle.UseShader(_shader);
|
|
|
|
var xforms = _entMan.GetEntityQuery<TransformComponent>();
|
|
var query = _entMan
|
|
.EntityQuery<ExplosionVisualsComponent, ExplosionVisualsTexturesComponent, AppearanceComponent>(true);
|
|
|
|
foreach (var (visuals, textures, appearance) in query)
|
|
{
|
|
if (visuals.Epicenter.MapId != args.MapId)
|
|
continue;
|
|
|
|
if (!appearance.TryGetData(ExplosionAppearanceData.Progress, out int index))
|
|
continue;
|
|
|
|
index = Math.Min(index, visuals.Intensity.Count - 1);
|
|
DrawExplosion(drawHandle, args.WorldBounds, visuals, index, xforms, textures);
|
|
}
|
|
|
|
drawHandle.SetTransform(Matrix3.Identity);
|
|
drawHandle.UseShader(null);
|
|
}
|
|
|
|
private void DrawExplosion(
|
|
DrawingHandleWorld drawHandle,
|
|
Box2Rotated worldBounds,
|
|
ExplosionVisualsComponent visuals,
|
|
int index,
|
|
EntityQuery<TransformComponent> xforms,
|
|
ExplosionVisualsTexturesComponent textures)
|
|
{
|
|
Box2 gridBounds;
|
|
foreach (var (gridId, tiles) in visuals.Tiles)
|
|
{
|
|
if (!_entMan.TryGetComponent(gridId, out MapGridComponent? grid))
|
|
continue;
|
|
|
|
var xform = xforms.GetComponent(gridId);
|
|
var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
|
|
|
|
gridBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2);
|
|
drawHandle.SetTransform(worldMatrix);
|
|
|
|
DrawTiles(drawHandle, gridBounds, index, tiles, visuals, grid.TileSize, textures);
|
|
}
|
|
|
|
if (visuals.SpaceTiles == null)
|
|
return;
|
|
|
|
gridBounds = Matrix3.Invert(visuals.SpaceMatrix).TransformBox(worldBounds).Enlarged(2);
|
|
drawHandle.SetTransform(visuals.SpaceMatrix);
|
|
|
|
DrawTiles(drawHandle, gridBounds, index, visuals.SpaceTiles, visuals, visuals.SpaceTileSize, textures);
|
|
}
|
|
|
|
private void DrawTiles(
|
|
DrawingHandleWorld drawHandle,
|
|
Box2 gridBounds,
|
|
int index,
|
|
Dictionary<int, List<Vector2i>> tileSets,
|
|
ExplosionVisualsComponent visuals,
|
|
ushort tileSize,
|
|
ExplosionVisualsTexturesComponent textures)
|
|
{
|
|
for (var j = 0; j <= index; j++)
|
|
{
|
|
if (!tileSets.TryGetValue(j, out var tiles))
|
|
continue;
|
|
|
|
var frameIndex = (int) Math.Min(visuals.Intensity[j] / textures.IntensityPerState, textures.FireFrames.Count - 1);
|
|
var frames = textures.FireFrames[frameIndex];
|
|
|
|
foreach (var tile in tiles)
|
|
{
|
|
var centre = (tile + Vector2Helpers.Half) * tileSize;
|
|
|
|
if (!gridBounds.Contains(centre))
|
|
continue;
|
|
|
|
var texture = _robustRandom.Pick(frames);
|
|
drawHandle.DrawTextureRect(texture, Box2.CenteredAround(centre, new Vector2(tileSize, tileSize)), textures.FireColor);
|
|
}
|
|
}
|
|
}
|
|
}
|