Basic implementation of jobs in the character profile.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Preferences
|
||||
@@ -6,20 +8,34 @@ namespace Content.Shared.Preferences
|
||||
[Serializable, NetSerializable]
|
||||
public class HumanoidCharacterProfile : ICharacterProfile
|
||||
{
|
||||
public HumanoidCharacterProfile(string name,
|
||||
private readonly Dictionary<string, JobPriority> _jobPriorities;
|
||||
|
||||
private HumanoidCharacterProfile(string name,
|
||||
int age,
|
||||
Sex sex,
|
||||
HumanoidCharacterAppearance appearance)
|
||||
HumanoidCharacterAppearance appearance,
|
||||
Dictionary<string, JobPriority> jobPriorities)
|
||||
{
|
||||
Name = name;
|
||||
Age = age;
|
||||
Sex = sex;
|
||||
Appearance = appearance;
|
||||
_jobPriorities = jobPriorities;
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile(string name,
|
||||
int age,
|
||||
Sex sex,
|
||||
HumanoidCharacterAppearance appearance,
|
||||
IReadOnlyDictionary<string, JobPriority> jobPriorities)
|
||||
: this(name, age, sex, appearance, new Dictionary<string, JobPriority>(jobPriorities))
|
||||
{
|
||||
}
|
||||
|
||||
public static HumanoidCharacterProfile Default()
|
||||
{
|
||||
return new HumanoidCharacterProfile("John Doe", 18, Sex.Male, HumanoidCharacterAppearance.Default());
|
||||
return new HumanoidCharacterProfile("John Doe", 18, Sex.Male, HumanoidCharacterAppearance.Default(),
|
||||
new Dictionary<string, JobPriority>());
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
@@ -27,28 +43,50 @@ namespace Content.Shared.Preferences
|
||||
public Sex Sex { get; }
|
||||
public ICharacterAppearance CharacterAppearance => Appearance;
|
||||
public HumanoidCharacterAppearance Appearance { get; }
|
||||
public IReadOnlyDictionary<string, JobPriority> JobPriorities => _jobPriorities;
|
||||
|
||||
public HumanoidCharacterProfile WithName(string name)
|
||||
{
|
||||
return new HumanoidCharacterProfile(name, Age, Sex, Appearance);
|
||||
return new HumanoidCharacterProfile(name, Age, Sex, Appearance, _jobPriorities);
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile WithAge(int age)
|
||||
{
|
||||
return new HumanoidCharacterProfile(Name, age, Sex, Appearance);
|
||||
return new HumanoidCharacterProfile(Name, age, Sex, Appearance, _jobPriorities);
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile WithSex(Sex sex)
|
||||
{
|
||||
return new HumanoidCharacterProfile(Name, Age, sex, Appearance);
|
||||
return new HumanoidCharacterProfile(Name, Age, sex, Appearance, _jobPriorities);
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile WithCharacterAppearance(HumanoidCharacterAppearance appearance)
|
||||
{
|
||||
return new HumanoidCharacterProfile(Name, Age, Sex, appearance);
|
||||
return new HumanoidCharacterProfile(Name, Age, Sex, appearance, _jobPriorities);
|
||||
}
|
||||
|
||||
public string Summary => $"{Name}, {Age} years old {Sex.ToString().ToLower()} human.\nOccupation: to be implemented.";
|
||||
public HumanoidCharacterProfile WithJobPriorities(IReadOnlyDictionary<string, JobPriority> jobPriorities)
|
||||
{
|
||||
return new HumanoidCharacterProfile(Name, Age, Sex, Appearance, new Dictionary<string, JobPriority>(jobPriorities));
|
||||
}
|
||||
|
||||
public HumanoidCharacterProfile WithJobPriority(string jobId, JobPriority priority)
|
||||
{
|
||||
var dictionary = new Dictionary<string, JobPriority>(_jobPriorities);
|
||||
if (priority == JobPriority.Never)
|
||||
{
|
||||
dictionary.Remove(jobId);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary[jobId] = priority;
|
||||
}
|
||||
|
||||
return new HumanoidCharacterProfile(Name, Age, Sex, Appearance, dictionary);
|
||||
}
|
||||
|
||||
public string Summary =>
|
||||
$"{Name}, {Age} years old {Sex.ToString().ToLower()} human.";
|
||||
|
||||
public bool MemberwiseEquals(ICharacterProfile maybeOther)
|
||||
{
|
||||
@@ -56,6 +94,7 @@ namespace Content.Shared.Preferences
|
||||
if (Name != other.Name) return false;
|
||||
if (Age != other.Age) return false;
|
||||
if (Sex != other.Sex) return false;
|
||||
if (!_jobPriorities.SequenceEqual(other._jobPriorities)) return false;
|
||||
return Appearance.MemberwiseEquals(other.Appearance);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user