using Content.Shared.Destructible; using Content.Shared.Storage.Components; using Robust.Shared.Random; namespace Content.Server._Horizon.BluespaceHarvester; public sealed class BluespaceHarvesterBundleSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnOpen); SubscribeLocalEvent(OnDestruction); } private void OnOpen(Entity bundle, ref StorageBeforeOpenEvent args) { CreateLoot(bundle); } private void OnDestruction(Entity bundle, ref DestructionEventArgs args) { CreateLoot(bundle); } private void CreateLoot(Entity bundle) { if (bundle.Comp.Spawned) return; var content = _random.Pick(bundle.Comp.Contents); var position = Transform(bundle.Owner).Coordinates; for (var i = 0; i < content.Amount; i++) { Spawn(content.PrototypeId, position); } bundle.Comp.Spawned = true; } }