Nemanja
2023-01-17 19:38:12 -05:00
committed by GitHub
parent 2c1c1c45c3
commit 4d57226335
11 changed files with 28 additions and 25 deletions

View File

@@ -25,7 +25,7 @@ public sealed class AnomalySystem : SharedAnomalySystem
if (!Appearance.TryGetData(uid, AnomalyVisuals.IsPulsing, out bool pulsing, args.Component)) if (!Appearance.TryGetData(uid, AnomalyVisuals.IsPulsing, out bool pulsing, args.Component))
pulsing = false; pulsing = false;
if (Appearance.TryGetData(uid, AnomalyVisuals.IsPulsing, out bool super, args.Component) && super) if (Appearance.TryGetData(uid, AnomalyVisuals.Supercritical, out bool super, args.Component) && super)
pulsing = super; pulsing = super;
if (HasComp<AnomalySupercriticalComponent>(uid)) if (HasComp<AnomalySupercriticalComponent>(uid))

View File

@@ -2,6 +2,7 @@
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems; using Content.Server.Power.EntitySystems;
using Content.Shared.Anomaly; using Content.Shared.Anomaly;
using Content.Shared.CCVar;
using Content.Shared.Materials; using Content.Shared.Materials;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
@@ -14,15 +15,6 @@ namespace Content.Server.Anomaly;
/// </summary> /// </summary>
public sealed partial class AnomalySystem public sealed partial class AnomalySystem
{ {
/// <summary>
/// A multiplier applied to the grid bounds
/// to make the likelihood of it spawning outside
/// of the main station less likely.
///
/// tl;dr anomalies only generate on the inner __% of the station.
/// </summary>
public const float GridBoundsMultiplier = 0.6f;
private void InitializeGenerator() private void InitializeGenerator()
{ {
SubscribeLocalEvent<AnomalyGeneratorComponent, BoundUIOpenedEvent>(OnGeneratorBUIOpened); SubscribeLocalEvent<AnomalyGeneratorComponent, BoundUIOpenedEvent>(OnGeneratorBUIOpened);
@@ -90,16 +82,16 @@ public sealed partial class AnomalySystem
var xform = Transform(grid); var xform = Transform(grid);
var targetCoords = xform.Coordinates; var targetCoords = xform.Coordinates;
var (gridPos, _, gridMatrix) = _transform.GetWorldPositionRotationMatrix(xform); var gridBounds = gridComp.LocalAABB;
var gridBounds = gridMatrix.TransformBox(gridComp.LocalAABB); gridBounds.Scale(_configuration.GetCVar(CCVars.AnomalyGenerationGridBoundsScale));
for (var i = 0; i < 25; i++) for (var i = 0; i < 25; i++)
{ {
var randomX = Random.Next((int) (gridBounds.Left * GridBoundsMultiplier), (int) (gridBounds.Right * GridBoundsMultiplier)); var randomX = Random.Next((int) gridBounds.Left, (int) gridBounds.Right);
var randomY = Random.Next((int) (gridBounds.Bottom * GridBoundsMultiplier), (int) (gridBounds.Top * GridBoundsMultiplier)); var randomY = Random.Next((int) gridBounds.Bottom, (int)gridBounds.Top);
var tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y); var tile = new Vector2i(randomX, randomY);
if (_atmosphere.IsTileSpace(grid, Transform(grid).MapUid, tile, if (_atmosphere.IsTileSpace(grid, xform.MapUid, tile,
mapGridComp: gridComp) || _atmosphere.IsTileAirBlocked(grid, tile, mapGridComp: gridComp)) mapGridComp: gridComp) || _atmosphere.IsTileAirBlocked(grid, tile, mapGridComp: gridComp))
{ {
continue; continue;

View File

@@ -63,7 +63,7 @@ public sealed partial class AnomalySystem
{ {
if (component.Anomaly != null || if (component.Anomaly != null ||
!TryComp<AnomalyScannerComponent>(args.Used, out var scanner) || !TryComp<AnomalyScannerComponent>(args.Used, out var scanner) ||
scanner.ScannedAnomaly is not {} anomaly) scanner.ScannedAnomaly is not { } anomaly)
{ {
return; return;
} }

View File

@@ -8,6 +8,7 @@ using Content.Server.Popups;
using Content.Shared.Anomaly; using Content.Shared.Anomaly;
using Content.Shared.Anomaly.Components; using Content.Shared.Anomaly.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Anomaly; namespace Content.Server.Anomaly;
@@ -17,6 +18,7 @@ namespace Content.Server.Anomaly;
/// </summary> /// </summary>
public sealed partial class AnomalySystem : SharedAnomalySystem public sealed partial class AnomalySystem : SharedAnomalySystem
{ {
[Dependency] private readonly IConfigurationManager _configuration = default!;
[Dependency] private readonly AmbientSoundSystem _ambient = default!; [Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!; [Dependency] private readonly DoAfterSystem _doAfter = default!;

View File

@@ -136,7 +136,7 @@ namespace Content.Server.Singularity.EntitySystems
if (component.SelectableTypes.Count < 2) if (component.SelectableTypes.Count < 2)
return; return;
var proto = _prototype.Index<EntityPrototype>(component.BoltType); var proto = _prototype.Index<EntityPrototype>(component.BoltType);
args.Message.AddText(Loc.GetString("emitter-component-current-type", ("type", proto.Name))); args.PushMarkup(Loc.GetString("emitter-component-current-type", ("type", proto.Name)));
} }
private void ReceivedChanged( private void ReceivedChanged(

View File

@@ -179,7 +179,7 @@ public sealed class AnomalyComponent : Component
/// of an anomalous particle of <seealso cref="DestabilizingParticleType"/>. /// of an anomalous particle of <seealso cref="DestabilizingParticleType"/>.
/// </summary> /// </summary>
[DataField("stabilityPerWeakeningeHit")] [DataField("stabilityPerWeakeningeHit")]
public float StabilityPerWeakeningeHit = -0.02f; public float StabilityPerWeakeningeHit = -0.1f;
#region Points and Vessels #region Points and Vessels
/// <summary> /// <summary>

View File

@@ -1,8 +1,6 @@
using System.Linq; using System.Linq;
using Content.Shared.Anomaly.Components; using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects.Components; using Content.Shared.Anomaly.Effects.Components;
using Content.Shared.Construction.Components;
using Content.Shared.Construction.EntitySystems;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Robust.Shared.Map; using Robust.Shared.Map;
@@ -12,7 +10,6 @@ public abstract class SharedGravityAnomalySystem : EntitySystem
{ {
[Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedAnchorableSystem _anchorable = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!; [Dependency] private readonly SharedTransformSystem _xform = default!;

View File

@@ -91,6 +91,7 @@ public abstract class SharedAnomalySystem : EntitySystem
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
DebugTools.Assert(component.MinPulseLength > TimeSpan.FromSeconds(3)); // this is just to prevent lagspikes mispredicting pulses
var variation = Random.NextFloat(-component.PulseVariation, component.PulseVariation) + 1; var variation = Random.NextFloat(-component.PulseVariation, component.PulseVariation) + 1;
component.NextPulseTime = Timing.CurTime + GetPulseLength(component) * variation; component.NextPulseTime = Timing.CurTime + GetPulseLength(component) * variation;
@@ -107,7 +108,8 @@ public abstract class SharedAnomalySystem : EntitySystem
} }
Log.Add(LogType.Anomaly, LogImpact.Medium, $"Anomaly {ToPrettyString(uid)} pulsed with severity {component.Severity}."); Log.Add(LogType.Anomaly, LogImpact.Medium, $"Anomaly {ToPrettyString(uid)} pulsed with severity {component.Severity}.");
Audio.PlayPvs(component.PulseSound, uid); if (_net.IsServer)
Audio.PlayPvs(component.PulseSound, uid);
var pulse = EnsureComp<AnomalyPulsingComponent>(uid); var pulse = EnsureComp<AnomalyPulsingComponent>(uid);
pulse.EndTime = Timing.CurTime + pulse.PulseDuration; pulse.EndTime = Timing.CurTime + pulse.PulseDuration;

View File

@@ -1135,6 +1135,16 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> BiomassEasyMode = public static readonly CVarDef<bool> BiomassEasyMode =
CVarDef.Create("biomass.easy_mode", true, CVar.SERVERONLY); CVarDef.Create("biomass.easy_mode", true, CVar.SERVERONLY);
/*
* Anomaly
*/
/// <summary>
/// A scale factor applied to a grid's bounds when trying to find a spot to randomly generate an anomaly.
/// </summary>
public static readonly CVarDef<float> AnomalyGenerationGridBoundsScale =
CVarDef.Create("anomaly.generation_grid_bounds_scale", 0.6f, CVar.SERVERONLY);
/* /*
* VIEWPORT * VIEWPORT
*/ */

View File

@@ -159,7 +159,7 @@
id: MachineAnomalyGenerator id: MachineAnomalyGenerator
parent: BaseMachinePowered parent: BaseMachinePowered
name: anomaly generator name: anomaly generator
description: The peak of psuedoscientific technology. description: The peak of pseudoscientific technology.
placement: placement:
mode: AlignTileAny mode: AlignTileAny
components: components:

View File

@@ -2,7 +2,7 @@
abstract: true abstract: true
id: BaseAnomaly id: BaseAnomaly
name: anomaly name: anomaly
description: A impossible object in space. Should you be standing this close to it? description: An impossible object. Should you be standing this close to it?
components: components:
- type: Anomaly - type: Anomaly
pulseSound: pulseSound: