2022-12-19 10:41:47 +13:00
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-20 16:47:53 -07:00
|
|
|
using Content.Shared.Popups;
|
|
|
|
|
using Robust.Shared.Player;
|
2023-06-04 16:45:02 -04:00
|
|
|
using Robust.Shared.Prototypes;
|
2021-11-20 16:47:53 -07:00
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Chemistry.ReagentEffects
|
|
|
|
|
{
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class PopupMessage : ReagentEffect
|
2021-11-20 16:47:53 -07:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField(required: true)]
|
2021-11-20 16:47:53 -07:00
|
|
|
public string[] Messages = default!;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField]
|
2022-07-09 02:09:52 -07:00
|
|
|
public PopupRecipients Type = PopupRecipients.Local;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField]
|
2022-07-09 02:09:52 -07:00
|
|
|
public PopupType VisualType = PopupType.Small;
|
2021-11-20 16:47:53 -07:00
|
|
|
|
2023-06-04 16:45:02 -04:00
|
|
|
// JUSTIFICATION: This is purely cosmetic.
|
|
|
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
|
|
|
|
=> null;
|
|
|
|
|
|
2021-11-21 00:35:02 -07:00
|
|
|
public override void Effect(ReagentEffectArgs args)
|
2021-11-20 16:47:53 -07:00
|
|
|
{
|
|
|
|
|
var popupSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedPopupSystem>();
|
|
|
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
|
|
|
|
|
|
|
|
|
var msg = random.Pick(Messages);
|
2022-10-03 21:46:54 -04:00
|
|
|
var msgArgs = new (string, object)[] {
|
|
|
|
|
("entity", args.SolutionEntity),
|
|
|
|
|
("organ", args.OrganEntity.GetValueOrDefault()),
|
|
|
|
|
};
|
2022-07-09 02:09:52 -07:00
|
|
|
if (Type == PopupRecipients.Local)
|
2022-12-19 10:41:47 +13:00
|
|
|
popupSys.PopupEntity(Loc.GetString(msg, msgArgs), args.SolutionEntity, args.SolutionEntity, VisualType);
|
2022-07-09 02:09:52 -07:00
|
|
|
else if (Type == PopupRecipients.Pvs)
|
2022-12-19 10:41:47 +13:00
|
|
|
popupSys.PopupEntity(Loc.GetString(msg, msgArgs), args.SolutionEntity, VisualType);
|
2021-11-20 16:47:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-09 02:09:52 -07:00
|
|
|
public enum PopupRecipients
|
2021-11-20 16:47:53 -07:00
|
|
|
{
|
|
|
|
|
Pvs,
|
|
|
|
|
Local
|
|
|
|
|
}
|
|
|
|
|
}
|