* Use new Subs.CVar helper Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe. This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown. * Fix a bunch of warnings * More warning fixes * Use new DateTime serializer to get rid of ISerializationHooks in changelog code. * Get rid of some more ISerializationHooks for enums * And a little more * Apply suggestions from code review Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: 0x6273 <0x40@keemail.me>
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Content.Server.EUI;
|
|
using Content.Server.Explosion.EntitySystems;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Eui;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Administration.UI;
|
|
|
|
/// <summary>
|
|
/// Admin Eui for spawning and preview-ing explosions
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class SpawnExplosionEui : BaseEui
|
|
{
|
|
private readonly ExplosionSystem _explosionSystem;
|
|
private readonly ISawmill _sawmill;
|
|
|
|
public SpawnExplosionEui()
|
|
{
|
|
_explosionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ExplosionSystem>();
|
|
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("explosion");
|
|
}
|
|
|
|
public override void HandleMessage(EuiMessageBase msg)
|
|
{
|
|
base.HandleMessage(msg);
|
|
|
|
if (msg is not SpawnExplosionEuiMsg.PreviewRequest request)
|
|
return;
|
|
|
|
if (request.TotalIntensity <= 0 || request.IntensitySlope <= 0)
|
|
return;
|
|
|
|
var explosion = EntitySystem.Get<ExplosionSystem>().GenerateExplosionPreview(request);
|
|
|
|
if (explosion == null)
|
|
{
|
|
_sawmill.Error("Failed to generate explosion preview.");
|
|
return;
|
|
}
|
|
|
|
SendMessage(new SpawnExplosionEuiMsg.PreviewData(explosion, request.IntensitySlope, request.TotalIntensity));
|
|
}
|
|
}
|