added Character Setup (#511)

* added Character Setup

* whoops

* reverted unrelated changes

* Made everything work post-rebase

* Removed unused PreferencesChanged event

* nope, don't need this

* HumanoidProfileEditorPanel -> HumanoidProfileEditor

* Set initial data for hair pickers

* Fixed nullable warning

* Renamed LooksComponent -> HumanoidAppearanceComponent

* Renamed LooksComponentState -> HumanoidAppearanceComponentState

* Final renaming maybe

* Use a human-like dummy instead of a real human

* Change preferences structs back to classes
This commit is contained in:
DamianX
2020-01-18 01:54:13 +01:00
committed by Pieter-Jan Briers
parent d03da83fda
commit a4e369e629
41 changed files with 1423 additions and 756 deletions

View File

@@ -0,0 +1,73 @@
using System;
using Content.Shared.Preferences;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Mobs
{
public abstract class SharedHumanoidAppearanceComponent : Component
{
private HumanoidCharacterAppearance _appearance;
private Sex _sex;
public sealed override string Name => "HumanoidAppearance";
public sealed override uint? NetID => ContentNetIDs.HUMANOID_APPEARANCE;
public sealed override Type StateType => typeof(HumanoidAppearanceComponentState);
[ViewVariables(VVAccess.ReadWrite)]
public virtual HumanoidCharacterAppearance Appearance
{
get => _appearance;
set
{
_appearance = value;
Dirty();
}
}
[ViewVariables(VVAccess.ReadWrite)]
public virtual Sex Sex
{
get => _sex;
set
{
_sex = value;
Dirty();
}
}
public override ComponentState GetComponentState()
{
return new HumanoidAppearanceComponentState(Appearance, Sex);
}
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
var cast = (HumanoidAppearanceComponentState) curState;
Appearance = cast.Appearance;
Sex = cast.Sex;
}
public void UpdateFromProfile(ICharacterProfile profile)
{
var humanoid = (HumanoidCharacterProfile) profile;
Appearance = (HumanoidCharacterAppearance) humanoid.CharacterAppearance;
Sex = humanoid.Sex;
}
[Serializable]
[NetSerializable]
private sealed class HumanoidAppearanceComponentState : ComponentState
{
public HumanoidAppearanceComponentState(HumanoidCharacterAppearance appearance, Sex sex) : base(ContentNetIDs.HUMANOID_APPEARANCE)
{
Appearance = appearance;
Sex = sex;
}
public HumanoidCharacterAppearance Appearance { get; }
public Sex Sex { get; }
}
}
}