2021-07-17 02:37:09 +02:00
|
|
|
|
using Content.Server.Chemistry.Components;
|
2022-02-26 21:04:01 -06:00
|
|
|
|
using Content.Server.Coordinates.Helpers;
|
|
|
|
|
|
using Content.Shared.Audio;
|
|
|
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-02-03 11:26:46 -03:00
|
|
|
|
using JetBrains.Annotations;
|
2022-02-26 21:04:01 -06:00
|
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
using Robust.Shared.Player;
|
2021-02-03 11:26:46 -03:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Chemistry.ReactionEffects
|
|
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataDefinition]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class FoamAreaReactionEffect : AreaReactionEffect
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
|
protected override SolutionAreaEffectComponent? GetAreaEffectComponent(EntityUid entity)
|
2021-02-03 11:26:46 -03:00
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
|
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<FoamSolutionAreaEffectComponent>(entity);
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
2022-02-26 21:04:01 -06:00
|
|
|
|
|
|
|
|
|
|
public static void SpawnFoam(string entityPrototype, EntityCoordinates coords, Solution? contents, int amount, float duration, float spreadDelay,
|
|
|
|
|
|
float removeDelay, SoundSpecifier sound, IEntityManager? entityManager = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
|
var ent = entityManager.SpawnEntity(entityPrototype, coords.SnapToGrid());
|
|
|
|
|
|
|
|
|
|
|
|
var areaEffectComponent = entityManager.GetComponentOrNull<FoamSolutionAreaEffectComponent>(ent);
|
|
|
|
|
|
|
|
|
|
|
|
if (areaEffectComponent == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.Error("Couldn't get AreaEffectComponent from " + entityPrototype);
|
|
|
|
|
|
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(ent);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (contents != null)
|
|
|
|
|
|
areaEffectComponent.TryAddSolution(contents);
|
|
|
|
|
|
areaEffectComponent.Start(amount, duration, spreadDelay, removeDelay);
|
|
|
|
|
|
|
2022-06-12 19:45:47 -04:00
|
|
|
|
SoundSystem.Play(sound.GetSound(), Filter.Pvs(ent), ent, AudioHelpers.WithVariation(0.125f));
|
2022-02-26 21:04:01 -06:00
|
|
|
|
}
|
2021-02-03 11:26:46 -03:00
|
|
|
|
}
|
|
|
|
|
|
}
|