forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Procedural + z-levels refactor (space-wizards#216)
* create biome tile spawner * spawner now spawn decals and entities * fancy spawners * remove old decals * randomize seed * fix bugs * update alchemy test map to new system * update z-level system * autolink tweak * add documentation * Update GravityComponent.cs * Update GravityComponent.cs
- Loading branch information
Showing
11 changed files
with
20,059 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Content.Server/_CP14/PortalAutoLink/CP14AutoLinkComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Robust.Shared.Map; | ||
|
||
namespace Content.Server._CP14.PortalAutoLink; | ||
|
||
/// <summary> | ||
/// allows you to automatically link entities to each other, through key matching searches | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(CP14AutoLinkSystem))] | ||
public sealed partial class CP14AutoLinkComponent : Component | ||
{ | ||
/// <summary> | ||
/// a key that is used to search for another autolinked entity installed in the worlds | ||
/// </summary> | ||
[DataField] | ||
public string? AutoLinkKey = "Hello"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Content.Shared.Interaction; | ||
using Content.Shared.Teleportation.Systems; | ||
|
||
namespace Content.Server._CP14.PortalAutoLink; | ||
|
||
public sealed partial class CP14AutoLinkSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly LinkedEntitySystem _link = default!; | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<CP14AutoLinkComponent, MapInitEvent>(OnMapInit); | ||
} | ||
|
||
private void OnMapInit(Entity<CP14AutoLinkComponent> autolink, ref MapInitEvent args) | ||
{ | ||
TryAutoLink(autolink, out var otherLink); | ||
} | ||
public bool TryAutoLink(Entity<CP14AutoLinkComponent> autolink, out EntityUid? linkedEnt) | ||
{ | ||
linkedEnt = null; | ||
|
||
var query = EntityQueryEnumerator<CP14AutoLinkComponent>(); | ||
while (query.MoveNext(out var uid, out var otherAutolink)) | ||
{ | ||
if (autolink.Comp == otherAutolink) | ||
continue; | ||
|
||
if (autolink.Comp.AutoLinkKey == otherAutolink.AutoLinkKey) | ||
{ | ||
if (_link.TryLink(autolink, uid, false)) | ||
{ | ||
RemComp<CP14AutoLinkComponent>(uid); | ||
RemComp<CP14AutoLinkComponent>(autolink); | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Content.Server/_CP14/StationDungeonMap/CP14StationAdditionalMapComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server._CP14.StationDungeonMap; | ||
|
||
/// <summary> | ||
/// Initializes a procedurally generated world with points of interest | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(CP14StationAdditionalMapSystem))] | ||
public sealed partial class CP14StationAdditionalMapComponent : Component | ||
{ | ||
/// <summary> | ||
/// A map paths to load on a new map. | ||
/// </summary> | ||
[DataField] | ||
public List<ResPath> MapPaths = new(); | ||
} |
46 changes: 46 additions & 0 deletions
46
Content.Server/_CP14/StationDungeonMap/CP14StationAdditionalMapSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Content.Server.Parallax; | ||
using Content.Server.Station.Components; | ||
using Content.Server.Station.Events; | ||
using Content.Server.Station.Systems; | ||
using Content.Shared.Teleportation.Systems; | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server._CP14.StationDungeonMap; | ||
|
||
public sealed partial class CP14StationAdditionalMapSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly BiomeSystem _biome = default!; | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
[Dependency] private readonly MapSystem _map = default!; | ||
[Dependency] private readonly MetaDataSystem _metaData = default!; | ||
[Dependency] private readonly LinkedEntitySystem _linkedEntity = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
[Dependency] private readonly MapLoaderSystem _mapLoader = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<CP14StationAdditionalMapComponent, StationPostInitEvent>(OnStationPostInit); | ||
} | ||
|
||
private void OnStationPostInit(Entity<CP14StationAdditionalMapComponent> addMap, ref StationPostInitEvent args) | ||
{ | ||
if (!TryComp(addMap, out StationDataComponent? dataComp)) | ||
return; | ||
|
||
foreach (var path in addMap.Comp.MapPaths) | ||
{ | ||
var mapUid = _map.CreateMap(out var mapId); | ||
Log.Info($"Created map {mapId} for StationAdditionalMap system"); | ||
var options = new MapLoadOptions { LoadMap = true }; | ||
if (!_mapLoader.TryLoad(mapId, path.ToString(), out var roots, options)) | ||
{ | ||
Log.Error($"Failed to load map from {path}!"); | ||
Del(mapUid); | ||
return; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.