CatStation/Content.Shared/EntityEffects/Effects/Transform/PopupMessageEntityEffectSystem.cs
AndrewFenriz 53e29ab962
Move admin smites to prototypes (#45550)
* Add prototype-backed admin verb framework

* Add reusable admin verb operations

* Add smite-specific admin operations

* Migrate admin smites to prototypes

* More docs for god of docs

* We dont have prediction here, so...

* Final cleanup

* Fix adminSmite

* Add segment display control

* Add generic thermoregulator

* Add thermobath systems

* Replace hotplate with thermobath

* Refine thermobath layout

* move simple smites to effects

* move comps to effects

* move add action to effect

* move add mind role to effect

* move add user interfaces to effect

* move godmode to effect

* move eye zoom to effect

* move speed swap to effect

* move spill bloodstream to effect

* move remove organs to effect

* move cream pie to effect

* move slip to effect

* fix server effect usings

* move homing rod to effect

* move locker stuff to effect

* move tabletop dimension to effect

* move pinball to effect

* move yeet to effect

* move silicon laws to effect

* move ghost kick to effect

* remove admin operations

* revert sht

* remove BOM

* use admin verb prototypes for smites

* add heart attack smite prototype

* docs update

* fix AdminSmiteVomitOrgans

* split and move to shared

* move to shared

* move to shared and predict

* PredictedQueueDel

* fix Popup

* fix HomingRod

* port DeleteEntityEntityEffectSystem

* fix StuffIntoLockerEntityEffectSystem

* upd

* fix eye

* fix movement

* fix!!

* fix and doc

* Add admin verb category prototype

* upd AdminVerbPrototype

* split verbs

* SuperSuperSuperBonk

* Update PopupMessageEntityEffectSystem.cs

* fields

---------

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
2026-09-18 19:01:16 +00:00

99 lines
3.4 KiB
C#

using Content.Shared.Popups;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
namespace Content.Shared.EntityEffects.Effects.Transform;
/// <summary>
/// Creates a text popup to appear at this entity's coordinates.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
public sealed partial class PopupMessageEntityEffectSystem : EntityEffectSystem<TransformComponent, PopupMessage>
{
[Dependency] private INetManager _net = default!;
[Dependency] private IRobustRandom _random = default!;
[Dependency] private SharedPopupSystem _popup = default!;
protected override void Effect(Entity<TransformComponent> entity, ref EntityEffectEvent<PopupMessage> args)
{
// TODO: When we get proper random prediction remove this check.
if (_net.IsClient)
return;
var msg = Loc.GetString(_random.Pick(args.Effect.Messages), ("entity", entity));
switch (args.Effect.Method, args.Effect.Type)
{
case (PopupMethod.PopupEntity, PopupRecipients.Local):
_popup.PopupEntity(msg, entity, entity, args.Effect.VisualType);
break;
case (PopupMethod.PopupEntity, PopupRecipients.Pvs):
_popup.PopupEntity(msg, entity, args.Effect.VisualType);
break;
case (PopupMethod.PopupCoordinates, PopupRecipients.Local):
_popup.PopupCoordinates(msg, Transform(entity).Coordinates, entity, args.Effect.VisualType);
break;
case (PopupMethod.PopupCoordinates, PopupRecipients.Pvs):
_popup.PopupCoordinates(msg, Transform(entity).Coordinates, args.Effect.VisualType);
break;
case (PopupMethod.PopupEntity, PopupRecipients.PvsExceptTarget):
_popup.PopupEntity(msg, entity, Filter.PvsExcept(entity), true, args.Effect.VisualType);
break;
case (PopupMethod.PopupCoordinates, PopupRecipients.PvsExceptTarget):
_popup.PopupCoordinates(
msg,
Transform(entity).Coordinates,
Filter.PvsExcept(entity),
true,
args.Effect.VisualType);
break;
}
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class PopupMessage : EntityEffectBase<PopupMessage>
{
/// <summary>
/// Array of messages that can popup.
/// Only one is chosen when the effect is applied.
/// </summary>
[DataField(required: true)]
public string[] Messages = default!;
/// <summary>
/// Whether to just the entity we're affecting, or everyone around them.
/// </summary>
[DataField]
public PopupRecipients Type = PopupRecipients.Local;
/// <summary>
/// Which popup API method to use.
/// Use PopupCoordinates in case the entity will be deleted while the popup is shown.
/// </summary>
[DataField]
public PopupMethod Method = PopupMethod.PopupEntity;
/// <summary>
/// Size of the popup.
/// </summary>
[DataField]
public PopupType VisualType = PopupType.Small;
}
[Serializable, NetSerializable]
public enum PopupRecipients : byte
{
Pvs,
Local,
PvsExceptTarget,
}
[Serializable, NetSerializable]
public enum PopupMethod : byte
{
PopupEntity,
PopupCoordinates,
}