using Content.Shared.Emag.Systems; using Content.Shared.Mobs; using Robust.Shared.Audio.Systems; using System.Diagnostics.CodeAnalysis; namespace Content.Shared.Silicons.Bots; /// /// Handles emagging medibots and provides api. /// public sealed class MedibotSystem : EntitySystem { [Dependency] private readonly SharedAudioSystem _audio = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnEmagged); } private void OnEmagged(EntityUid uid, EmaggableMedibotComponent comp, ref GotEmaggedEvent args) { if (!TryComp(uid, out var medibot)) return; _audio.PlayPredicted(comp.SparkSound, uid, args.UserUid); foreach (var (state, treatment) in comp.Replacements) { medibot.Treatments[state] = treatment; } args.Handled = true; } /// /// Get a treatment for a given mob state. /// /// /// This only exists because allowing other execute would allow modifying the dictionary, and Read access does not cover TryGetValue. /// public bool TryGetTreatment(MedibotComponent comp, MobState state, [NotNullWhen(true)] out MedibotTreatment? treatment) { return comp.Treatments.TryGetValue(state, out treatment); } }