using Content.Shared.Actions; using Content.Shared.Fluids.Components; using Content.Shared.Verbs; using Robust.Shared.Map; namespace Content.Shared.Fluids.EntitySystems; public abstract class SharedSpraySystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent>(OnGetVerb); SubscribeLocalEvent(SprayLiquid); } private void SprayLiquid(SprayLiquidEvent ev) { var equipSprayEnt = ev.Action.Comp.Container; if (equipSprayEnt == null) { Log.Warning($"{ev.Action.Comp.AttachedEntity} tried to use the SprayLiquidEvent but the entity was null."); return; } if (!TryComp(equipSprayEnt, out var sprayComponent)) { Log.Warning($"{ev.Action.Comp.AttachedEntity} tried to use the SprayLiquidEvent on {equipSprayEnt} but the SprayComponent did not exist."); return; } Spray((equipSprayEnt.Value, sprayComponent), ev.Performer); } private void OnGetVerb(Entity entity, ref GetVerbsEvent args) { if (entity.Comp.VerbLocId == null || !args.CanAccess || !args.CanInteract) return; var sprayComponent = Comp(entity); var user = args.User; var verb = new EquipmentVerb { Act = () => { Spray((entity, sprayComponent), user); }, Text = Loc.GetString(entity.Comp.VerbLocId), }; args.Verbs.Add(verb); } /// /// Spray starting from the entity, to the given coordinates. If the user is supplied, will give them failure /// popups and will also push them in space. /// /// Entity that is spraying. /// The coordinates being aimed at. /// The user that is using the spraying device. public virtual void Spray(Entity entity, MapCoordinates mapcoord, EntityUid? user = null) { // do nothing! } /// /// Spray starting from the entity and facing the direction its pointing. /// /// Entity that is spraying. /// User that is using the spraying device. public virtual void Spray(Entity entity, EntityUid? user = null) { // do nothing! } } public sealed partial class SprayLiquidEvent : InstantActionEvent;