Ice anomaly spawns ice underneath it (#21227)

* added TileAnomalySystem to AnomalyIce

* added FloorIce for station

* created ice crust entity to spawn under ice anomaly

* update draw depth for ice crust

* uh oh, added ice-sliding but at what cost

* resolved mispredicts

* updated sprite alpha, removed appearance component (not used)

* fixed function not reflecting event name, left datafield attributes blank, added one comment about saving data (?)

---------

Co-authored-by: Yurii Kis <yurii.kis@smartteksas.com>
This commit is contained in:
KISS
2023-11-06 04:41:42 +02:00
committed by GitHub
parent b1f39ad2ad
commit 4cacb7b9e3
10 changed files with 261 additions and 16 deletions

View File

@@ -21,27 +21,46 @@ public sealed class EntityAnomalySystem : EntitySystem
{
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyPulseEvent>(OnPulse);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
SubscribeLocalEvent<EntitySpawnAnomalyComponent, AnomalyStabilityChangedEvent>(OnStabilityChanged);
}
private void OnPulse(EntityUid uid, EntitySpawnAnomalyComponent component, ref AnomalyPulseEvent args)
{
if (!component.SpawnOnPulse)
return;
var range = component.SpawnRange * args.Stability;
var amount = (int) (component.MaxSpawnAmount * args.Severity + 0.5f);
var xform = Transform(uid);
SpawnMonstersOnOpenTiles(component, xform, amount, range, component.Spawns);
SpawnEntitesOnOpenTiles(component, xform, amount, range, component.Spawns);
}
private void OnSupercritical(EntityUid uid, EntitySpawnAnomalyComponent component, ref AnomalySupercriticalEvent args)
{
if (!component.SpawnOnSuperCritical)
return;
var xform = Transform(uid);
// A cluster of monsters
SpawnMonstersOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange, component.Spawns);
// A cluster of entities
SpawnEntitesOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange, component.Spawns);
// And so much meat (for the meat anomaly at least)
SpawnMonstersOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange, component.SuperCriticalSpawns);
SpawnEntitesOnOpenTiles(component, xform, component.MaxSpawnAmount, component.SpawnRange, component.SuperCriticalSpawns);
}
private void SpawnMonstersOnOpenTiles(EntitySpawnAnomalyComponent component, TransformComponent xform, int amount, float radius, List<EntProtoId> spawns)
private void OnStabilityChanged(EntityUid uid, EntitySpawnAnomalyComponent component, ref AnomalyStabilityChangedEvent args)
{
if (!component.SpawnOnStabilityChanged)
return;
var range = component.SpawnRange * args.Stability;
var amount = (int) (component.MaxSpawnAmount * args.Stability + 0.5f);
var xform = Transform(uid);
SpawnEntitesOnOpenTiles(component, xform, amount, range, component.Spawns);
}
private void SpawnEntitesOnOpenTiles(EntitySpawnAnomalyComponent component, TransformComponent xform, int amount, float radius, List<EntProtoId> spawns)
{
if (!component.Spawns.Any())
return;