Anomalies behaviours (#24683)
* Added new anomaly particle * Add basic anomaly behaviour * +2 parametres * add functional to new particle * add components to behaviours * big content * add shuffle, moved thing to server * clean up * fixes * random pick redo * bonjour behavioUr * fix AJCM * fix * add some new behaviours * power modifier behaviour * rmeove timer * new event for update ui fix * refactor! * fixes * enum * Fix mapinit * Minor touches --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Shared.Administration.Logs;
|
||||
@@ -33,7 +33,7 @@ public sealed class BluespaceAnomalySystem : EntitySystem
|
||||
{
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var xform = xformQuery.GetComponent(uid);
|
||||
var range = component.MaxShuffleRadius * args.Severity;
|
||||
var range = component.MaxShuffleRadius * args.Severity * args.PowerModifier;
|
||||
var mobs = new HashSet<Entity<MobStateComponent>>();
|
||||
_lookup.GetEntitiesInRange(xform.Coordinates, range, mobs);
|
||||
var allEnts = new ValueList<EntityUid>(mobs.Select(m => m.Owner)) { uid };
|
||||
@@ -56,7 +56,7 @@ public sealed class BluespaceAnomalySystem : EntitySystem
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var mapPos = _xform.GetWorldPosition(xform);
|
||||
var radius = component.SupercriticalTeleportRadius;
|
||||
var radius = component.SupercriticalTeleportRadius * args.PowerModifier;
|
||||
var gridBounds = new Box2(mapPos - new Vector2(radius, radius), mapPos + new Vector2(radius, radius));
|
||||
var mobs = new HashSet<Entity<MobStateComponent>>();
|
||||
_lookup.GetEntitiesInRange(xform.Coordinates, component.MaxShuffleRadius, mobs);
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed class ElectricityAnomalySystem : EntitySystem
|
||||
|
||||
private void OnPulse(Entity<ElectricityAnomalyComponent> anomaly, ref AnomalyPulseEvent args)
|
||||
{
|
||||
var range = anomaly.Comp.MaxElectrocuteRange * args.Stability;
|
||||
var range = anomaly.Comp.MaxElectrocuteRange * args.Stability * args.PowerModifier;
|
||||
|
||||
int boltCount = (int)MathF.Floor(MathHelper.Lerp((float)anomaly.Comp.MinBoltCount, (float)anomaly.Comp.MaxBoltCount, args.Severity));
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed class ElectricityAnomalySystem : EntitySystem
|
||||
|
||||
private void OnSupercritical(Entity<ElectricityAnomalyComponent> anomaly, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
var range = anomaly.Comp.MaxElectrocuteRange * 3;
|
||||
var range = anomaly.Comp.MaxElectrocuteRange * 3 * args.PowerModifier;
|
||||
|
||||
_emp.EmpPulse(_transform.GetMapCoordinates(anomaly), range, anomaly.Comp.EmpEnergyConsumption, anomaly.Comp.EmpDisabledDuration);
|
||||
_lightning.ShootRandomLightnings(anomaly, range, anomaly.Comp.MaxBoltCount * 3, arcDepth: 3);
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
|
||||
if (!entry.Settings.SpawnOnPulse)
|
||||
continue;
|
||||
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity);
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity, args.PowerModifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
|
||||
if (!entry.Settings.SpawnOnSuperCritical)
|
||||
continue;
|
||||
|
||||
SpawnEntities(component, entry, 1, 1);
|
||||
SpawnEntities(component, entry, 1, 1, args.PowerModifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
|
||||
if (!entry.Settings.SpawnOnShutdown || args.Supercritical)
|
||||
continue;
|
||||
|
||||
SpawnEntities(component, entry, 1, 1);
|
||||
SpawnEntities(component, entry, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
|
||||
if (!entry.Settings.SpawnOnStabilityChanged)
|
||||
continue;
|
||||
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity);
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,17 +79,17 @@ public sealed class EntityAnomalySystem : SharedEntityAnomalySystem
|
||||
if (!entry.Settings.SpawnOnSeverityChanged)
|
||||
continue;
|
||||
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity);
|
||||
SpawnEntities(component, entry, args.Stability, args.Severity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnEntities(Entity<EntitySpawnAnomalyComponent> anomaly, EntitySpawnSettingsEntry entry, float stability, float severity)
|
||||
private void SpawnEntities(Entity<EntitySpawnAnomalyComponent> anomaly, EntitySpawnSettingsEntry entry, float stability, float severity, float powerMod)
|
||||
{
|
||||
var xform = Transform(anomaly);
|
||||
if (!TryComp(xform.GridUid, out MapGridComponent? grid))
|
||||
return;
|
||||
|
||||
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings);
|
||||
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings, powerMod);
|
||||
if (tiles == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ public sealed class InjectionAnomalySystem : EntitySystem
|
||||
|
||||
private void OnPulse(Entity<InjectionAnomalyComponent> entity, ref AnomalyPulseEvent args)
|
||||
{
|
||||
PulseScalableEffect(entity, entity.Comp.InjectRadius, entity.Comp.MaxSolutionInjection * args.Severity);
|
||||
PulseScalableEffect(entity, entity.Comp.InjectRadius * args.PowerModifier, entity.Comp.MaxSolutionInjection * args.Severity * args.PowerModifier);
|
||||
}
|
||||
|
||||
private void OnSupercritical(Entity<InjectionAnomalyComponent> entity, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
PulseScalableEffect(entity, entity.Comp.SuperCriticalInjectRadius, entity.Comp.SuperCriticalSolutionInjection);
|
||||
PulseScalableEffect(entity, entity.Comp.SuperCriticalInjectRadius * args.PowerModifier, entity.Comp.SuperCriticalSolutionInjection * args.PowerModifier);
|
||||
}
|
||||
|
||||
private void PulseScalableEffect(Entity<InjectionAnomalyComponent> entity, float injectRadius, float maxInject)
|
||||
|
||||
@@ -31,12 +31,12 @@ public sealed class ProjectileAnomalySystem : EntitySystem
|
||||
|
||||
private void OnPulse(EntityUid uid, ProjectileAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
ShootProjectilesAtEntities(uid, component, args.Severity);
|
||||
ShootProjectilesAtEntities(uid, component, args.Severity * args.PowerModifier);
|
||||
}
|
||||
|
||||
private void OnSupercritical(EntityUid uid, ProjectileAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
ShootProjectilesAtEntities(uid, component, 1.0f);
|
||||
ShootProjectilesAtEntities(uid, component, args.PowerModifier);
|
||||
}
|
||||
|
||||
private void ShootProjectilesAtEntities(EntityUid uid, ProjectileAnomalyComponent component, float severity)
|
||||
|
||||
@@ -25,9 +25,10 @@ public sealed class PuddleCreateAnomalySystem : EntitySystem
|
||||
return;
|
||||
|
||||
var xform = Transform(entity.Owner);
|
||||
var puddleSol = _solutionContainer.SplitSolution(sol.Value, entity.Comp.MaxPuddleSize * args.Severity);
|
||||
var puddleSol = _solutionContainer.SplitSolution(sol.Value, entity.Comp.MaxPuddleSize * args.Severity * args.PowerModifier);
|
||||
_puddle.TrySplashSpillAt(entity.Owner, xform.Coordinates, puddleSol, out _);
|
||||
}
|
||||
|
||||
private void OnSupercritical(Entity<PuddleCreateAnomalyComponent> entity, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var sol))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Effects.Components;
|
||||
@@ -24,14 +24,14 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
|
||||
private void OnPulse(EntityUid uid, PyroclasticAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
var ignitionRadius = component.MaximumIgnitionRadius * args.Stability;
|
||||
var ignitionRadius = component.MaximumIgnitionRadius * args.Stability * args.PowerModifier;
|
||||
IgniteNearby(uid, xform.Coordinates, args.Severity, ignitionRadius);
|
||||
}
|
||||
|
||||
private void OnSupercritical(EntityUid uid, PyroclasticAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
IgniteNearby(uid, xform.Coordinates, 1, component.MaximumIgnitionRadius * 2);
|
||||
IgniteNearby(uid, xform.Coordinates, 1, component.MaximumIgnitionRadius * 2 * args.PowerModifier);
|
||||
}
|
||||
|
||||
public void IgniteNearby(EntityUid uid, EntityCoordinates coordinates, float severity, float radius)
|
||||
|
||||
40
Content.Server/Anomaly/Effects/SecretDataAnomalySystem.cs
Normal file
40
Content.Server/Anomaly/Effects/SecretDataAnomalySystem.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
public sealed class SecretDataAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private readonly List<AnomalySecretData> _deita = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<SecretDataAnomalyComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, SecretDataAnomalyComponent anomaly, MapInitEvent args)
|
||||
{
|
||||
RandomizeSecret(uid,_random.Next(anomaly.RandomStartSecretMin, anomaly.RandomStartSecretMax), anomaly);
|
||||
}
|
||||
|
||||
public void RandomizeSecret(EntityUid uid, int count, SecretDataAnomalyComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.Secret.Clear();
|
||||
|
||||
// I also considered just adding all the enum values and pruning but that seems more wasteful.
|
||||
_deita.Clear();
|
||||
_deita.AddRange(Enum.GetValues<AnomalySecretData>());
|
||||
var actualCount = Math.Min(count, _deita.Count);
|
||||
|
||||
for (int i = 0; i < actualCount; i++)
|
||||
{
|
||||
component.Secret.Add(_random.PickAndTake(_deita));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
public sealed class ShuffleParticlesAnomalySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AnomalySystem _anomaly = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<ShuffleParticlesAnomalyComponent, AnomalyPulseEvent>(OnPulse);
|
||||
SubscribeLocalEvent<ShuffleParticlesAnomalyComponent, StartCollideEvent>(OnStartCollide);
|
||||
}
|
||||
|
||||
private void OnStartCollide(EntityUid uid, ShuffleParticlesAnomalyComponent shuffle, StartCollideEvent args)
|
||||
{
|
||||
if (!TryComp<AnomalyComponent>(uid, out var anomaly))
|
||||
return;
|
||||
|
||||
if (shuffle.ShuffleOnParticleHit && _random.Prob(shuffle.Prob))
|
||||
_anomaly.ShuffleParticlesEffect(anomaly);
|
||||
|
||||
if (!TryComp<AnomalousParticleComponent>(args.OtherEntity, out var particle))
|
||||
return;
|
||||
}
|
||||
|
||||
private void OnPulse(EntityUid uid, ShuffleParticlesAnomalyComponent shuffle, AnomalyPulseEvent args)
|
||||
{
|
||||
if (!TryComp<AnomalyComponent>(uid, out var anomaly))
|
||||
return;
|
||||
|
||||
if (shuffle.ShuffleOnPulse && _random.Prob(shuffle.Prob))
|
||||
{
|
||||
_anomaly.ShuffleParticlesEffect(anomaly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public sealed class TileAnomalySystem : SharedTileAnomalySystem
|
||||
if (!entry.Settings.SpawnOnPulse)
|
||||
continue;
|
||||
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity);
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity, args.PowerModifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public sealed class TileAnomalySystem : SharedTileAnomalySystem
|
||||
if (!entry.Settings.SpawnOnSuperCritical)
|
||||
continue;
|
||||
|
||||
SpawnTiles(component, entry, 1, 1);
|
||||
SpawnTiles(component, entry, 1, 1, args.PowerModifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public sealed class TileAnomalySystem : SharedTileAnomalySystem
|
||||
if (!entry.Settings.SpawnOnShutdown || args.Supercritical)
|
||||
continue;
|
||||
|
||||
SpawnTiles(component, entry, 1, 1);
|
||||
SpawnTiles(component, entry, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public sealed class TileAnomalySystem : SharedTileAnomalySystem
|
||||
if (!entry.Settings.SpawnOnStabilityChanged)
|
||||
continue;
|
||||
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity);
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,17 +78,17 @@ public sealed class TileAnomalySystem : SharedTileAnomalySystem
|
||||
if (!entry.Settings.SpawnOnSeverityChanged)
|
||||
continue;
|
||||
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity);
|
||||
SpawnTiles(component, entry, args.Stability, args.Severity, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnTiles(Entity<TileSpawnAnomalyComponent> anomaly, TileSpawnSettingsEntry entry, float stability, float severity)
|
||||
private void SpawnTiles(Entity<TileSpawnAnomalyComponent> anomaly, TileSpawnSettingsEntry entry, float stability, float severity, float powerMod)
|
||||
{
|
||||
var xform = Transform(anomaly);
|
||||
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings);
|
||||
var tiles = _anomaly.GetSpawningPoints(anomaly, stability, severity, entry.Settings, powerMod);
|
||||
if (tiles == null)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user