<commit_before>﻿using Content.Shared.Chemistry.Reagent;
using Content.Shared.Popups;
using Robust.Shared.Player;
using Robust.Shared.Random;

namespace Content.Server.Chemistry.ReagentEffects
{
    public sealed class PopupMessage : ReagentEffect
    {
        [DataField("messages", required: true)]
        public string[] Messages = default!;

        [DataField("type")]
        public PopupRecipients Type = PopupRecipients.Local;

        [DataField("visualType")]
        public PopupType VisualType = PopupType.Small;

        public override void Effect(ReagentEffectArgs args)
        {
            var popupSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedPopupSystem>();
            var random = IoCManager.Resolve<IRobustRandom>();

            var msg = random.Pick(Messages);
            if (Type == PopupRecipients.Local)
                popupSys.PopupEntity(Loc.GetString(msg), args.SolutionEntity, Filter.Entities(args.SolutionEntity), VisualType);
            else if (Type == PopupRecipients.Pvs)
                popupSys.PopupEntity(Loc.GetString(msg), args.SolutionEntity, Filter.Pvs(args.SolutionEntity), VisualType);
        }
    }

    public enum PopupRecipients
    {
        Pvs,
        Local
    }
}
<commit_msg>Permit ReagentEffect PopupMessage to access the solutionEntity it occurs in. (#11537)<commit_after>﻿using Content.Shared.Chemistry.Reagent;
using Content.Shared.Popups;
using Robust.Shared.Player;
using Robust.Shared.Random;

namespace Content.Server.Chemistry.ReagentEffects
{
    public sealed class PopupMessage : ReagentEffect
    {
        [DataField("messages", required: true)]
        public string[] Messages = default!;

        [DataField("type")]
        public PopupRecipients Type = PopupRecipients.Local;

        [DataField("visualType")]
        public PopupType VisualType = PopupType.Small;

        public override void Effect(ReagentEffectArgs args)
        {
            var popupSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedPopupSystem>();
            var random = IoCManager.Resolve<IRobustRandom>();

            var msg = random.Pick(Messages);
            var msgArgs = new (string, object)[] {
                ("entity", args.SolutionEntity),
                ("organ", args.OrganEntity.GetValueOrDefault()),
            };
            if (Type == PopupRecipients.Local)
                popupSys.PopupEntity(Loc.GetString(msg, msgArgs), args.SolutionEntity, Filter.Entities(args.SolutionEntity), VisualType);
            else if (Type == PopupRecipients.Pvs)
                popupSys.PopupEntity(Loc.GetString(msg, msgArgs), args.SolutionEntity, Filter.Pvs(args.SolutionEntity), VisualType);
        }
    }

    public enum PopupRecipients
    {
        Pvs,
        Local
    }
}

{'fraction_non_alphanumeric': 0.10050251256281408, 'fraction_numerical': 0.0017946877243359654, 'mean_word_length': 2.802182810368349, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4888575', 'n_tokens_mistral': 794, 'n_tokens_neox': 753, 'n_words': 153}