namespace Content.Server.Anomaly.Effects;
-public sealed class FleshAnomalySystem : EntitySystem
+public sealed class EntityAnomalySystem : EntitySystem
{
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IRobustRandom _random = default!;
/// <inheritdoc/>
public override void Initialize()
{
- SubscribeLocalEvent<FleshAnomalyComponent, AnomalyPulseEvent>(OnPulse);
- SubscribeLocalEvent<FleshAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
- SubscribeLocalEvent<FleshAnomalyComponent, AnomalyStabilityChangedEvent>(OnSeverityChanged);
+ SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
+ SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
}
- private void OnPulse(EntityUid uid, FleshAnomalyComponent component, ref AnomalyPulseEvent args)
+ private void OnPulse(EntityUid uid, EntitySpawnAnomalyComponent component, ref AnomalyPulseEvent args)
{
var range = component.SpawnRange * args.Stability;
var amount = (int) (component.MaxSpawnAmount * args.Severity + 0.5f);
SpawnMonstersOnOpenTiles(component, xform, amount, range);
}
- private void OnSupercritical(EntityUid uid, FleshAnomalyComponent component, ref AnomalySupercriticalEvent args)
+ private void OnSupercritical(EntityUid uid, EntitySpawnAnomalyComponent component, ref AnomalySupercriticalEvent args)
{
var xform = Transform(uid);
SpawnMonstersOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange);
Spawn(component.SupercriticalSpawn, xform.Coordinates);
}
- private void OnSeverityChanged(EntityUid uid, FleshAnomalyComponent component, ref AnomalyStabilityChangedEvent args)
- {
- var xform = Transform(uid);
- if (!_map.TryGetGrid(xform.GridUid, out var grid))
- return;
-
- var radius = component.SpawnRange * args.Stability;
- var fleshTile = (ContentTileDefinition) _tiledef[component.FleshTileId];
- var localpos = xform.Coordinates.Position;
- var tilerefs = grid.GetLocalTilesIntersecting(
- new Box2(localpos + (-radius, -radius), localpos + (radius, radius)));
- foreach (var tileref in tilerefs)
- {
- if (!_random.Prob(0.33f))
- continue;
- _tile.ReplaceTile(tileref, fleshTile);
- }
- }
-
- private void SpawnMonstersOnOpenTiles(FleshAnomalyComponent component, TransformComponent xform, int amount, float radius)
+ private void SpawnMonstersOnOpenTiles(EntitySpawnAnomalyComponent component, TransformComponent xform, int amount, float radius)
{
if (!component.Spawns.Any())
return;
--- /dev/null
+using System.Linq;
+using Content.Server.Maps;
+using Content.Shared.Anomaly.Components;
+using Content.Shared.Anomaly.Effects.Components;
+using Content.Shared.Maps;
+using Content.Shared.Physics;
+using Robust.Shared.Map;
+using Robust.Shared.Physics;
+using Robust.Shared.Physics.Components;
+using Robust.Shared.Random;
+
+namespace Content.Server.Anomaly.Effects;
+
+public sealed class TileAnomalySystem : EntitySystem
+{
+ [Dependency] private readonly IMapManager _map = default!;
+ [Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly ITileDefinitionManager _tiledef = default!;
+ [Dependency] private readonly TileSystem _tile = default!;
+
+ /// <inheritdoc/>
+ public override void Initialize()
+ {
+ SubscribeLocalEvent<TileSpawnAnomalyComponent, AnomalyStabilityChangedEvent>(OnSeverityChanged);
+ }
+
+ private void OnSeverityChanged(EntityUid uid, TileSpawnAnomalyComponent component, ref AnomalyStabilityChangedEvent args)
+ {
+ var xform = Transform(uid);
+ if (!_map.TryGetGrid(xform.GridUid, out var grid))
+ return;
+
+ var radius = component.SpawnRange * args.Stability;
+ var fleshTile = (ContentTileDefinition) _tiledef[component.FloorTileId];
+ var localpos = xform.Coordinates.Position;
+ var tilerefs = grid.GetLocalTilesIntersecting(
+ new Box2(localpos + (-radius, -radius), localpos + (radius, radius)));
+ foreach (var tileref in tilerefs)
+ {
+ if (!_random.Prob(0.33f))
+ continue;
+ _tile.ReplaceTile(tileref, fleshTile);
+ }
+ }
+}
namespace Content.Shared.Anomaly.Effects.Components;
[RegisterComponent]
-public sealed class FleshAnomalyComponent : Component
+public sealed class EntitySpawnAnomalyComponent : Component
{
/// <summary>
/// A list of entities that are random picked to be spawned on each pulse
/// <summary>
/// The tile that is spawned by the anomaly's effect
/// </summary>
- [DataField("fleshTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
- public string FleshTileId = "FloorFlesh";
+ [DataField("floorTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
+ public string FloorTileId = "FloorFlesh";
/// <summary>
/// The entity spawned when the anomaly goes supercritical
--- /dev/null
+using Content.Shared.Maps;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
+
+namespace Content.Shared.Anomaly.Effects.Components;
+
+[RegisterComponent]
+public sealed class TileSpawnAnomalyComponent : Component
+{
+ /// <summary>
+ /// The maximum radius of tiles scales with stability
+ /// </summary>
+ [DataField("spawnRange"), ViewVariables(VVAccess.ReadWrite)]
+ public float SpawnRange = 5f;
+
+ /// <summary>
+ /// The tile that is spawned by the anomaly's effect
+ /// </summary>
+ [DataField("floorTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
+ public string FloorTileId = "FloorFlesh";
+}
energy: 7.5
color: "#cb5b7e"
castShadows: false
- - type: FleshAnomaly
+ - type: TileSpawnAnomaly
+ floorTileId: FloorFlesh
+ - type: EntitySpawnAnomaly
+ superCriticalSpawn: FleshKudzu
spawns:
- MobFleshJared
- MobFleshGolem