Adds species to HumanoidAppearanceComponent (#7445)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.CharacterAppearance;
|
using Content.Shared.CharacterAppearance;
|
||||||
using Content.Shared.CharacterAppearance.Systems;
|
using Content.Shared.CharacterAppearance.Systems;
|
||||||
|
using Content.Shared.Species;
|
||||||
using Robust.Shared.Analyzers;
|
using Robust.Shared.Analyzers;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -25,6 +26,9 @@ namespace Content.Shared.CharacterAppearance.Components
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public Gender Gender { get; set; } = default!;
|
public Gender Gender { get; set; } = default!;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public string Species { get; set; } = SpeciesManager.DefaultSpecies;
|
||||||
|
|
||||||
[DataField("categoriesHair")]
|
[DataField("categoriesHair")]
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public SpriteAccessoryCategories CategoriesHair { get; set; } = SpriteAccessoryCategories.HumanHair;
|
public SpriteAccessoryCategories CategoriesHair { get; set; } = SpriteAccessoryCategories.HumanHair;
|
||||||
@@ -56,14 +60,17 @@ namespace Content.Shared.CharacterAppearance.Components
|
|||||||
public HumanoidCharacterAppearance Appearance { get; }
|
public HumanoidCharacterAppearance Appearance { get; }
|
||||||
public Sex Sex { get; }
|
public Sex Sex { get; }
|
||||||
public Gender Gender { get; }
|
public Gender Gender { get; }
|
||||||
|
public string Species { get; }
|
||||||
|
|
||||||
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance,
|
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance,
|
||||||
Sex sex,
|
Sex sex,
|
||||||
Gender gender)
|
Gender gender,
|
||||||
|
string species)
|
||||||
{
|
{
|
||||||
Appearance = appearance;
|
Appearance = appearance;
|
||||||
Sex = sex;
|
Sex = sex;
|
||||||
Gender = gender;
|
Gender = gender;
|
||||||
|
Species = species;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Content.Shared.CharacterAppearance.Systems
|
|||||||
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile)
|
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile)
|
||||||
{
|
{
|
||||||
var humanoid = (HumanoidCharacterProfile) profile;
|
var humanoid = (HumanoidCharacterProfile) profile;
|
||||||
UpdateAppearance(uid, humanoid.Appearance, humanoid.Sex, humanoid.Gender);
|
UpdateAppearance(uid, humanoid.Appearance, humanoid.Sex, humanoid.Gender, humanoid.Species);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The magic mirror otherwise wouldn't work. (it directly modifies the component server-side)
|
// The magic mirror otherwise wouldn't work. (it directly modifies the component server-side)
|
||||||
@@ -31,25 +31,26 @@ namespace Content.Shared.CharacterAppearance.Systems
|
|||||||
component.Dirty();
|
component.Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAppearance(EntityUid uid, HumanoidCharacterAppearance appearance, Sex sex, Gender gender, HumanoidAppearanceComponent? component = null)
|
private void UpdateAppearance(EntityUid uid, HumanoidCharacterAppearance appearance, Sex sex, Gender gender, string species, HumanoidAppearanceComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component)) return;
|
if (!Resolve(uid, ref component)) return;
|
||||||
|
|
||||||
component.Appearance = appearance;
|
component.Appearance = appearance;
|
||||||
component.Sex = sex;
|
component.Sex = sex;
|
||||||
component.Gender = gender;
|
component.Gender = gender;
|
||||||
|
component.Species = species;
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(uid, out GrammarComponent? g))
|
if (EntityManager.TryGetComponent(uid, out GrammarComponent? g))
|
||||||
g.Gender = gender;
|
g.Gender = gender;
|
||||||
|
|
||||||
component.Dirty();
|
component.Dirty();
|
||||||
|
|
||||||
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(appearance, sex, gender));
|
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(appearance, sex, gender, species));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAppearanceGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
|
private void OnAppearanceGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
|
||||||
{
|
{
|
||||||
args.State = new HumanoidAppearanceComponentState(component.Appearance, component.Sex, component.Gender);
|
args.State = new HumanoidAppearanceComponentState(component.Appearance, component.Sex, component.Gender, component.Species);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAppearanceHandleState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentHandleState args)
|
private void OnAppearanceHandleState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentHandleState args)
|
||||||
@@ -57,7 +58,7 @@ namespace Content.Shared.CharacterAppearance.Systems
|
|||||||
if (args.Current is not HumanoidAppearanceComponentState state)
|
if (args.Current is not HumanoidAppearanceComponentState state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateAppearance(uid, state.Appearance, state.Sex, state.Gender);
|
UpdateAppearance(uid, state.Appearance, state.Sex, state.Gender, state.Species);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scaffolding until Body is moved to ECS.
|
// Scaffolding until Body is moved to ECS.
|
||||||
@@ -105,19 +106,22 @@ namespace Content.Shared.CharacterAppearance.Systems
|
|||||||
public HumanoidCharacterAppearance Appearance { get; }
|
public HumanoidCharacterAppearance Appearance { get; }
|
||||||
public Sex Sex { get; }
|
public Sex Sex { get; }
|
||||||
public Gender Gender { get; }
|
public Gender Gender { get; }
|
||||||
|
public string Species { get; }
|
||||||
|
|
||||||
public ChangedHumanoidAppearanceEvent(HumanoidCharacterProfile profile)
|
public ChangedHumanoidAppearanceEvent(HumanoidCharacterProfile profile)
|
||||||
{
|
{
|
||||||
Appearance = profile.Appearance;
|
Appearance = profile.Appearance;
|
||||||
Sex = profile.Sex;
|
Sex = profile.Sex;
|
||||||
Gender = profile.Gender;
|
Gender = profile.Gender;
|
||||||
|
Species = profile.Species;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangedHumanoidAppearanceEvent(HumanoidCharacterAppearance appearance, Sex sex, Gender gender)
|
public ChangedHumanoidAppearanceEvent(HumanoidCharacterAppearance appearance, Sex sex, Gender gender, string species)
|
||||||
{
|
{
|
||||||
Appearance = appearance;
|
Appearance = appearance;
|
||||||
Sex = sex;
|
Sex = sex;
|
||||||
Gender = gender;
|
Gender = gender;
|
||||||
|
Species = species;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user