StationBiomeSystem.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Content.Server.Parallax;
  2. using Content.Server.Station.Components;
  3. using Content.Server.Station.Events;
  4. using Content.Server.Station.Systems;
  5. using Robust.Shared.Map;
  6. using Robust.Shared.Prototypes;
  7. namespace Content.Server.Station.Systems;
  8. public sealed partial class StationBiomeSystem : EntitySystem
  9. {
  10. [Dependency] private readonly BiomeSystem _biome = default!;
  11. [Dependency] private readonly IMapManager _mapManager = default!;
  12. [Dependency] private readonly IPrototypeManager _proto = default!;
  13. [Dependency] private readonly StationSystem _station = default!;
  14. public override void Initialize()
  15. {
  16. base.Initialize();
  17. SubscribeLocalEvent<StationBiomeComponent, StationPostInitEvent>(OnStationPostInit);
  18. }
  19. private void OnStationPostInit(Entity<StationBiomeComponent> map, ref StationPostInitEvent args)
  20. {
  21. if (!TryComp(map, out StationDataComponent? dataComp))
  22. return;
  23. var station = _station.GetLargestGrid(dataComp);
  24. if (station == null) return;
  25. var mapId = Transform(station.Value).MapID;
  26. var mapUid = _mapManager.GetMapEntityId(mapId);
  27. _biome.EnsurePlanet(mapUid, _proto.Index(map.Comp.Biome), map.Comp.Seed, mapLight: map.Comp.MapLightColor);
  28. }
  29. }