Component of planet initialization on the map (#26510)
* no cl no fun * DevPlanet * fix europa? * Update Content.Server/Station/Components/StationBiomeComponent.cs * Update Content.Server/Station/Components/StationBiomeComponent.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
19
Content.Server/Station/Components/StationBiomeComponent.cs
Normal file
19
Content.Server/Station/Components/StationBiomeComponent.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Content.Server.Station.Systems;
|
||||||
|
using Content.Shared.Parallax.Biomes;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Server.Station.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs EnsurePlanet against the largest grid on Mapinit.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(StationBiomeSystem))]
|
||||||
|
public sealed partial class StationBiomeComponent : Component
|
||||||
|
{
|
||||||
|
[DataField(required: true)]
|
||||||
|
public ProtoId<BiomeTemplatePrototype> Biome = "Grasslands";
|
||||||
|
|
||||||
|
// If null, its random
|
||||||
|
[DataField]
|
||||||
|
public int? Seed = null;
|
||||||
|
}
|
||||||
35
Content.Server/Station/Systems/StationBiomeSystem.cs
Normal file
35
Content.Server/Station/Systems/StationBiomeSystem.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Content.Server.Parallax;
|
||||||
|
using Content.Server.Station.Components;
|
||||||
|
using Content.Server.Station.Events;
|
||||||
|
using Content.Server.Station.Systems;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Server.Station.Systems;
|
||||||
|
public sealed partial class StationBiomeSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly BiomeSystem _biome = default!;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
|
[Dependency] private readonly StationSystem _station = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<StationBiomeComponent, StationPostInitEvent>(OnStationPostInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStationPostInit(Entity<StationBiomeComponent> map, ref StationPostInitEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp(map, out StationDataComponent? dataComp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var station = _station.GetLargestGrid(dataComp);
|
||||||
|
if (station == null) return;
|
||||||
|
|
||||||
|
var mapId = Transform(station.Value).MapID;
|
||||||
|
var mapUid = _mapManager.GetMapEntityId(mapId);
|
||||||
|
|
||||||
|
_biome.EnsurePlanet(mapUid, _proto.Index(map.Comp.Biome), map.Comp.Seed);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,8 @@
|
|||||||
Europa:
|
Europa:
|
||||||
stationProto: StandardNanotrasenStation
|
stationProto: StandardNanotrasenStation
|
||||||
components:
|
components:
|
||||||
|
- type: StationBiome
|
||||||
|
biome: Snow
|
||||||
- type: StationRandomTransform
|
- type: StationRandomTransform
|
||||||
enableStationRotation: false
|
enableStationRotation: false
|
||||||
maxStationOffset: null
|
maxStationOffset: null
|
||||||
|
|||||||
Reference in New Issue
Block a user