59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using Content.Shared.Explosion;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Explosion.EntitySystems;
|
|
|
|
// This part of the system handled send visual / overlay data to clients.
|
|
public sealed partial class ExplosionSystem : EntitySystem
|
|
{
|
|
public void InitVisuals()
|
|
{
|
|
SubscribeLocalEvent<ExplosionVisualsComponent, ComponentGetState>(OnGetState);
|
|
}
|
|
|
|
private void OnGetState(EntityUid uid, ExplosionVisualsComponent component, ref ComponentGetState args)
|
|
{
|
|
args.State = new ExplosionVisualsState(
|
|
component.Epicenter,
|
|
component.ExplosionType,
|
|
component.Intensity,
|
|
component.SpaceTiles,
|
|
component.Tiles,
|
|
component.SpaceMatrix,
|
|
component.SpaceTileSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor for the shared <see cref="ExplosionEvent"/> using the server-exclusive explosion classes.
|
|
/// </summary>
|
|
private EntityUid CreateExplosionVisualEntity(MapCoordinates epicenter, string prototype, Matrix3 spaceMatrix, ExplosionSpaceTileFlood? spaceData, IEnumerable<ExplosionGridTileFlood> gridData, List<float> iterationIntensity)
|
|
{
|
|
var explosionEntity = Spawn(null, MapCoordinates.Nullspace);
|
|
var comp = AddComp<ExplosionVisualsComponent>(explosionEntity);
|
|
|
|
foreach (var grid in gridData)
|
|
{
|
|
comp.Tiles.Add(grid.Grid.Owner, grid.TileLists);
|
|
}
|
|
|
|
comp.SpaceTiles = spaceData?.TileLists;
|
|
comp.Epicenter = epicenter;
|
|
comp.ExplosionType = prototype;
|
|
comp.Intensity = iterationIntensity;
|
|
comp.SpaceMatrix = spaceMatrix;
|
|
comp.SpaceTileSize = spaceData?.TileSize ?? DefaultTileSize;
|
|
Dirty(comp);
|
|
|
|
// Light, sound & visuals may extend well beyond normal PVS range. In principle, this should probably still be
|
|
// restricted to something like the same map, but whatever.
|
|
_pvsSys.AddGlobalOverride(explosionEntity);
|
|
|
|
var appearance = AddComp<AppearanceComponent>(explosionEntity);
|
|
_appearance.SetData(explosionEntity, ExplosionAppearanceData.Progress, 1, appearance);
|
|
|
|
return explosionEntity;
|
|
}
|
|
}
|