BuckleOnMapInitSystem.cs 585 B

12345678910111213141516171819
  1. using Content.Shared.Buckle;
  2. namespace Content.Server.Traits.Assorted;
  3. public sealed class BuckleOnMapInitSystem : EntitySystem
  4. {
  5. [Dependency] private readonly SharedBuckleSystem _buckleSystem = default!;
  6. public override void Initialize()
  7. {
  8. SubscribeLocalEvent<BuckleOnMapInitComponent, MapInitEvent>(OnMapInit);
  9. }
  10. private void OnMapInit(EntityUid uid, BuckleOnMapInitComponent component, MapInitEvent args)
  11. {
  12. var buckle = Spawn(component.Prototype, Transform(uid).Coordinates);
  13. _buckleSystem.TryBuckle(uid, uid, buckle);
  14. }
  15. }