Rotate and Offset station CCVar nuke (#26175)
* no content * add noRot to Europa * bruh. and this * yay * fix
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Events;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Fax;
|
||||
using Content.Shared.Station;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -49,17 +50,12 @@ public sealed class StationSystem : EntitySystem
|
||||
_sawmill = _logManager.GetSawmill("station");
|
||||
|
||||
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRoundEnd);
|
||||
SubscribeLocalEvent<PreGameMapLoad>(OnPreGameMapLoad);
|
||||
SubscribeLocalEvent<PostGameMapLoad>(OnPostGameMapLoad);
|
||||
SubscribeLocalEvent<StationDataComponent, ComponentStartup>(OnStationAdd);
|
||||
SubscribeLocalEvent<StationDataComponent, ComponentShutdown>(OnStationDeleted);
|
||||
SubscribeLocalEvent<StationMemberComponent, ComponentShutdown>(OnStationGridDeleted);
|
||||
SubscribeLocalEvent<StationMemberComponent, PostGridSplitEvent>(OnStationSplitEvent);
|
||||
|
||||
Subs.CVar(_configurationManager, CCVars.StationOffset, x => _randomStationOffset = x, true);
|
||||
Subs.CVar(_configurationManager, CCVars.MaxStationOffset, x => _maxRandomStationOffset = x, true);
|
||||
Subs.CVar(_configurationManager, CCVars.StationRotation, x => _randomStationRotation = x, true);
|
||||
|
||||
_player.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
}
|
||||
|
||||
@@ -112,19 +108,6 @@ public sealed class StationSystem : EntitySystem
|
||||
RaiseNetworkEvent(new StationsUpdatedEvent(GetStationNames()), Filter.Broadcast());
|
||||
}
|
||||
|
||||
private void OnPreGameMapLoad(PreGameMapLoad ev)
|
||||
{
|
||||
// this is only for maps loaded during round setup!
|
||||
if (_gameTicker.RunLevel == GameRunLevel.InRound)
|
||||
return;
|
||||
|
||||
if (_randomStationOffset)
|
||||
ev.Options.Offset += _random.NextVector2(_maxRandomStationOffset);
|
||||
|
||||
if (_randomStationRotation)
|
||||
ev.Options.Rotation = _random.NextAngle();
|
||||
}
|
||||
|
||||
private void OnPostGameMapLoad(PostGameMapLoad ev)
|
||||
{
|
||||
var dict = new Dictionary<string, List<EntityUid>>();
|
||||
@@ -311,6 +294,8 @@ public sealed class StationSystem : EntitySystem
|
||||
// Use overrides for setup.
|
||||
var station = EntityManager.SpawnEntity(stationConfig.StationPrototype, MapCoordinates.Nullspace, stationConfig.StationComponentOverrides);
|
||||
|
||||
|
||||
|
||||
if (name is not null)
|
||||
RenameStation(station, name, false);
|
||||
|
||||
@@ -319,11 +304,48 @@ public sealed class StationSystem : EntitySystem
|
||||
var data = Comp<StationDataComponent>(station);
|
||||
name ??= MetaData(station).EntityName;
|
||||
|
||||
foreach (var grid in gridIds ?? Array.Empty<EntityUid>())
|
||||
var entry = gridIds ?? Array.Empty<EntityUid>();
|
||||
|
||||
foreach (var grid in entry)
|
||||
{
|
||||
AddGridToStation(station, grid, null, data, name);
|
||||
}
|
||||
|
||||
if (TryComp<StationRandomTransformComponent>(station, out var random))
|
||||
{
|
||||
Angle? rotation = null;
|
||||
Vector2? offset = null;
|
||||
|
||||
if (random.MaxStationOffset != null)
|
||||
offset = _random.NextVector2(-random.MaxStationOffset.Value, random.MaxStationOffset.Value);
|
||||
|
||||
if (random.EnableStationRotation)
|
||||
rotation = _random.NextAngle();
|
||||
|
||||
foreach (var grid in entry)
|
||||
{
|
||||
//planetary maps give an error when trying to change from position or rotation.
|
||||
//This is still the case, but it will be irrelevant after the https://github.com/space-wizards/space-station-14/pull/26510
|
||||
if (rotation != null && offset != null)
|
||||
{
|
||||
var pos = _transform.GetWorldPosition(grid);
|
||||
_transform.SetWorldPositionRotation(grid, pos + offset.Value, rotation.Value);
|
||||
continue;
|
||||
}
|
||||
if (rotation != null)
|
||||
{
|
||||
_transform.SetWorldRotation(grid, rotation.Value);
|
||||
continue;
|
||||
}
|
||||
if (offset != null)
|
||||
{
|
||||
var pos = _transform.GetWorldPosition(grid);
|
||||
_transform.SetWorldPosition(grid, pos + offset.Value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ev = new StationPostInitEvent((station, data));
|
||||
RaiseLocalEvent(station, ref ev, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user