2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
5 using System.Collections.Immutable;
51 Priority = element.GetAttributeFloat(
"priority", -1f);
54 DebugConsole.AddWarning($
"The 'priority' attribute is missing from the the item repair priorities definition in {element} of {file.Path}.",
62 internal class JobVariant
64 public JobPrefab Prefab;
66 public JobVariant(JobPrefab prefab,
int variant)
79 private static readonly Dictionary<Identifier, float> _itemRepairPriorities =
new Dictionary<Identifier, float>();
87 if (
Prefabs.ContainsKey(identifier))
93 DebugConsole.ThrowError(
"Couldn't find a job prefab with the given identifier: " + identifier);
150 public readonly ImmutableDictionary<int, ImmutableArray<JobItem>>
JobItems;
151 public readonly List<SkillPrefab>
Skills =
new List<SkillPrefab>();
173 [
Serialize(
false,
IsPropertySaveable.No, description:
"Can the character speak any random lines, or just ones specifically meant for the job?")]
180 [
Serialize(0,
IsPropertySaveable.No, description:
"The number of these characters in the crew the player starts with in the single player campaign.")]
187 [
Serialize(
false,
IsPropertySaveable.No, description:
"If set to true, a client that has chosen this as their preferred job will get it regardless of the maximum number or the amount of spawnpoints in the sub.")]
201 [
Serialize(0,
IsPropertySaveable.No, description:
"How many crew members are required to have the job. I.e. if one captain is required, one captain is chosen even if all the players have set captain to lowest preference.")]
215 [
Serialize(1.0f,
IsPropertySaveable.No, description:
"Multiplier on the base hiring cost when hiring the character from an outpost.")]
222 [
Serialize(0.0f,
IsPropertySaveable.No, description:
"How much the vitality of the character is increased/reduced from the default value (e.g. 10 = 110 total vitality if the default vitality is 100.).")]
229 [
Serialize(
false,
IsPropertySaveable.No, description:
"Hidden jobs are not selectable by players, but can be used by e.g. outpost NPCs.")]
253 var jobItems =
new Dictionary<int, List<JobItem>>();
256 foreach (var subElement
in element.Elements())
258 switch (subElement.Name.ToString().ToLowerInvariant())
261 jobItems[variant] =
new List<JobItem>();
262 loadJobItems(subElement, variant, parentItem:
null);
266 foreach (var skillElement
in subElement.Elements())
271 case "autonomousobjectives":
274 case "appropriateobjectives":
275 case "appropriateorders":
276 subElement.Elements().ForEach(order =>
AppropriateOrders.Add(order.GetAttributeIdentifier(
"identifier",
"")));
293 DebugConsole.ThrowErrorLocalized(
"Error in job config \"" +
Name +
"\" - use identifiers instead of names to configure the items.",
300 if (itemIdentifier.IsEmpty)
302 DebugConsole.ThrowErrorLocalized(
"Error in job config \"" +
Name +
"\" - item with no identifier.",
307 jobItem =
new JobItem(itemElement, parentItem);
308 jobItems[variant].Add(jobItem);
310 loadJobItems(itemElement, variant, parentItem: jobItem);
314 JobItems = jobItems.Select(kvp => (kvp.Key, kvp.Value.ToImmutableArray()))
315 .ToImmutableDictionary();
319 Skills.Sort((x,y) => y.GetLevelRange(isPvP:
false).Start.CompareTo(x.GetLevelRange(isPvP:
false).Start));
322 public static JobPrefab Random(Rand.RandSync sync, Func<JobPrefab, bool> predicate =
null) =>
Prefabs.GetRandom(p => !p.HiddenJob && (predicate ==
null || predicate(p)), sync);
readonly bool IgnoreAtNonOutpost
The order is ignored in "normal" non-outpost levels
AutonomousObjective(XElement element)
readonly float PriorityModifier
readonly bool IgnoreAtOutpost
The order is ignored in outpost levels. Doesn't apply to outpost NPCs.
readonly Identifier Identifier
readonly Identifier Option
ContentPackage? ContentPackage
IEnumerable< ContentXElement > GetChildElements(string name)
bool GetAttributeBool(string key, bool def)
int GetAttributeInt(string key, int def)
XAttribute? GetAttribute(string name)
Identifier GetAttributeIdentifier(string key, string def)
static readonly PrefabCollection< ItemRepairPriority > Prefabs
ItemRepairPriority(XElement element, JobsFile file)
readonly JobItem ParentItem
Identifier GetItemIdentifier(CharacterTeamType team, bool isPvPMode)
readonly GameModeType GameMode
readonly Identifier ItemIdentifierTeam2
JobItem(ContentXElement element, JobItem parentItem)
readonly Identifier ItemIdentifier
readonly bool ShowPreview
AIObjectiveIdle.BehaviorType IdleBehavior
JobPrefab(ContentXElement element, JobsFile file)
readonly LocalizedString Name
bool OnlyJobSpecificDialog
readonly List< AutonomousObjective > AutonomousObjectives
static IReadOnlyDictionary< Identifier, float > ItemRepairPriorities
Tag -> priority.
readonly ImmutableDictionary< int, ImmutableArray< JobItem > > JobItems
The items the character can get when spawning. The key is the index of the job variant.
readonly LocalizedString Description
static JobPrefab Random(Rand.RandSync sync, Func< JobPrefab, bool > predicate=null)
static readonly PrefabCollection< JobPrefab > Prefabs
static JobPrefab Get(Identifier identifier)
readonly List< Identifier > AppropriateOrders
readonly List< SkillPrefab > Skills
readonly Identifier Identifier
Prefab that has a property serves as a deterministic hash of a prefab's identifier....
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)