using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
using Content.Server.Station.Components;
+using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Shared.GameTicking;
+using Content.Shared.Humanoid;
+using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Mind;
using Content.Shared.Players;
using Content.Shared.Preferences;
+using Content.Shared.Random;
+using Content.Shared.Random.Helpers;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Map;
return;
}
+ string speciesId;
+ if (_randomizeCharacters)
+ {
+ var weightId = _cfg.GetCVar(CCVars.ICRandomSpeciesWeights);
+
+ // If blank, choose a round start species.
+ if (string.IsNullOrEmpty(weightId))
+ {
+ var roundStart = new List<ProtoId<SpeciesPrototype>>();
+
+ var speciesPrototypes = _prototypeManager.EnumeratePrototypes<SpeciesPrototype>();
+ foreach (var proto in speciesPrototypes)
+ {
+ if (proto.RoundStart)
+ roundStart.Add(proto.ID);
+ }
+
+ speciesId = roundStart.Count == 0
+ ? SharedHumanoidAppearanceSystem.DefaultSpecies
+ : _robustRandom.Pick(roundStart);
+ }
+ else
+ {
+ var weights = _prototypeManager.Index<WeightedRandomSpeciesPrototype>(weightId);
+ speciesId = weights.Pick(_robustRandom);
+ }
+
+ character = HumanoidCharacterProfile.RandomWithSpecies(speciesId);
+ }
+
// We raise this event to allow other systems to handle spawning this player themselves. (e.g. late-join wizard, etc)
var bev = new PlayerBeforeSpawnEvent(player, character, jobId, lateJoin, station);
RaiseLocalEvent(bev);
using Content.Server.Preferences.Managers;
using Content.Server.ServerUpdates;
using Content.Server.Station.Systems;
+using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.GameTicking;
using Content.Shared.Mind;
private ISawmill _sawmill = default!;
+ private bool _randomizeCharacters;
+
public override void Initialize()
{
base.Initialize();
_sawmill = _logManager.GetSawmill("ticker");
_sawmillReplays = _logManager.GetSawmill("ticker.replays");
+ Subs.CVar(_cfg, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
+
// Initialize the other parts of the game ticker.
InitializeStatusShell();
InitializeCVars();
using Content.Shared.PDA;
using Content.Shared.Preferences;
using Content.Shared.Preferences.Loadouts;
-using Content.Shared.Random;
-using Content.Shared.Random.Helpers;
using Content.Shared.Roles;
using Content.Shared.Station;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
-using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Station.Systems;
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
[Dependency] private readonly PdaSystem _pdaSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- [Dependency] private readonly IRobustRandom _random = default!;
-
- private bool _randomizeCharacters;
-
- /// <inheritdoc/>
- public override void Initialize()
- {
- base.Initialize();
- Subs.CVar(_configurationManager, CCVars.ICRandomCharacters, e => _randomizeCharacters = e, true);
- }
/// <summary>
/// Attempts to spawn a player character onto the given station.
return jobEntity;
}
- string speciesId;
- if (_randomizeCharacters)
- {
- var weightId = _configurationManager.GetCVar(CCVars.ICRandomSpeciesWeights);
-
- // If blank, choose a round start species.
- if (string.IsNullOrEmpty(weightId))
- {
- var roundStart = new List<ProtoId<SpeciesPrototype>>();
-
- var speciesPrototypes = _prototypeManager.EnumeratePrototypes<SpeciesPrototype>();
- foreach (var proto in speciesPrototypes)
- {
- if (proto.RoundStart)
- roundStart.Add(proto.ID);
- }
-
- if (roundStart.Count == 0)
- speciesId = SharedHumanoidAppearanceSystem.DefaultSpecies;
- else
- speciesId = _random.Pick(roundStart);
- }
- else
- {
- var weights = _prototypeManager.Index<WeightedRandomSpeciesPrototype>(weightId);
- speciesId = weights.Pick(_random);
- }
- }
- else if (profile != null)
- {
- speciesId = profile.Species;
- }
- else
- {
- speciesId = SharedHumanoidAppearanceSystem.DefaultSpecies;
- }
+ string speciesId = profile != null ? profile.Species : SharedHumanoidAppearanceSystem.DefaultSpecies;
if (!_prototypeManager.TryIndex<SpeciesPrototype>(speciesId, out var species))
throw new ArgumentException($"Invalid species prototype was used: {speciesId}");
entity ??= Spawn(species.Prototype, coordinates);
- if (_randomizeCharacters)
- {
- profile = HumanoidCharacterProfile.RandomWithSpecies(speciesId);
- }
-
if (profile != null)
{
_humanoidSystem.LoadProfile(entity.Value, profile);