Add CVar for random grid offset, disable it by default.
This commit is contained in:
@@ -21,14 +21,22 @@ namespace Content.Server.GameTicking
|
||||
[ViewVariables]
|
||||
public bool DisallowLateJoin { get; private set; } = false;
|
||||
|
||||
[ViewVariables]
|
||||
public bool StationOffset { get; private set; } = false;
|
||||
|
||||
[ViewVariables]
|
||||
public float MaxStationOffset { get; private set; } = 0f;
|
||||
|
||||
private void InitializeCVars()
|
||||
{
|
||||
_configurationManager.OnValueChanged(CCVars.GameLobbyEnabled, value => LobbyEnabled = value, true);
|
||||
_configurationManager.OnValueChanged(CCVars.GameDummyTicker, value => DummyTicker = value, true);
|
||||
_configurationManager.OnValueChanged(CCVars.GameMap, value => ChosenMap = value, true);
|
||||
_configurationManager.OnValueChanged(CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
|
||||
_configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins, invokeImmediately:true,
|
||||
onValueChanged:value => { DisallowLateJoin = value; UpdateLateJoinStatus(); UpdateJobsAvailable(); });
|
||||
_configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins,
|
||||
value => { DisallowLateJoin = value; UpdateLateJoinStatus(); UpdateJobsAvailable(); }, true);
|
||||
_configurationManager.OnValueChanged(CCVars.StationOffset, value => StationOffset = value, true);
|
||||
_configurationManager.OnValueChanged(CCVars.MaxStationOffset, value => MaxStationOffset = value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +63,13 @@ namespace Content.Server.GameTicking
|
||||
throw new InvalidOperationException($"No grid found for map {map}");
|
||||
}
|
||||
|
||||
var maxStationOffset = _configurationManager.GetCVar(CCVars.MaxStationOffset);
|
||||
var x = _robustRandom.NextFloat() * maxStationOffset * 2 - maxStationOffset;
|
||||
var y = _robustRandom.NextFloat() * maxStationOffset * 2 - maxStationOffset;
|
||||
_entityManager.GetEntity(grid.GridEntityId).Transform.LocalPosition = new Vector2(x, y);
|
||||
if (StationOffset)
|
||||
{
|
||||
// Apply a random offset to the station grid entity.
|
||||
var x = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
||||
var y = _robustRandom.NextFloat() * MaxStationOffset * 2 - MaxStationOffset;
|
||||
EntityManager.GetEntity(grid.GridEntityId).Transform.LocalPosition = new Vector2(x, y);
|
||||
}
|
||||
|
||||
DefaultGridId = grid.Index;
|
||||
_spawnPoint = grid.ToCoordinates();
|
||||
@@ -286,7 +289,7 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
|
||||
// Delete all entities.
|
||||
foreach (var entity in _entityManager.GetEntities().ToList())
|
||||
foreach (var entity in EntityManager.GetEntities().ToList())
|
||||
{
|
||||
// TODO: Maybe something less naive here?
|
||||
// FIXME: Actually, definitely.
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Content.Server.GameTicking
|
||||
private IEntity SpawnPlayerMob(Job job, HumanoidCharacterProfile? profile, bool lateJoin = true)
|
||||
{
|
||||
var coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
|
||||
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
||||
var entity = EntityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
||||
|
||||
if (job.StartingGear != null)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ namespace Content.Server.GameTicking
|
||||
private IEntity SpawnObserverMob()
|
||||
{
|
||||
var coordinates = GetObserverSpawnPoint();
|
||||
return _entityManager.SpawnEntity(ObserverPrototypeName, coordinates);
|
||||
return EntityManager.SpawnEntity(ObserverPrototypeName, coordinates);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Content.Server.GameTicking
|
||||
var equipmentStr = startingGear.GetGear(slot, profile);
|
||||
if (equipmentStr != string.Empty)
|
||||
{
|
||||
var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates);
|
||||
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates);
|
||||
inventory.Equip(slot, equipmentEntity.GetComponent<ItemComponent>());
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ namespace Content.Server.GameTicking
|
||||
var inhand = startingGear.Inhand;
|
||||
foreach (var (hand, prototype) in inhand)
|
||||
{
|
||||
var inhandEntity = _entityManager.SpawnEntity(prototype, entity.Transform.Coordinates);
|
||||
var inhandEntity = EntityManager.SpawnEntity(prototype, entity.Transform.Coordinates);
|
||||
handsComponent.TryPickupEntity(hand, inhandEntity, checkActionBlocker: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,6 @@ namespace Content.Server.GameTicking
|
||||
UpdateRoundFlow(frameTime);
|
||||
}
|
||||
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IMapLoader _mapLoader = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -55,6 +55,12 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<string>
|
||||
GameMap = CVarDef.Create("game.map", "Maps/saltern.yml", CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a random position offset will be applied to the station on roundstart.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> StationOffset =
|
||||
CVarDef.Create<bool>("game.station_offset", false);
|
||||
|
||||
/// <summary>
|
||||
/// When the default blueprint is loaded what is the maximum amount it can be offset from 0,0.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user