Add static "IsPowered" method (#8434)
* Add static "IsPowered" method * Use IsPowered in more places Co-authored-by: wrexbe <wrexbe@protonmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Botany.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
@@ -22,29 +23,27 @@ public sealed class SeedExtractorSystem : EntitySystem
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, SeedExtractorComponent component, InteractUsingEvent args)
|
||||
{
|
||||
if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent) || !powerReceiverComponent.Powered)
|
||||
if (!this.IsPowered(uid, EntityManager))
|
||||
return;
|
||||
|
||||
if (TryComp(args.Used, out ProduceComponent? produce))
|
||||
if (!TryComp(args.Used, out ProduceComponent? produce)) return;
|
||||
if (!_botanySystem.TryGetSeed(produce, out var seed))
|
||||
return;
|
||||
|
||||
_popupSystem.PopupCursor(Loc.GetString("seed-extractor-component-interact-message",("name", args.Used)),
|
||||
Filter.Entities(args.User));
|
||||
|
||||
QueueDel(args.Used);
|
||||
|
||||
var random = _random.Next(component.MinSeeds, component.MaxSeeds);
|
||||
var coords = Transform(uid).Coordinates;
|
||||
|
||||
if (random > 1)
|
||||
seed.Unique = false;
|
||||
|
||||
for (var i = 0; i < random; i++)
|
||||
{
|
||||
if (!_botanySystem.TryGetSeed(produce, out var seed))
|
||||
return;
|
||||
|
||||
_popupSystem.PopupCursor(Loc.GetString("seed-extractor-component-interact-message",("name", args.Used)),
|
||||
Filter.Entities(args.User));
|
||||
|
||||
QueueDel(args.Used);
|
||||
|
||||
var random = _random.Next(component.MinSeeds, component.MaxSeeds);
|
||||
var coords = Transform(uid).Coordinates;
|
||||
|
||||
if (random > 1)
|
||||
seed.Unique = false;
|
||||
|
||||
for (var i = 0; i < random; i++)
|
||||
{
|
||||
_botanySystem.SpawnSeedPacket(seed, coords);
|
||||
}
|
||||
_botanySystem.SpawnSeedPacket(seed, coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user