Give silicons proper lobby/character editor previews (#33763)

* 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 <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2024-12-08 02:46:41 +01:00
committed by GitHub
parent 3d53e748fa
commit 299b13f21b
6 changed files with 39 additions and 4 deletions

View File

@@ -455,7 +455,21 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
{
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);
@@ -469,7 +483,8 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
if (humanoid != null && jobClothes)
{
job ??= GetPreferredJob(humanoid);
DebugTools.Assert(job != null);
GiveDummyJobClothes(dummyEnt, humanoid, job);
if (_prototypeManager.HasIndex<RoleLoadoutPrototype>(LoadoutSystem.GetJobPrototype(job.ID)))

View File

@@ -6,6 +6,7 @@
SeparationOverride="0"
Name="InternalHBox">
<SpriteView Scale="2 2"
Margin="0 4 4 4"
OverrideDirection="South"
Name="View"/>
<Label Name="DescriptionLabel"

View File

@@ -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" />

View File

@@ -119,6 +119,13 @@ namespace Content.Shared.Roles
[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";

View File

@@ -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
@@ -559,4 +570,4 @@
rules: ghost-role-information-silicon-rules
raffle:
settings: default
- type: GhostTakeoverAvailable
- type: GhostTakeoverAvailable

View File

@@ -12,6 +12,7 @@
icon: JobIconStationAi
supervisors: job-supervisors-rd
jobEntity: StationAiBrain
jobPreviewEntity: PlayerStationAiPreview
applyTraits: false
- type: job