mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> # Conflicts: # Content.Server/Humanoid/Components/RandomHumanoidAppearanceComponent.cs # Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs # Conflicts: # Resources/Prototypes/Species/diona.yml # Conflicts: # Content.Server/Zombies/ZombieSystem.Transform.cs
67 lines
2.6 KiB
C#
67 lines
2.6 KiB
C#
using Content.Server.Humanoid.Components;
|
|
using Content.Server.RandomMetadata;
|
|
using Content.Shared.Body;
|
|
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Preferences;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager;
|
|
|
|
namespace Content.Server.Humanoid.Systems;
|
|
|
|
/// <summary>
|
|
/// This deals with spawning and setting up random humanoids.
|
|
/// </summary>
|
|
public sealed class RandomHumanoidSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly HumanoidProfileSystem _humanoidProfile = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly ISerializationManager _serialization = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
[Dependency] private readonly SharedVisualBodySystem _visualBody = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<RandomHumanoidSpawnerComponent, MapInitEvent>(OnMapInit,
|
|
after: new []{ typeof(RandomMetadataSystem) });
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, RandomHumanoidSpawnerComponent component, MapInitEvent args)
|
|
{
|
|
QueueDel(uid);
|
|
if (component.SettingsPrototypeId != null)
|
|
SpawnRandomHumanoid(component.SettingsPrototypeId, Transform(uid).Coordinates, MetaData(uid).EntityName);
|
|
}
|
|
|
|
public EntityUid SpawnRandomHumanoid(string prototypeId, EntityCoordinates coordinates, string name)
|
|
{
|
|
if (!_prototypeManager.TryIndex<RandomHumanoidSettingsPrototype>(prototypeId, out var prototype))
|
|
throw new ArgumentException("Could not get random humanoid settings");
|
|
|
|
var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist);
|
|
var speciesProto = _prototypeManager.Index<SpeciesPrototype>(profile.Species);
|
|
var humanoid = EntityManager.CreateEntityUninitialized(speciesProto.Prototype, coordinates);
|
|
|
|
_metaData.SetEntityName(humanoid, prototype.RandomizeName ? profile.Name : name);
|
|
|
|
if (prototype.Components != null)
|
|
{
|
|
foreach (var entry in prototype.Components.Values)
|
|
{
|
|
var comp = (Component)_serialization.CreateCopy(entry.Component, notNullableOverride: true);
|
|
RemComp(humanoid, comp.GetType());
|
|
AddComp(humanoid, comp);
|
|
}
|
|
}
|
|
|
|
EntityManager.InitializeAndStartEntity(humanoid);
|
|
|
|
_visualBody.ApplyProfileTo(humanoid, profile);
|
|
_humanoidProfile.ApplyProfileTo(humanoid, profile);
|
|
|
|
return humanoid;
|
|
}
|
|
}
|