Ice anomaly (#15925)
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
30
Content.Server/Anomaly/Effects/ExplosionAnomalySystem.cs
Normal file
30
Content.Server/Anomaly/Effects/ExplosionAnomalySystem.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// This handles <see cref="ExplosionAnomalyComponent"/>
|
||||
/// </summary>
|
||||
public sealed class ExplosionAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ExplosionSystem _boom = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ExplosionAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
|
||||
}
|
||||
|
||||
private void OnSupercritical(EntityUid uid, ExplosionAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
_boom.QueueExplosion(
|
||||
uid,
|
||||
component.ExplosionPrototype,
|
||||
component.TotalIntensity,
|
||||
component.Dropoff,
|
||||
component.MaxTileIntensity
|
||||
);
|
||||
}
|
||||
}
|
||||
75
Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
Normal file
75
Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// This handles <see cref="GasProducerAnomalyComponent"/> and the events from <seealso cref="AnomalySystem"/>
|
||||
/// </summary>
|
||||
public sealed class GasProducerAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
|
||||
[Dependency] private readonly TransformSystem _xform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<GasProducerAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
|
||||
}
|
||||
|
||||
private void OnSupercritical(EntityUid uid, GasProducerAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
if (!component.ReleaseOnMaxSeverity)
|
||||
return;
|
||||
|
||||
ReleaseGas(uid, component.ReleasedGas, component.SuperCriticalMoleAmount);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<GasProducerAnomalyComponent>();
|
||||
while (query.MoveNext(out var ent, out var comp))
|
||||
{
|
||||
if (!comp.ReleasePassively)
|
||||
continue;
|
||||
|
||||
// Yes this is unused code since there are no anomalies that
|
||||
// release gas passively *yet*, but since I'm here I figured
|
||||
// I'd save someone some time and just add it for the future
|
||||
ReleaseGas(ent, comp.ReleasedGas, comp.PassiveMoleAmount * frameTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseGas(EntityUid uid, Gas gas, float amount)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var grid = xform.GridUid;
|
||||
var map = xform.MapUid;
|
||||
|
||||
var indices = _xform.GetGridOrMapTilePosition(uid, xform);
|
||||
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
|
||||
|
||||
if (mixture == null)
|
||||
return;
|
||||
|
||||
mixture.AdjustMoles(gas, amount);
|
||||
|
||||
if (grid is { })
|
||||
{
|
||||
foreach (var ind in _atmosphere.GetAdjacentTiles(grid.Value, indices))
|
||||
{
|
||||
var mix = _atmosphere.GetTileMixture(grid, map, ind, true);
|
||||
|
||||
if (mix is not { })
|
||||
continue;
|
||||
|
||||
mix.AdjustMoles(gas, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs
Normal file
91
Content.Server/Anomaly/Effects/ProjectileAnomalySystem.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Projectiles;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// This handles <see cref="ProjectileAnomalyComponent"/> and the events from <seealso cref="AnomalySystem"/>
|
||||
/// </summary>
|
||||
public sealed class ProjectileAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly TransformSystem _xform = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly GunSystem _gunSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<ProjectileAnomalyComponent, AnomalyPulseEvent>(OnPulse);
|
||||
SubscribeLocalEvent<ProjectileAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
|
||||
}
|
||||
|
||||
private void OnPulse(EntityUid uid, ProjectileAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
ShootProjectilesAtEntities(uid, component, args.Severity);
|
||||
}
|
||||
|
||||
private void OnSupercritical(EntityUid uid, ProjectileAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
ShootProjectilesAtEntities(uid, component, 1.0f);
|
||||
}
|
||||
|
||||
private void ShootProjectilesAtEntities(EntityUid uid, ProjectileAnomalyComponent component, float severity)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var projectilesShot = 0;
|
||||
var range = component.ProjectileRange * severity;
|
||||
var mobQuery = GetEntityQuery<MindComponent>();
|
||||
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(uid, range, LookupFlags.Dynamic))
|
||||
{
|
||||
if (projectilesShot >= component.MaxProjectiles * severity)
|
||||
return;
|
||||
|
||||
// Sentient entities are more likely to be shot at than non sentient
|
||||
if (!mobQuery.HasComponent(entity) && !_random.Prob(component.TargetNonSentientChance))
|
||||
continue;
|
||||
|
||||
var targetCoords = Transform(entity).Coordinates.Offset(_random.NextVector2(-1, 1));
|
||||
|
||||
ShootProjectile(
|
||||
uid, component,
|
||||
xform.Coordinates,
|
||||
targetCoords,
|
||||
severity
|
||||
);
|
||||
projectilesShot++;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShootProjectile(
|
||||
EntityUid uid,
|
||||
ProjectileAnomalyComponent component,
|
||||
EntityCoordinates coords,
|
||||
EntityCoordinates targetCoords,
|
||||
float severity
|
||||
)
|
||||
{
|
||||
var mapPos = coords.ToMap(EntityManager, _xform);
|
||||
|
||||
var spawnCoords = _mapManager.TryFindGridAt(mapPos, out var grid)
|
||||
? coords.WithEntityId(grid.Owner, EntityManager)
|
||||
: new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position);
|
||||
|
||||
var ent = Spawn(component.ProjectilePrototype, spawnCoords);
|
||||
var direction = targetCoords.ToMapPos(EntityManager, _xform) - mapPos.Position;
|
||||
|
||||
if (!TryComp<ProjectileComponent>(ent, out var comp))
|
||||
return;
|
||||
|
||||
comp.Damage *= severity;
|
||||
|
||||
_gunSystem.ShootProjectile(ent, direction, Vector2.Zero, uid, component.MaxProjectileSpeed * severity);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Effects.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
@@ -13,11 +12,9 @@ namespace Content.Server.Anomaly.Effects;
|
||||
/// </summary>
|
||||
public sealed class PyroclasticAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly FlammableSystem _flammable = default!;
|
||||
[Dependency] private readonly InteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly TransformSystem _xform = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -36,54 +33,9 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
|
||||
private void OnSupercritical(EntityUid uid, PyroclasticAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var grid = xform.GridUid;
|
||||
var map = xform.MapUid;
|
||||
|
||||
var indices = _xform.GetGridOrMapTilePosition(uid, xform);
|
||||
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
|
||||
|
||||
if (mixture == null)
|
||||
return;
|
||||
mixture.AdjustMoles(component.SupercriticalGas, component.SupercriticalMoleAmount);
|
||||
if (grid is { })
|
||||
{
|
||||
foreach (var ind in _atmosphere.GetAdjacentTiles(grid.Value, indices))
|
||||
{
|
||||
var mix = _atmosphere.GetTileMixture(grid, map, ind, true);
|
||||
if (mix is not { })
|
||||
continue;
|
||||
|
||||
mix.AdjustMoles(component.SupercriticalGas, component.SupercriticalMoleAmount);
|
||||
mix.Temperature += component.HotspotExposeTemperature;
|
||||
_atmosphere.HotspotExpose(grid.Value, indices, component.HotspotExposeTemperature, mix.Volume, uid, true);
|
||||
}
|
||||
}
|
||||
IgniteNearby(xform.Coordinates, 1, component.MaximumIgnitionRadius * 2);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<PyroclasticAnomalyComponent, AnomalyComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var ent, out var pyro, out var anom, out var xform))
|
||||
{
|
||||
var grid = xform.GridUid;
|
||||
var map = xform.MapUid;
|
||||
var indices = _xform.GetGridOrMapTilePosition(ent, xform);
|
||||
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
|
||||
if (mixture is { })
|
||||
{
|
||||
mixture.Temperature += pyro.HeatPerSecond * anom.Severity * frameTime;
|
||||
}
|
||||
|
||||
if (grid != null && anom.Severity > pyro.AnomalyHotspotThreshold)
|
||||
{
|
||||
_atmosphere.HotspotExpose(grid.Value, indices, pyro.HotspotExposeTemperature, pyro.HotspotExposeVolume, ent, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void IgniteNearby(EntityCoordinates coordinates, float severity, float radius)
|
||||
{
|
||||
foreach (var flammable in _lookup.GetComponentsInRange<FlammableComponent>(coordinates, radius))
|
||||
|
||||
39
Content.Server/Anomaly/Effects/TempAffectingAnomalySystem.cs
Normal file
39
Content.Server/Anomaly/Effects/TempAffectingAnomalySystem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// This handles <see cref="TempAffectingAnomalyComponent"/>
|
||||
/// </summary>
|
||||
public sealed class TempAffectingAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
|
||||
[Dependency] private readonly TransformSystem _xform = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<TempAffectingAnomalyComponent, AnomalyComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var ent, out var comp, out var anom, out var xform))
|
||||
{
|
||||
var grid = xform.GridUid;
|
||||
var map = xform.MapUid;
|
||||
var indices = _xform.GetGridOrMapTilePosition(ent, xform);
|
||||
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
|
||||
|
||||
if (mixture is { })
|
||||
{
|
||||
mixture.Temperature += comp.TempChangePerSecond * anom.Severity * frameTime;
|
||||
}
|
||||
|
||||
if (grid != null && anom.Severity > comp.AnomalyHotSpotThreshold)
|
||||
{
|
||||
_atmosphere.HotspotExpose(grid.Value, indices, comp.HotspotExposeTemperature, comp.HotspotExposeVolume, ent, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user