Skip to content

Commit

Permalink
organizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Void-Crew2@gm committed Apr 16, 2023
1 parent 971a6ef commit 1356470
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Content.Server.ATLAS.Supermatter.Components
{

[RegisterComponent]
[Access(typeof(SupermatterSystem))]
public sealed class SupermatterComponent : Component
{
#region SM Base
Expand Down Expand Up @@ -49,30 +49,29 @@ public sealed class SupermatterComponent : Component
[DataField("heatThreshold")]
public float HeatThreshold = 2500f;

#endregion SM Base

#region SM Sound
/// <summary>
/// Current stream of SM audio.
/// </summary>
public IPlayingAudioStream? Stream;

public SupermatterSystem.SuperMatterSound? SmSound;

[ViewVariables(VVAccess.ReadOnly)]
[DataField("calmSound")]
public SoundSpecifier CalmSound = new SoundPathSpecifier("/Audio/ATLAS/Supermatter/calm.ogg");
public SoundSpecifier CalmSound { get; set; } = new SoundPathSpecifier("/Audio/ATLAS/Supermatter/calm.ogg");

[ViewVariables(VVAccess.ReadOnly)]
[DataField("dustSound")]
public SoundSpecifier DustSound = new SoundPathSpecifier("/Audio/ATLAS/Supermatter/dust.ogg");
public SoundSpecifier DustSound { get; set; } = new SoundPathSpecifier("/Audio/ATLAS/Supermatter/dust.ogg");

[ViewVariables(VVAccess.ReadOnly)]
[DataField("delamSound")]
public SoundSpecifier DelamSound = new SoundPathSpecifier("/Audio/Machines/Supermatter/delamming.ogg");
public SoundSpecifier DelamSound { get; set; } = new SoundPathSpecifier("/Audio/ATLAS/Supermatter/delamming.ogg");

[ViewVariables(VVAccess.ReadOnly)]
[DataField("delamAlarm")]
public SoundSpecifier DelamAlarm = new SoundPathSpecifier("/Audio/Machines/alarm.ogg");
public SoundSpecifier DelamAlarm { get; set; } = new SoundPathSpecifier("/Audio/Machines/alarm.ogg");

#endregion SM Base
#endregion SM Sound

#region SM Calculation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;
using Robust.Server.GameObjects;
using Content.Shared.Atmos;
using Content.Shared.Damage;
Expand Down Expand Up @@ -35,6 +36,7 @@ public sealed class SupermatterSystem : EntitySystem
[Dependency] private readonly ExplosionSystem _explosion = default!;
[Dependency] private readonly TransformSystem _xform = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

public enum DelamType : sbyte
{
Expand All @@ -61,6 +63,9 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

if (!_gameTiming.IsFirstTimePredicted)
return;

foreach (var (supermatter, damageable, xplode,rads) in EntityManager.EntityQuery<SupermatterComponent, DamageableComponent, ExplosiveComponent, RadiationSourceComponent>())
{
HandleOutput(supermatter.Owner, frameTime, supermatter, rads);
Expand All @@ -79,6 +84,7 @@ private void HandleOutput(EntityUid uid, float frameTime, SupermatterComponent?
}

sMcomponent.AtmosUpdateAccumulator += frameTime;

if (!(sMcomponent.AtmosUpdateAccumulator > sMcomponent.AtmosUpdateTimer) ||
_atmosphere.GetContainingMixture(uid, true, true) is not { } mixture)
return;
Expand Down Expand Up @@ -372,7 +378,7 @@ private void Delamination(EntityUid uid, float frameTime, float damageArchived,
if (sMcomponent.FinalCountdown && sMcomponent.SmSound != SuperMatterSound.Delam)
{
sMcomponent.Stream?.Stop();
sMcomponent.Stream = _audio.Play(sound, Filter.Pvs(uid, 5), uid, false, param);
sMcomponent.Stream = _audio.PlayPvs(sound,uid,param);
sMcomponent.SmSound = SuperMatterSound.Delam;
}

Expand Down Expand Up @@ -414,7 +420,7 @@ private void HandleSoundLoop(EntityUid uid, SupermatterComponent sMcomponent,Dam
var sounds = isAggressive ? sMcomponent.DelamSound : sMcomponent.CalmSound;
var sound = _audio.GetSound(sounds);
var param = sounds.Params.WithLoop(true).WithVolume(5f).WithMaxDistance(20f);
sMcomponent.Stream = _audio.Play(sound, Filter.Pvs(uid), uid, false, param);
sMcomponent.Stream = _audio.PlayPvs(sound,uid,param);
sMcomponent.SmSound = smSound;
}

Expand Down Expand Up @@ -453,7 +459,7 @@ private void OnCollideEvent(EntityUid uid, SupermatterComponent supermatter, ref
if (!EntityManager.HasComponent<ProjectileComponent>(target))
{
EntityManager.SpawnEntity("Ash", Transform(target).Coordinates);
_audio.Play(supermatter.DustSound, Filter.Pvs(uid), uid, false);
_audio.PlayPvs(supermatter.DustSound,uid);
}

EntityManager.QueueDeleteEntity(target);
Expand All @@ -464,7 +470,7 @@ private void OnHandInteract(EntityUid uid, SupermatterComponent supermatter, Int
var target = args.User;
supermatter.MatterPower += 200;
EntityManager.SpawnEntity("Ash", Transform(target).Coordinates);
_audio.Play(supermatter.DustSound, Filter.Pvs(uid), uid, false);
_audio.PlayPvs(supermatter.DustSound,uid);
EntityManager.QueueDeleteEntity(target);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
- type: InteractionOutline
- type: Sprite
drawdepth: WallMountedItems
sprite: ATLAS/supermatter.rsi
sprite: ATLAS/Supermatter/supermatter.rsi
state: supermatter
- type: Icon
sprite: ATLAS/supermatter.rsi
sprite: ATLAS/Supermatter/supermatter.rsi
state: supermatter
- type: PointLight
enabled: true
Expand Down

0 comments on commit 1356470

Please sign in to comment.