| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using Content.Shared.IdentityManagement;
- using Content.Shared.Lube;
- using Content.Shared.NameModifier.EntitySystems;
- using Content.Shared.Popups;
- using Content.Shared.Throwing;
- using Robust.Shared.Containers;
- using Robust.Shared.Random;
- namespace Content.Server.Lube;
- public sealed class LubedSystem : EntitySystem
- {
- [Dependency] private readonly ThrowingSystem _throwing = default!;
- [Dependency] private readonly IRobustRandom _random = default!;
- [Dependency] private readonly SharedTransformSystem _transform = default!;
- [Dependency] private readonly SharedPopupSystem _popup = default!;
- [Dependency] private readonly NameModifierSystem _nameMod = default!;
- public override void Initialize()
- {
- base.Initialize();
- SubscribeLocalEvent<LubedComponent, ComponentInit>(OnInit);
- SubscribeLocalEvent<LubedComponent, ContainerGettingInsertedAttemptEvent>(OnHandPickUp);
- SubscribeLocalEvent<LubedComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
- }
- private void OnInit(EntityUid uid, LubedComponent component, ComponentInit args)
- {
- _nameMod.RefreshNameModifiers(uid);
- }
- private void OnHandPickUp(EntityUid uid, LubedComponent component, ContainerGettingInsertedAttemptEvent args)
- {
- if (component.SlipsLeft <= 0)
- {
- RemComp<LubedComponent>(uid);
- _nameMod.RefreshNameModifiers(uid);
- return;
- }
- component.SlipsLeft--;
- args.Cancel();
- var user = args.Container.Owner;
- _transform.SetCoordinates(uid, Transform(user).Coordinates);
- _transform.AttachToGridOrMap(uid);
- _throwing.TryThrow(uid, _random.NextVector2(), baseThrowSpeed: component.SlipStrength);
- _popup.PopupEntity(Loc.GetString("lube-slip", ("target", Identity.Entity(uid, EntityManager))), user, user, PopupType.MediumCaution);
- }
- private void OnRefreshNameModifiers(Entity<LubedComponent> entity, ref RefreshNameModifiersEvent args)
- {
- args.AddModifier("lubed-name-prefix");
- }
- }
|