Fixes for the recycler and related things (#12703)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Mervill
2022-11-25 01:00:41 -08:00
committed by GitHub
parent 11f9284bae
commit 5ae838a6a3
8 changed files with 49 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Body.Systems;
using Content.Server.GameTicking;
using Content.Server.Players;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Recycling.Components;
using Content.Shared.Audio;
@@ -29,6 +30,10 @@ namespace Content.Server.Recycling
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly TagSystem _tags = default!;
[Dependency] private readonly AudioSystem _soundSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
private const string RecyclerColliderName = "brrt";
private const float RecyclerSoundCooldown = 0.8f;
@@ -38,6 +43,7 @@ namespace Content.Server.Recycling
SubscribeLocalEvent<RecyclerComponent, StartCollideEvent>(OnCollide);
SubscribeLocalEvent<RecyclerComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<RecyclerComponent, SuicideEvent>(OnSuicide);
SubscribeLocalEvent<RecyclerComponent, PowerChangedEvent>(OnPowerChanged);
}
private void OnExamined(EntityUid uid, RecyclerComponent component, ExaminedEvent args)
@@ -77,7 +83,16 @@ namespace Content.Server.Recycling
if (component.Enabled) return;
component.Enabled = true;
_ambience.SetAmbience(component.Owner, true);
if (TryComp(component.Owner, out ApcPowerReceiverComponent? apcPower))
{
_ambience.SetAmbience(component.Owner, apcPower.Powered);
}
else
{
_ambience.SetAmbience(component.Owner, true);
}
}
public void DisableRecycler(RecyclerComponent component)
@@ -88,9 +103,24 @@ namespace Content.Server.Recycling
_ambience.SetAmbience(component.Owner, false);
}
private void OnPowerChanged(EntityUid uid, RecyclerComponent component, ref PowerChangedEvent args)
{
if (component.Enabled)
{
_ambience.SetAmbience(uid, args.Powered);
}
}
private void OnCollide(EntityUid uid, RecyclerComponent component, ref StartCollideEvent args)
{
if (component.Enabled && args.OurFixture.ID != "brrt") return;
if (component.Enabled && args.OurFixture.ID != RecyclerColliderName)
return;
if (TryComp(uid, out ApcPowerReceiverComponent? apcPower))
{
if (!apcPower.Powered)
return;
}
Recycle(component, args.OtherFixture.Body.Owner);
}
@@ -123,7 +153,7 @@ namespace Content.Server.Recycling
if (component.Sound != null && (_timing.CurTime - component.LastSound).TotalSeconds > RecyclerSoundCooldown)
{
SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, AudioHelpers.WithVariation(0.01f).WithVolume(-3));
_soundSystem.PlayPvs(component.Sound, component.Owner, AudioHelpers.WithVariation(0.01f).WithVolume(-3));
component.LastSound = _timing.CurTime;
}
@@ -140,7 +170,7 @@ namespace Content.Server.Recycling
{
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance))
{
appearance.SetData(RecyclerVisuals.Bloody, true);
_appearanceSystem.SetData(component.Owner, RecyclerVisuals.Bloody, true, appearance);
}
}