Replace StationRandomTransform (#29149)
* Revert "Rotate and Offset station CCVar nuke (#26175)"
This reverts commit 44b20f60ff.
# Conflicts:
# Content.Server/Station/Systems/StationSystem.cs
# Resources/Prototypes/Maps/europa.yml
* Fix
* Review
This commit is contained in:
@@ -160,6 +160,12 @@ namespace Content.Server.GameTicking
|
|||||||
// whereas the command can also be used on an existing map.
|
// whereas the command can also be used on an existing map.
|
||||||
var loadOpts = loadOptions ?? new MapLoadOptions();
|
var loadOpts = loadOptions ?? new MapLoadOptions();
|
||||||
|
|
||||||
|
if (map.MaxRandomOffset != 0f)
|
||||||
|
loadOpts.Offset = _robustRandom.NextVector2(map.MaxRandomOffset);
|
||||||
|
|
||||||
|
if (map.RandomRotation)
|
||||||
|
loadOpts.Rotation = _robustRandom.NextAngle();
|
||||||
|
|
||||||
var ev = new PreGameMapLoad(targetMapId, map, loadOpts);
|
var ev = new PreGameMapLoad(targetMapId, map, loadOpts);
|
||||||
RaiseLocalEvent(ev);
|
RaiseLocalEvent(ev);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Content.Server.Maps;
|
namespace Content.Server.Maps;
|
||||||
|
|
||||||
@@ -21,16 +22,22 @@ public sealed partial class GameMapPrototype : IPrototype
|
|||||||
[IdDataField]
|
[IdDataField]
|
||||||
public string ID { get; private set; } = default!;
|
public string ID { get; private set; } = default!;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public float MaxRandomOffset = 1000f;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool RandomRotation = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the map to use in generic messages, like the map vote.
|
/// Name of the map to use in generic messages, like the map vote.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("mapName", required: true)]
|
[DataField(required: true)]
|
||||||
public string MapName { get; private set; } = default!;
|
public string MapName { get; private set; } = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Relative directory path to the given map, i.e. `/Maps/saltern.yml`
|
/// Relative directory path to the given map, i.e. `/Maps/saltern.yml`
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("mapPath", required: true)]
|
[DataField(required: true)]
|
||||||
public ResPath MapPath { get; private set; } = default!;
|
public ResPath MapPath { get; private set; } = default!;
|
||||||
|
|
||||||
[DataField("stations", required: true)]
|
[DataField("stations", required: true)]
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
using Content.Server.Station.Systems;
|
|
||||||
|
|
||||||
namespace Content.Server.Station.Components;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stores station parameters that can be randomized by the roundstart
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent, Access(typeof(StationSystem))]
|
|
||||||
public sealed partial class StationRandomTransformComponent : Component
|
|
||||||
{
|
|
||||||
[DataField]
|
|
||||||
public float? MaxStationOffset = 100.0f;
|
|
||||||
|
|
||||||
[DataField]
|
|
||||||
public bool EnableStationRotation = true;
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Station.Components;
|
using Content.Server.Station.Components;
|
||||||
using Content.Server.Station.Events;
|
using Content.Server.Station.Events;
|
||||||
using Content.Shared.Fax;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Station;
|
using Content.Shared.Station;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -28,10 +27,12 @@ namespace Content.Server.Station.Systems;
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public sealed class StationSystem : EntitySystem
|
public sealed class StationSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||||
[Dependency] private readonly ILogManager _logManager = default!;
|
[Dependency] private readonly ILogManager _logManager = default!;
|
||||||
[Dependency] private readonly IPlayerManager _player = default!;
|
[Dependency] private readonly IPlayerManager _player = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||||
|
[Dependency] private readonly GameTicker _ticker = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||||
[Dependency] private readonly MapSystem _map = default!;
|
[Dependency] private readonly MapSystem _map = default!;
|
||||||
@@ -282,51 +283,11 @@ public sealed class StationSystem : EntitySystem
|
|||||||
var data = Comp<StationDataComponent>(station);
|
var data = Comp<StationDataComponent>(station);
|
||||||
name ??= MetaData(station).EntityName;
|
name ??= MetaData(station).EntityName;
|
||||||
|
|
||||||
var entry = gridIds ?? Array.Empty<EntityUid>();
|
foreach (var grid in gridIds ?? Array.Empty<EntityUid>())
|
||||||
|
|
||||||
foreach (var grid in entry)
|
|
||||||
{
|
{
|
||||||
AddGridToStation(station, grid, null, data, name);
|
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));
|
var ev = new StationPostInitEvent((station, data));
|
||||||
RaiseLocalEvent(station, ref ev, true);
|
RaiseLocalEvent(station, ref ev, true);
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: StationData
|
- type: StationData
|
||||||
|
|
||||||
- type: entity
|
|
||||||
id: BaseRandomStation
|
|
||||||
abstract: true
|
|
||||||
components:
|
|
||||||
- type: StationRandomTransform
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: BaseStationCargo
|
id: BaseStationCargo
|
||||||
abstract: true
|
abstract: true
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
- BaseStationSiliconLawCrewsimov
|
- BaseStationSiliconLawCrewsimov
|
||||||
- BaseStationAllEventsEligible
|
- BaseStationAllEventsEligible
|
||||||
- BaseStationNanotrasen
|
- BaseStationNanotrasen
|
||||||
- BaseRandomStation
|
|
||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: Transform
|
- type: Transform
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
id: Europa
|
id: Europa
|
||||||
mapName: 'Europa'
|
mapName: 'Europa'
|
||||||
mapPath: /Maps/europa.yml
|
mapPath: /Maps/europa.yml
|
||||||
|
maxRandomOffset: 0
|
||||||
|
randomRotation: false
|
||||||
minPlayers: 0
|
minPlayers: 0
|
||||||
maxPlayers: 40
|
maxPlayers: 40
|
||||||
stations:
|
stations:
|
||||||
@@ -10,9 +12,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: StationBiome
|
- type: StationBiome
|
||||||
biome: Snow
|
biome: Snow
|
||||||
- type: StationRandomTransform
|
|
||||||
enableStationRotation: false
|
|
||||||
maxStationOffset: null
|
|
||||||
- type: StationNameSetup
|
- type: StationNameSetup
|
||||||
mapNameTemplate: '{0} Europa {1}'
|
mapNameTemplate: '{0} Europa {1}'
|
||||||
nameGenerator:
|
nameGenerator:
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
id: Train
|
id: Train
|
||||||
mapName: 'Train'
|
mapName: 'Train'
|
||||||
mapPath: /Maps/train.yml
|
mapPath: /Maps/train.yml
|
||||||
|
maxRandomOffset: 0
|
||||||
|
randomRotation: false
|
||||||
minPlayers: 10
|
minPlayers: 10
|
||||||
maxPlayers: 50
|
maxPlayers: 50
|
||||||
stations:
|
stations:
|
||||||
Train:
|
Train:
|
||||||
stationProto: StandardNanotrasenStation
|
stationProto: StandardNanotrasenStation
|
||||||
components:
|
components:
|
||||||
- type: StationRandomTransform
|
|
||||||
enableStationRotation: false
|
|
||||||
- type: StationNameSetup
|
- type: StationNameSetup
|
||||||
mapNameTemplate: 'Train "Sentipode" {0}-{1}'
|
mapNameTemplate: 'Train "Sentipode" {0}-{1}'
|
||||||
nameGenerator:
|
nameGenerator:
|
||||||
|
|||||||
Reference in New Issue
Block a user