Clothing and pronoun fields (#2689)
* Clothing & Gender fields: Add to database [MODIFIED TO NOT DEPEND ON SAPHIRE-DB-REFACTOR] Sorry about this, Saphire. * Clothing & Gender fields: Add UI [FALLBACK II] * Clothing & Gender fields: Actually apply gender * Clothing & Gender fields: Import innerclothingskirt field from my previous attempt Couldn't import actual prototypes because of a change to IDs * Clothing & Gender fields: Add innerclothingskirt field to everything * Clothing & Gender fields: Jumpskirts now work * Clothing & Gender fields: Gender field will follow sex field if it's not different (UX improvement) [FALLBACK II] * Clothing & Gender fields: Gender -> Pronouns to reduce confusion. Also, fix profile summary. Properly. [FALLBACK II] * Clothing & Pronoun fields: Refactor so that profile equipment adjustments are performed in StartingGearPrototype.
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Shared.Preferences;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Localization.Macros;
|
||||
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
@@ -130,10 +131,24 @@ namespace Content.Server.Database
|
||||
{
|
||||
var jobs = profile.Jobs.ToDictionary(j => j.JobName, j => (JobPriority) j.Priority);
|
||||
var antags = profile.Antags.Select(a => a.AntagName);
|
||||
|
||||
var sex = Sex.Male;
|
||||
if (Enum.TryParse<Sex>(profile.Sex, true, out var sexVal))
|
||||
sex = sexVal;
|
||||
|
||||
var clothing = ClothingPreference.Jumpsuit;
|
||||
if (Enum.TryParse<ClothingPreference>(profile.Clothing, true, out var clothingVal))
|
||||
clothing = clothingVal;
|
||||
|
||||
var gender = sex == Sex.Male ? Gender.Male : Gender.Female;
|
||||
if (Enum.TryParse<Gender>(profile.Gender, true, out var genderVal))
|
||||
gender = genderVal;
|
||||
|
||||
return new HumanoidCharacterProfile(
|
||||
profile.CharacterName,
|
||||
profile.Age,
|
||||
profile.Sex == "Male" ? Sex.Male : Sex.Female,
|
||||
sex,
|
||||
gender,
|
||||
new HumanoidCharacterAppearance
|
||||
(
|
||||
profile.HairName,
|
||||
@@ -143,6 +158,7 @@ namespace Content.Server.Database
|
||||
Color.FromHex(profile.EyeColor),
|
||||
Color.FromHex(profile.SkinColor)
|
||||
),
|
||||
clothing,
|
||||
jobs,
|
||||
(PreferenceUnavailableMode) profile.PreferenceUnavailable,
|
||||
antags.ToList()
|
||||
@@ -158,12 +174,14 @@ namespace Content.Server.Database
|
||||
CharacterName = humanoid.Name,
|
||||
Age = humanoid.Age,
|
||||
Sex = humanoid.Sex.ToString(),
|
||||
Gender = humanoid.Gender.ToString(),
|
||||
HairName = appearance.HairStyleName,
|
||||
HairColor = appearance.HairColor.ToHex(),
|
||||
FacialHairName = appearance.FacialHairStyleName,
|
||||
FacialHairColor = appearance.FacialHairColor.ToHex(),
|
||||
EyeColor = appearance.EyeColor.ToHex(),
|
||||
SkinColor = appearance.SkinColor.ToHex(),
|
||||
Clothing = humanoid.Clothing.ToString(),
|
||||
Slot = slot,
|
||||
PreferenceUnavailable = (DbPreferenceUnavailableMode) humanoid.PreferenceUnavailable
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@ using Content.Server.GameObjects.EntitySystems.AI;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Server.AI;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -68,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
if (StartingGearPrototype != null)
|
||||
{
|
||||
var startingGear = _prototypeManager.Index<StartingGearPrototype>(StartingGearPrototype);
|
||||
_gameTicker.EquipStartingGear(Owner, startingGear);
|
||||
_gameTicker.EquipStartingGear(Owner, startingGear, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -577,26 +577,34 @@ namespace Content.Server.GameTicking
|
||||
return Paused;
|
||||
}
|
||||
|
||||
private IEntity _spawnPlayerMob(Job job, bool lateJoin = true)
|
||||
private IEntity _spawnPlayerMob(Job job, HumanoidCharacterProfile profile, bool lateJoin = true)
|
||||
{
|
||||
EntityCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
|
||||
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
||||
var startingGear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear);
|
||||
EquipStartingGear(entity, startingGear);
|
||||
EquipStartingGear(entity, startingGear, profile);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
entity.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(profile);
|
||||
entity.Name = profile.Name;
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear)
|
||||
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear, HumanoidCharacterProfile profile)
|
||||
{
|
||||
if (entity.TryGetComponent(out InventoryComponent inventory))
|
||||
{
|
||||
var gear = startingGear.Equipment;
|
||||
|
||||
foreach (var (slot, equipmentStr) in gear)
|
||||
foreach (var slot in AllSlots)
|
||||
{
|
||||
var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates);
|
||||
inventory.Equip(slot, equipmentEntity.GetComponent<ItemComponent>());
|
||||
var equipmentStr = startingGear.GetGear(slot, profile);
|
||||
if (equipmentStr != "")
|
||||
{
|
||||
var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates);
|
||||
inventory.Equip(slot, equipmentEntity.GetComponent<ItemComponent>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,14 +619,6 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyCharacterProfile(IEntity entity, ICharacterProfile profile)
|
||||
{
|
||||
if (profile is null)
|
||||
return;
|
||||
entity.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(profile);
|
||||
entity.Name = profile.Name;
|
||||
}
|
||||
|
||||
private IEntity _spawnObserverMob()
|
||||
{
|
||||
var coordinates = GetObserverSpawnPoint();
|
||||
@@ -888,9 +888,8 @@ namespace Content.Server.GameTicking
|
||||
var job = new Job(data.Mind, jobPrototype);
|
||||
data.Mind.AddRole(job);
|
||||
|
||||
var mob = _spawnPlayerMob(job, lateJoin);
|
||||
var mob = _spawnPlayerMob(job, character, lateJoin);
|
||||
data.Mind.TransferTo(mob);
|
||||
ApplyCharacterProfile(mob, character);
|
||||
|
||||
if (session.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}"))
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Server.Interfaces.Console;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
@@ -51,7 +52,7 @@ namespace Content.Server.Interfaces.GameTicking
|
||||
EntityCoordinates GetJobSpawnPoint(string jobId);
|
||||
EntityCoordinates GetObserverSpawnPoint();
|
||||
|
||||
void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear);
|
||||
void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear, HumanoidCharacterProfile profile);
|
||||
|
||||
// GameRule system.
|
||||
T AddGameRule<T>() where T : GameRule, new();
|
||||
|
||||
Reference in New Issue
Block a user