SingularitySystem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Content.Shared.Singularity;
  2. using Content.Shared.Singularity.Components;
  3. using Content.Shared.Singularity.EntitySystems;
  4. using Robust.Client.GameObjects;
  5. using Robust.Shared.GameStates;
  6. using Robust.Shared.Utility;
  7. namespace Content.Client.Singularity.Systems;
  8. /// <summary>
  9. /// The client-side version of <see cref="SharedSingularitySystem"/>.
  10. /// Primarily manages <see cref="SingularityComponent"/>s.
  11. /// </summary>
  12. public sealed class SingularitySystem : SharedSingularitySystem
  13. {
  14. public override void Initialize()
  15. {
  16. base.Initialize();
  17. SubscribeLocalEvent<SingularityComponent, ComponentHandleState>(HandleSingularityState);
  18. }
  19. /// <summary>
  20. /// Handles syncing singularities with their server-side versions.
  21. /// </summary>
  22. /// <param name="uid">The uid of the singularity to sync.</param>
  23. /// <param name="comp">The state of the singularity to sync.</param>
  24. /// <param name="args">The event arguments including the state to sync the singularity with.</param>
  25. private void HandleSingularityState(EntityUid uid, SingularityComponent comp, ref ComponentHandleState args)
  26. {
  27. if (args.Current is not SingularityComponentState state)
  28. return;
  29. SetLevel(uid, state.Level, comp);
  30. }
  31. }