Skip to content

Commit

Permalink
fix editor dummy always being human
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Jul 23, 2024
1 parent fe84704 commit f28bbb3
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Client.Preferences.UI;
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Content.Shared.Roles;
Expand Down Expand Up @@ -98,41 +99,50 @@ public void UpdateCharacterUI()
return;
}

if (_previewDummy == null)
var maybeProfile = _profileEditor?.Profile ?? (HumanoidCharacterProfile) _preferencesManager.Preferences!.SelectedCharacter;

if (_previewDummy == null
|| maybeProfile.Species != EntityManager.GetComponent<HumanoidAppearanceComponent>(_previewDummy.Value).Species)
{
_previewDummy =
EntityManager.SpawnEntity(
_prototypeManager.Index<SpeciesPrototype>(HumanoidCharacterProfile.DefaultWithSpecies().Species)
.DollPrototype, MapCoordinates.Nullspace);
_previewPanel?.SetSprite(_previewDummy.Value);
RespawnDummy(maybeProfile);
_previewPanel?.SetSprite(_previewDummy!.Value);
}

_previewPanel?.SetLoaded(true);

if (_preferencesManager.Preferences?.SelectedCharacter is not HumanoidCharacterProfile selectedCharacter)
_previewPanel?.SetSummaryText(string.Empty);
else if (_previewDummy != null)
if (_previewDummy == null)
return;

_previewPanel?.SetSummaryText(maybeProfile.Summary);
_humanoid.LoadProfile(_previewDummy.Value, maybeProfile);


if (UpdateClothes)
{
var maybeProfile = _profileEditor?.Profile ?? selectedCharacter;
_previewPanel?.SetSummaryText(maybeProfile.Summary);
_humanoid.LoadProfile(_previewDummy.Value, maybeProfile);


if (UpdateClothes)
{
RemoveDummyClothes(_previewDummy.Value);
if (ShowClothes)
GiveDummyJobClothes(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
if (ShowLoadouts)
GiveDummyLoadouts(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
UpdateClothes = false;
}

PreviewDummyUpdated?.Invoke(_previewDummy.Value);
RemoveDummyClothes(_previewDummy.Value);
if (ShowClothes)
GiveDummyJobClothes(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
if (ShowLoadouts)
GiveDummyLoadouts(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile);
UpdateClothes = false;
}

PreviewDummyUpdated?.Invoke(_previewDummy.Value);
}


public void RespawnDummy(HumanoidCharacterProfile profile)
{
if (_previewDummy != null)
RemoveDummyClothes(_previewDummy.Value);

EntityManager.DeleteEntity(_previewDummy);
_previewDummy = EntityManager.SpawnEntity(
_prototypeManager.Index<SpeciesPrototype>(profile.Species).DollPrototype, MapCoordinates.Nullspace);

UpdateClothes = true;
}

/// <summary>
/// Gets the highest priority job for the profile.
/// </summary>
Expand Down

0 comments on commit f28bbb3

Please sign in to comment.