Recycler Overhaul (#30802)

* Recycler overhaul

* remove
This commit is contained in:
Nemanja
2024-08-18 23:39:00 -04:00
committed by GitHub
parent 1fa447f769
commit 476c7751c4
32 changed files with 207 additions and 253 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.DeviceLinking.Systems;
using Content.Server.Materials;
using Content.Server.Power.Components;
using Content.Shared.Conveyor;
using Content.Shared.Destructible;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Physics.Controllers;
@@ -26,7 +27,7 @@ public sealed class ConveyorController : SharedConveyorController
UpdatesAfter.Add(typeof(MoverController));
SubscribeLocalEvent<ConveyorComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ConveyorComponent, ComponentShutdown>(OnConveyorShutdown);
SubscribeLocalEvent<ConveyorComponent, BreakageEventArgs>(OnBreakage);
SubscribeLocalEvent<ConveyorComponent, SignalReceivedEvent>(OnSignalReceived);
SubscribeLocalEvent<ConveyorComponent, PowerChangedEvent>(OnPowerChanged);
@@ -61,6 +62,11 @@ public sealed class ConveyorController : SharedConveyorController
_fixtures.DestroyFixture(uid, ConveyorFixture, body: physics);
}
private void OnBreakage(Entity<ConveyorComponent> ent, ref BreakageEventArgs args)
{
SetState(ent, ConveyorState.Off, ent);
}
private void OnPowerChanged(EntityUid uid, ConveyorComponent component, ref PowerChangedEvent args)
{
component.Powered = args.Powered;
@@ -96,13 +102,14 @@ public sealed class ConveyorController : SharedConveyorController
if (!Resolve(uid, ref component))
return;
if (!_materialReclaimer.SetReclaimerEnabled(uid, state != ConveyorState.Off))
return;
component.State = state;
if (TryComp<PhysicsComponent>(uid, out var physics))
_broadphase.RegenerateContacts(uid, physics);
_materialReclaimer.SetReclaimerEnabled(uid, component.State != ConveyorState.Off);
UpdateAppearance(uid, component);
Dirty(uid, component);
}