fish-station/Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs
Vigers Ray 0e350ab6d3 Merge remote-tracking branch 'space-wizards/master'
# Conflicts:
#	Content.Client/Actions/ActionsSystem.cs
#	Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml
#	Content.Server/GameTicking/GameTicker.GamePreset.cs
#	Content.Server/GameTicking/GameTicker.Spawning.cs
#	Content.Server/Station/Systems/StationSpawningSystem.cs
#	Content.Shared/Actions/BaseActionComponent.cs
#	Content.Shared/Actions/SharedActionsSystem.cs
#	Content.Shared/Weapons/Reflect/ReflectComponent.cs
#	Content.Shared/Weapons/Reflect/ReflectSystem.cs
#	README.md
#	Resources/Prototypes/Actions/types.yml
#	Resources/Prototypes/Entities/Clothing/Eyes/hud.yml
#	Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
#	Resources/Prototypes/Entities/Mobs/Player/dragon.yml
#	Resources/Prototypes/Recipes/Lathes/security.yml
#	Resources/Prototypes/ai_factions.yml
2025-04-19 00:46:30 +03:00

73 lines
2.7 KiB
C#

using System.Numerics;
using Content.Shared.Explosion;
using Content.Shared.Explosion.Components;
using Content.Shared.Explosion.EntitySystems;
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
{
public void InitVisuals()
{
SubscribeLocalEvent<ExplosionVisualsComponent, ComponentGetState>(OnGetState);
}
private void OnGetState(EntityUid uid, ExplosionVisualsComponent component, ref ComponentGetState args)
{
Dictionary<NetEntity, Dictionary<int, List<Vector2i>>> tileLists = new();
foreach (var (grid, data) in component.Tiles)
{
tileLists.Add(GetNetEntity(grid), data);
}
args.State = new ExplosionVisualsState(
component.Epicenter,
component.ExplosionType,
component.Intensity,
component.SpaceTiles,
tileLists,
component.SpaceMatrix,
component.SpaceTileSize);
}
/// <summary>
/// Constructor for the shared <see cref="ExplosionEvent"/> using the server-exclusive explosion classes.
/// </summary>
private EntityUid CreateExplosionVisualEntity(MapCoordinates epicenter, ExplosionPrototype prototype, Matrix3x2 spaceMatrix, ExplosionSpaceTileFlood? spaceData, IEnumerable<ExplosionGridTileFlood> gridData, List<float> iterationIntensity)
{
var explosionEntity = Spawn(null, MapCoordinates.Nullspace);
// Sunrise added start
if (prototype.EffectType != ExplosionEffectType.Standard)
return explosionEntity;
// Sunrise added end
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.ID; // Sunrise edit
comp.Intensity = iterationIntensity;
comp.SpaceMatrix = spaceMatrix;
comp.SpaceTileSize = spaceData?.TileSize ?? DefaultTileSize;
Dirty(explosionEntity, 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;
}
}