more component ref removal + combining server/client comps (#13178)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,92 +0,0 @@
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Server.Singularity.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Singularity.Components;
|
||||
|
||||
/// <summary>
|
||||
/// The server-side version of <see cref="SharedSingularityComponent">.
|
||||
/// Primarily managed by <see cref="SingularitySystem">.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedSingularityComponent))]
|
||||
public sealed class SingularityComponent : SharedSingularityComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of energy this singularity contains.
|
||||
/// If you want to set this go through <see cref="SingularitySystem.SetEnergy"/>
|
||||
/// </summary>
|
||||
[DataField("energy")]
|
||||
[Access(friends:typeof(SingularitySystem))]
|
||||
public float Energy = 180f;
|
||||
|
||||
/// <summary>
|
||||
/// The rate at which this singularity loses energy over time.
|
||||
/// </summary>
|
||||
[DataField("energyLoss")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float EnergyDrain;
|
||||
|
||||
#region Audio
|
||||
|
||||
/// <summary>
|
||||
/// The sound that this singularity produces by existing.
|
||||
/// </summary>
|
||||
[DataField("ambientSound")]
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public SoundSpecifier? AmbientSound = new SoundPathSpecifier(
|
||||
"/Audio/Effects/singularity_form.ogg",
|
||||
AudioParams.Default.WithVolume(5).WithLoop(true).WithMaxDistance(20f)
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// The audio stream that plays the sound specified by <see cref="AmbientSound"> on loop.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public IPlayingAudioStream? AmbientSoundStream = null;
|
||||
|
||||
/// <summary>
|
||||
/// The sound that the singularity produces when it forms.
|
||||
/// </summary>
|
||||
[DataField("formationSound")]
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public SoundSpecifier? FormationSound = null;
|
||||
|
||||
/// <summary>
|
||||
/// The sound that the singularity produces when it dissipates.
|
||||
/// </summary>
|
||||
[DataField("dissipationSound")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public SoundSpecifier? DissipationSound = new SoundPathSpecifier(
|
||||
"/Audio/Effects/singularity_collapse.ogg",
|
||||
AudioParams.Default
|
||||
);
|
||||
|
||||
#endregion Audio
|
||||
|
||||
#region Update Timing
|
||||
|
||||
/// <summary>
|
||||
/// The amount of time that should elapse between automated updates to this singularity.
|
||||
/// </summary>
|
||||
[DataField("updatePeriod")]
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SingularitySystem))]
|
||||
public TimeSpan TargetUpdatePeriod { get; internal set; } = TimeSpan.FromSeconds(1.0);
|
||||
|
||||
/// <summary>
|
||||
/// The next time this singularity should be updated by <see cref="SingularitySystem"/>
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SingularitySystem))]
|
||||
public TimeSpan NextUpdateTime { get; internal set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The last time this singularity was be updated by <see cref="SingularitySystem"/>
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[Access(typeof(SingularitySystem))]
|
||||
public TimeSpan LastUpdateTime { get; internal set; } = default!;
|
||||
|
||||
#endregion Update Timing
|
||||
}
|
||||
@@ -4,19 +4,18 @@ using Content.Server.Construction;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Projectiles;
|
||||
using Content.Server.Projectiles.Components;
|
||||
using Content.Server.Singularity.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
|
||||
@@ -14,9 +14,9 @@ using Content.Server.Singularity.Events;
|
||||
namespace Content.Server.Singularity.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// The server-side version of <seed cref="SharedSingularitySystem">.
|
||||
/// The server-side version of <see cref="SharedSingularitySystem"/>.
|
||||
/// Primarily responsible for managing <see cref="SingularityComponent"/>s.
|
||||
/// Handles their accumulation of energy upon consuming entities (see <see cref="EventHorizonComponent">) and gradual dissipation.
|
||||
/// Handles their accumulation of energy upon consuming entities (see <see cref="EventHorizonComponent"/>) and gradual dissipation.
|
||||
/// Also handles synchronizing server-side components with the singuarities level.
|
||||
/// </summary>
|
||||
public sealed class SingularitySystem : SharedSingularitySystem
|
||||
@@ -41,7 +41,6 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SingularityDistortionComponent, ComponentStartup>(OnDistortionStartup);
|
||||
SubscribeLocalEvent<SingularityComponent, ComponentStartup>(OnSingularityStartup);
|
||||
SubscribeLocalEvent<SingularityComponent, ComponentShutdown>(OnSingularityShutdown);
|
||||
SubscribeLocalEvent<SingularityComponent, EventHorizonConsumedEntityEvent>(OnConsumed);
|
||||
SubscribeLocalEvent<SinguloFoodComponent, EventHorizonConsumedEntityEvent>(OnConsumed);
|
||||
@@ -198,7 +197,7 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
/// <param name="uid">The entity UID of the singularity that is forming.</param>
|
||||
/// <param name="comp">The component of the singularity that is forming.</param>
|
||||
/// <param name="args">The event arguments.</param>
|
||||
public void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args)
|
||||
protected override void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args)
|
||||
{
|
||||
comp.LastUpdateTime = _timing.CurTime;
|
||||
comp.NextUpdateTime = comp.LastUpdateTime + comp.TargetUpdatePeriod;
|
||||
@@ -309,7 +308,8 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
/// <param name="args">The event arguments.</param>
|
||||
public void UpdateEnergyDrain(EntityUid uid, SingularityComponent comp, SingularityLevelChangedEvent args)
|
||||
{
|
||||
comp.EnergyDrain = args.NewValue switch {
|
||||
comp.EnergyDrain = args.NewValue switch
|
||||
{
|
||||
6 => 20,
|
||||
5 => 15,
|
||||
4 => 10,
|
||||
|
||||
Reference in New Issue
Block a user