forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
774 additions
and
1 deletion.
There are no files selected for viewing
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
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
4 changes: 4 additions & 0 deletions
4
Content.Server/_CorvaxNext/AdditionalMap/AdditionalMapFixComponent.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,4 @@ | ||
namespace Content.Server._CorvaxNext.AdditionalMap; | ||
|
||
[RegisterComponent] | ||
public sealed partial class AdditionalMapFixComponent : Component; |
34 changes: 34 additions & 0 deletions
34
Content.Server/_CorvaxNext/AdditionalMap/AdditionalMapFixSystem.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,34 @@ | ||
using System.Threading; | ||
using Content.Server.Atmos.Components; | ||
using Content.Server.GameTicking; | ||
using Content.Server.Shuttles.Systems; | ||
using Content.Server.Station.Events; | ||
using Robust.Server.Console; | ||
using Timer = Robust.Shared.Timing.Timer; | ||
|
||
namespace Content.Server._CorvaxNext.AdditionalMapFix; | ||
public sealed class AdditionalMapFix : EntitySystem | ||
{ | ||
[Dependency] private readonly IServerConsoleHost _host = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<StationPostInitEvent>(OnStartup, after: new[] { typeof(ShuttleSystem) }); | ||
} | ||
|
||
private void OnStartup(ref StationPostInitEvent args) | ||
{ | ||
Timer.Spawn(TimeSpan.FromSeconds(5), () => | ||
{ | ||
var query = AllEntityQuery<GridAtmosphereComponent, TransformComponent>(); | ||
|
||
while (query.MoveNext(out var dummyatmos, out var comp)) | ||
{ | ||
var gridUid = comp.GridUid; | ||
_host.AppendCommand($"fixgridatmos {gridUid}"); | ||
Logger.Error($"executed command on {gridUid}"); | ||
} | ||
}); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Content.Server/_CorvaxNext/AdditionalMap/StationAdditionalMapComponent.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,23 @@ | ||
/* | ||
* All right reserved to CrystallEdge. | ||
* | ||
* BUT this file is sublicensed under MIT License | ||
* | ||
*/ | ||
|
||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server._CorvaxNext.AdditionalMap; | ||
|
||
/// <summary> | ||
/// Loads additional maps from the list at the start of the round. | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(StationAdditionalMapSystem))] | ||
public sealed partial class StationAdditionalMapComponent : Component | ||
{ | ||
/// <summary> | ||
/// A map paths to load on a new map. | ||
/// </summary> | ||
[DataField] | ||
public List<ResPath> MapPaths = new(); | ||
} |
53 changes: 53 additions & 0 deletions
53
Content.Server/_CorvaxNext/AdditionalMap/StationAdditionalMapSystem.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,53 @@ | ||
/* | ||
* All right reserved to CrystallEdge. | ||
* | ||
* BUT this file is sublicensed under MIT License | ||
* | ||
*/ | ||
|
||
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._CorvaxNext.AdditionalMap; | ||
|
||
public sealed partial class StationAdditionalMapSystem : 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<StationAdditionalMapComponent, StationPostInitEvent>(OnStationPostInit); | ||
} | ||
|
||
private void OnStationPostInit(Entity<StationAdditionalMapComponent> 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; | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Content.Server/_CorvaxNext/BiomeSpawner/Components/BiomeSpawnerComponent.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,22 @@ | ||
/* | ||
* All right reserved to CrystallEdge. | ||
* | ||
* BUT this file is sublicensed under MIT License | ||
* | ||
*/ | ||
|
||
using Content.Server._CorvaxNext.BiomeSpawner.EntitySystems; | ||
using Content.Shared.Parallax.Biomes; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server._CorvaxNext.BiomeSpawner.Components; | ||
|
||
/// <summary> | ||
/// fills the tile in which it is located with the contents of the biome. Includes: tile, decals and entities | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(BiomeSpawnerSystem))] | ||
public sealed partial class BiomeSpawnerComponent : Component | ||
{ | ||
[DataField] | ||
public ProtoId<BiomeTemplatePrototype> Biome = "Grasslands"; | ||
} |
96 changes: 96 additions & 0 deletions
96
Content.Server/_CorvaxNext/BiomeSpawner/EntitySystems/BiomeSpawnerSystem.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,96 @@ | ||
/* | ||
* All right reserved to CrystallEdge. | ||
* | ||
* BUT this file is sublicensed under MIT License | ||
* | ||
*/ | ||
|
||
using System.Linq; | ||
using Content.Server._CorvaxNext.BiomeSpawner.Components; | ||
using System.Numerics; | ||
using Content.Server.Decals; | ||
using Content.Server.GameTicking; | ||
using Content.Server.Parallax; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server._CorvaxNext.BiomeSpawner.EntitySystems; | ||
|
||
public sealed class BiomeSpawnerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
[Dependency] private readonly BiomeSystem _biome = default!; | ||
[Dependency] private readonly TransformSystem _transform = default!; | ||
[Dependency] private readonly SharedMapSystem _maps = default!; | ||
[Dependency] private readonly DecalSystem _decals = default!; | ||
[Dependency] private readonly EntityLookupSystem _lookup = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
private int _seed = 27; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<RoundStartAttemptEvent>(OnRoundStartAttempt); | ||
SubscribeLocalEvent<BiomeSpawnerComponent, MapInitEvent>(OnMapInit); | ||
} | ||
|
||
private void OnRoundStartAttempt(RoundStartAttemptEvent ev) | ||
{ | ||
_seed = _random.Next(100000); | ||
} | ||
|
||
private void OnMapInit(Entity<BiomeSpawnerComponent> ent, ref MapInitEvent args) | ||
{ | ||
SpawnBiome(ent); | ||
QueueDel(ent); | ||
} | ||
|
||
private void SpawnBiome(Entity<BiomeSpawnerComponent> ent) | ||
{ | ||
var biome = _proto.Index(ent.Comp.Biome); | ||
var spawnerTransform = Transform(ent); | ||
if (spawnerTransform.GridUid == null) | ||
return; | ||
var gridUid = spawnerTransform.GridUid.Value; | ||
if (!TryComp<MapGridComponent>(gridUid, out var map)) | ||
return; | ||
|
||
var vec = _transform.GetGridOrMapTilePosition(ent); | ||
if (!_biome.TryGetTile(vec, biome.Layers, _seed, map, out var tile)) | ||
return; | ||
|
||
// Set new tile | ||
_maps.SetTile(gridUid, map, vec, tile.Value); | ||
var tileCenterVec = vec + map.TileSizeHalfVector; | ||
|
||
// Remove old decals | ||
var oldDecals = _decals.GetDecalsInRange(gridUid, tileCenterVec); | ||
foreach (var (id, _) in oldDecals) | ||
{ | ||
_decals.RemoveDecal(gridUid, id); | ||
} | ||
|
||
//Add decals | ||
if (_biome.TryGetDecals(vec, biome.Layers, _seed, map, out var decals)) | ||
{ | ||
foreach (var decal in decals) | ||
{ | ||
_decals.TryAddDecal(decal.ID, new EntityCoordinates(gridUid, decal.Position), out _); | ||
} | ||
} | ||
|
||
// Remove entities | ||
var oldEntities = _lookup.GetEntitiesInRange(spawnerTransform.Coordinates, 0.48f); | ||
// TODO: Replace this with GetEntitiesInBox2 | ||
foreach (var entToRemove in oldEntities.Concat(new[] { ent.Owner })) // Do not remove self | ||
{ | ||
QueueDel(entToRemove); | ||
} | ||
|
||
if (_biome.TryGetEntity(vec, biome.Layers, tile.Value, _seed, map, out var entityProto)) | ||
Spawn(entityProto, new EntityCoordinates(gridUid, tileCenterVec)); | ||
} | ||
} |
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,8 @@ | ||
namespace Content.Server._CorvaxNext.Warper; | ||
|
||
[RegisterComponent] | ||
public sealed partial class WarperComponent : Component | ||
{ | ||
/// Warp destination unique identifier. | ||
[ViewVariables(VVAccess.ReadWrite)] [DataField("id")] public string? ID { get; set; } | ||
} |
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,76 @@ | ||
using Content.Server.Ghost.Components; | ||
using Content.Server.Warps; | ||
using Content.Server.Popups; | ||
using Content.Shared.Ghost; | ||
using Content.Shared.Interaction; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Components; | ||
using Robust.Shared.Physics.Systems; | ||
using Robust.Shared.Player; | ||
using System.Numerics; | ||
|
||
namespace Content.Server._CorvaxNext.Warper; | ||
|
||
public class WarperSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly PopupSystem _popupSystem = default!; | ||
[Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
[Dependency] private readonly WarpPointSystem _warpPointSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<WarperComponent, InteractHandEvent>(OnInteractHand); | ||
} | ||
|
||
private void OnInteractHand(EntityUid uid, WarperComponent component, InteractHandEvent args) | ||
{ | ||
if (component.ID is null) | ||
{ | ||
Logger.DebugS("warper", "Warper has no destination"); | ||
_popupSystem.PopupEntity(Loc.GetString("warper-goes-nowhere", ("warper", args.Target)), args.User, Filter.Entities(args.User), true); | ||
return; | ||
} | ||
|
||
var dest = _warpPointSystem.FindWarpPoint(component.ID); | ||
if (dest is null) | ||
{ | ||
Logger.DebugS("warper", String.Format("Warp destination '{0}' not found", component.ID)); | ||
_popupSystem.PopupEntity(Loc.GetString("warper-goes-nowhere", ("warper", args.Target)), args.User, Filter.Entities(args.User), true); | ||
return; | ||
} | ||
|
||
var entMan = IoCManager.Resolve<IEntityManager>(); | ||
TransformComponent? destXform; | ||
entMan.TryGetComponent<TransformComponent>(dest.Value, out destXform); | ||
if (destXform is null) | ||
{ | ||
Logger.DebugS("warper", String.Format("Warp destination '{0}' has no transform", component.ID)); | ||
_popupSystem.PopupEntity(Loc.GetString("warper-goes-nowhere", ("warper", args.Target)), args.User, Filter.Entities(args.User), true); | ||
return; | ||
} | ||
|
||
// Check that the destination map is initialized and return unless in aghost mode. | ||
var mapMgr = IoCManager.Resolve<IMapManager>(); | ||
var destMap = destXform.MapID; | ||
if (!mapMgr.IsMapInitialized(destMap) || mapMgr.IsMapPaused(destMap)) | ||
{ | ||
if (!entMan.HasComponent<GhostComponent>(args.User)) | ||
{ | ||
// Normal ghosts cannot interact, so if we're here this is already an admin ghost. | ||
Logger.DebugS("warper", String.Format("Player tried to warp to '{0}', which is not on a running map", component.ID)); | ||
_popupSystem.PopupEntity(Loc.GetString("warper-goes-nowhere", ("warper", args.Target)), args.User, Filter.Entities(args.User), true); | ||
return; | ||
} | ||
} | ||
|
||
var xform = entMan.GetComponent<TransformComponent>(args.User); | ||
xform.Coordinates = destXform.Coordinates; | ||
xform.AttachToGridOrMap(); | ||
if (entMan.TryGetComponent(uid, out PhysicsComponent? phys)) | ||
{ | ||
_physics.SetLinearVelocity(uid, Vector2.Zero); | ||
} | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
Resources/Locale/ru-RU/_corvaxnext/warper/warp-point-component.ftl
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 @@ | ||
warper-goes-nowhere = {CAPITALIZE($warper)} никуда не ведёт. |
Oops, something went wrong.