Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ using Robust.Shared.Random;
|
|||||||
|
|
||||||
namespace Content.Server.Anomaly.Effects;
|
namespace Content.Server.Anomaly.Effects;
|
||||||
|
|
||||||
public sealed class FleshAnomalySystem : EntitySystem
|
public sealed class EntityAnomalySystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _map = default!;
|
[Dependency] private readonly IMapManager _map = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
@@ -21,12 +21,11 @@ public sealed class FleshAnomalySystem : EntitySystem
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<FleshAnomalyComponent, AnomalyPulseEvent>(OnPulse);
|
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
|
||||||
SubscribeLocalEvent<FleshAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
|
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
|
||||||
SubscribeLocalEvent<FleshAnomalyComponent, AnomalyStabilityChangedEvent>(OnSeverityChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 range = component.SpawnRange * args.Stability;
|
||||||
var amount = (int) (component.MaxSpawnAmount * args.Severity + 0.5f);
|
var amount = (int) (component.MaxSpawnAmount * args.Severity + 0.5f);
|
||||||
@@ -35,33 +34,14 @@ public sealed class FleshAnomalySystem : EntitySystem
|
|||||||
SpawnMonstersOnOpenTiles(component, xform, amount, range);
|
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);
|
var xform = Transform(uid);
|
||||||
SpawnMonstersOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange);
|
SpawnMonstersOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange);
|
||||||
Spawn(component.SupercriticalSpawn, xform.Coordinates);
|
Spawn(component.SupercriticalSpawn, xform.Coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSeverityChanged(EntityUid uid, FleshAnomalyComponent component, ref AnomalyStabilityChangedEvent args)
|
private void SpawnMonstersOnOpenTiles(EntitySpawnAnomalyComponent component, TransformComponent xform, int amount, float radius)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (!component.Spawns.Any())
|
if (!component.Spawns.Any())
|
||||||
return;
|
return;
|
||||||
45
Content.Server/Anomaly/Effects/TileAnomalySystem.cs
Normal file
45
Content.Server/Anomaly/Effects/TileAnomalySystem.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
|||||||
namespace Content.Shared.Anomaly.Effects.Components;
|
namespace Content.Shared.Anomaly.Effects.Components;
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class FleshAnomalyComponent : Component
|
public sealed class EntitySpawnAnomalyComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of entities that are random picked to be spawned on each pulse
|
/// A list of entities that are random picked to be spawned on each pulse
|
||||||
@@ -32,8 +32,8 @@ public sealed class FleshAnomalyComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The tile that is spawned by the anomaly's effect
|
/// The tile that is spawned by the anomaly's effect
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("fleshTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
|
[DataField("floorTileId", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>)), ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string FleshTileId = "FloorFlesh";
|
public string FloorTileId = "FloorFlesh";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The entity spawned when the anomaly goes supercritical
|
/// The entity spawned when the anomaly goes supercritical
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
@@ -131,7 +131,10 @@
|
|||||||
energy: 7.5
|
energy: 7.5
|
||||||
color: "#cb5b7e"
|
color: "#cb5b7e"
|
||||||
castShadows: false
|
castShadows: false
|
||||||
- type: FleshAnomaly
|
- type: TileSpawnAnomaly
|
||||||
|
floorTileId: FloorFlesh
|
||||||
|
- type: EntitySpawnAnomaly
|
||||||
|
superCriticalSpawn: FleshKudzu
|
||||||
spawns:
|
spawns:
|
||||||
- MobFleshJared
|
- MobFleshJared
|
||||||
- MobFleshGolem
|
- MobFleshGolem
|
||||||
|
|||||||
Reference in New Issue
Block a user