Skip to content

Commit

Permalink
Give silicons proper lobby/character editor previews (space-wizards#3…
Browse files Browse the repository at this point in the history
…3763)

* Give silicons proper lobby/character editor previews

No more naked dummies, properly show a borg/AI sprite now.

This means taking the JobEntity into account when spawning the dummy. For AIs I had to add a "JobPreviewEntity" field because they'd look like a posibrain otherwise. AI therefore uses a custom dummy entity I defined.

Also I had to add some margins to the UI, because otherwise the 32x32 sprite of the AI would look bad.

* Update Content.Shared/Roles/JobPrototype.cs

* Update Content.Client/Lobby/LobbyUIController.cs

* Update Resources/Prototypes/Entities/Mobs/Player/silicon.yml

---------

Co-authored-by: slarticodefast <[email protected]>
  • Loading branch information
PJB3005 and slarticodefast authored Dec 8, 2024
1 parent 3d53e74 commit 299b13f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
19 changes: 17 additions & 2 deletions Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,21 @@ public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, JobProtot
{
EntityUid dummyEnt;

if (humanoid is not null)
EntProtoId? previewEntity = null;
if (humanoid != null && jobClothes)
{
job ??= GetPreferredJob(humanoid);

previewEntity = job.JobPreviewEntity ?? (EntProtoId?)job?.JobEntity;
}

if (previewEntity != null)
{
// Special type like borg or AI, do not spawn a human just spawn the entity.
dummyEnt = EntityManager.SpawnEntity(previewEntity, MapCoordinates.Nullspace);
return dummyEnt;
}
else if (humanoid is not null)
{
var dummy = _prototypeManager.Index<SpeciesPrototype>(humanoid.Species).DollPrototype;
dummyEnt = EntityManager.SpawnEntity(dummy, MapCoordinates.Nullspace);
Expand All @@ -469,7 +483,8 @@ public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, JobProtot

if (humanoid != null && jobClothes)
{
job ??= GetPreferredJob(humanoid);
DebugTools.Assert(job != null);

GiveDummyJobClothes(dummyEnt, humanoid, job);

if (_prototypeManager.HasIndex<RoleLoadoutPrototype>(LoadoutSystem.GetJobPrototype(job.ID)))
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Lobby/UI/CharacterPickerButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
SeparationOverride="0"
Name="InternalHBox">
<SpriteView Scale="2 2"
Margin="0 4 4 4"
OverrideDirection="South"
Name="View"/>
<Label Name="DescriptionLabel"
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
</BoxContainer>
<!-- Right side -->
<BoxContainer Orientation="Vertical" VerticalExpand="True" VerticalAlignment="Center">
<SpriteView Name="SpriteView" Scale="8 8" SizeFlagsStretchRatio="1" />
<SpriteView Name="SpriteView" Scale="8 8" Margin="4" SizeFlagsStretchRatio="1" />
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 5">
<Button Name="SpriteRotateLeft" Text="" StyleClasses="OpenRight" />
<cc:VSeparator Margin="2 0 3 0" />
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public sealed partial class JobPrototype : IPrototype
[DataField("jobEntity", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? JobEntity = null;

/// <summary>
/// Entity to use as a preview in the lobby/character editor.
/// Same restrictions as <see cref="JobEntity"/> apply.
/// </summary>
[DataField]
public EntProtoId? JobPreviewEntity = null;

[DataField]
public ProtoId<JobIconPrototype> Icon { get; private set; } = "JobIconUnknown";

Expand Down
13 changes: 12 additions & 1 deletion Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,17 @@
Occupied: { state: full }
- type: Intellicard

- type: entity
id: PlayerStationAiPreview
categories: [ HideSpawnMenu ]
components:
- type: Sprite
sprite: Mobs/Silicon/station_ai.rsi
layers:
- state: base
- state: ai
shader: unshaded

- type: entity
id: PlayerStationAiEmpty
name: AI Core
Expand Down Expand Up @@ -559,4 +570,4 @@
rules: ghost-role-information-silicon-rules
raffle:
settings: default
- type: GhostTakeoverAvailable
- type: GhostTakeoverAvailable
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Science/borg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
icon: JobIconStationAi
supervisors: job-supervisors-rd
jobEntity: StationAiBrain
jobPreviewEntity: PlayerStationAiPreview
applyTraits: false

- type: job
Expand Down

0 comments on commit 299b13f

Please sign in to comment.