Skip to content

Commit

Permalink
Revert "Rotate and Offset station CCVar nuke (space-wizards#26175)"
Browse files Browse the repository at this point in the history
This reverts commit 44b20f6.

# Conflicts:
#	Content.Server/Station/Systems/StationSystem.cs
#	Resources/Prototypes/Maps/europa.yml
  • Loading branch information
metalgearsloth committed Jun 18, 2024
1 parent 14cd55e commit 850e1aa
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 71 deletions.

This file was deleted.

63 changes: 20 additions & 43 deletions Content.Server/Station/Systems/StationSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
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.Fax;
using Content.Shared.CCVar;
using Content.Shared.Station;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
Expand Down Expand Up @@ -44,12 +43,17 @@ public override void Initialize()
_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;
}

Expand Down Expand Up @@ -102,6 +106,19 @@ private void OnStationDeleted(EntityUid uid, StationDataComponent component, Com
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>>();
Expand Down Expand Up @@ -282,51 +299,11 @@ public EntityUid InitializeNewStation(StationConfig stationConfig, IEnumerable<E
var data = Comp<StationDataComponent>(station);
name ??= MetaData(station).EntityName;

var entry = gridIds ?? Array.Empty<EntityUid>();

foreach (var grid in entry)
foreach (var grid in gridIds ?? Array.Empty<EntityUid>())
{
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;
}
}
}

if (LifeStage(station) < EntityLifeStage.MapInitialized)
throw new Exception($"Station must be man-initialized");

var ev = new StationPostInitEvent((station, data));
RaiseLocalEvent(station, ref ev, true);

Expand Down
19 changes: 19 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,25 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool>
GameCryoSleepRejoining = CVarDef.Create("game.cryo_sleep_rejoining", false, CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Whether a random position offset will be applied to the station on roundstart.
/// </summary>
public static readonly CVarDef<bool> StationOffset =
CVarDef.Create("game.station_offset", true);

/// <summary>
/// When the default blueprint is loaded what is the maximum amount it can be offset from 0,0.
/// Does nothing without <see cref="StationOffset"/> as true.
/// </summary>
public static readonly CVarDef<float> MaxStationOffset =
CVarDef.Create("game.maxstationoffset", 1000.0f);

/// <summary>
/// Whether a random rotation will be applied to the station on roundstart.
/// </summary>
public static readonly CVarDef<bool> StationRotation =
CVarDef.Create("game.station_rotation", true);

/// <summary>
/// When enabled, guests will be assigned permanent UIDs and will have their preferences stored.
/// </summary>
Expand Down
6 changes: 0 additions & 6 deletions Resources/Prototypes/Entities/Stations/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
components:
- type: StationData

- type: entity
id: BaseRandomStation
abstract: true
components:
- type: StationRandomTransform

- type: entity
id: BaseStationCargo
abstract: true
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Stations/nanotrasen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
- BaseStationSiliconLawCrewsimov
- BaseStationAllEventsEligible
- BaseStationNanotrasen
- BaseRandomStation
noSpawn: true
components:
- type: Transform
Expand Down
3 changes: 0 additions & 3 deletions Resources/Prototypes/Maps/europa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
components:
- type: StationBiome
biome: Snow
- type: StationRandomTransform
enableStationRotation: false
maxStationOffset: null
- type: StationNameSetup
mapNameTemplate: '{0} Europa {1}'
nameGenerator:
Expand Down
2 changes: 0 additions & 2 deletions Resources/Prototypes/Maps/train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Train:
stationProto: StandardNanotrasenStation
components:
- type: StationRandomTransform
enableStationRotation: false
- type: StationNameSetup
mapNameTemplate: 'Train "Sentipode" {0}-{1}'
nameGenerator:
Expand Down

0 comments on commit 850e1aa

Please sign in to comment.