]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Give silicons proper lobby/character editor previews (#33763)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Sun, 8 Dec 2024 01:46:41 +0000 (02:46 +0100)
committerGitHub <noreply@github.com>
Sun, 8 Dec 2024 01:46:41 +0000 (02:46 +0100)
* 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>
Content.Client/Lobby/LobbyUIController.cs
Content.Client/Lobby/UI/CharacterPickerButton.xaml
Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Content.Shared/Roles/JobPrototype.cs
Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Resources/Prototypes/Roles/Jobs/Science/borg.yml

index 50a25519988616aaa9a6d57106dda6a580a81ff4..56dc9d6d41232648bb5901a76917ed50f37efdda 100644 (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)))
index af1e640aadb652f06dd0855757ed3a5d7b7dc31b..2edfd19a24e8a355c15a378c2417f5e7a37e01da 100644 (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"
index 2f6c2d5aa2337033f89d0fa1e05db70ad0ede0d6..703b64bce3e185b65d9aaace5857e7bcbc53bf1f 100644 (file)
         </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" />
index 1ca1600e770d4f5104d678656c540d2b10e9470c..2a814f21a1ee63442896ae3a884e016d8396f13a 100644 (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";
 
index c16168120276d22715031a0d0e92958f4f9d597c..db9fb7899036d1ab7217471d0cc7e56029579afb 100644 (file)
           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
       rules: ghost-role-information-silicon-rules
       raffle:
         settings: default
-    - type: GhostTakeoverAvailable
\ No newline at end of file
+    - type: GhostTakeoverAvailable
index c62482d286eef7d544f655e0e457afbf381b923e..d85ed2a8bffd47351e249fa328235cdb2f668f34 100644 (file)
@@ -12,6 +12,7 @@
   icon: JobIconStationAi
   supervisors: job-supervisors-rd
   jobEntity: StationAiBrain
+  jobPreviewEntity: PlayerStationAiPreview
   applyTraits: false
 
 - type: job