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);
110 public readonly Dictionary<int, ContentXElement>
ItemSets =
new Dictionary<int, ContentXElement>();
111 public readonly ImmutableDictionary<int, ImmutableArray<PreviewItem>>
PreviewItems;
112 public readonly List<SkillPrefab>
Skills =
new List<SkillPrefab>();
134 [
Serialize(
false,
IsPropertySaveable.No, description:
"Can the character speak any random lines, or just ones specifically meant for the job?")]
141 [
Serialize(0,
IsPropertySaveable.No, description:
"The number of these characters in the crew the player starts with in the single player campaign.")]
148 [
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.")]
162 [
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.")]
176 [
Serialize(1.0f,
IsPropertySaveable.No, description:
"Multiplier on the base hiring cost when hiring the character from an outpost.")]
183 [
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.).")]
190 [
Serialize(
false,
IsPropertySaveable.No, description:
"Hidden jobs are not selectable by players, but can be used by e.g. outpost NPCs.")]
214 var previewItems =
new Dictionary<int, List<PreviewItem>>();
217 foreach (var subElement
in element.Elements())
219 switch (subElement.Name.ToString().ToLowerInvariant())
223 previewItems[variant] =
new List<PreviewItem>();
224 loadItemIdentifiers(subElement, variant);
228 foreach (var skillElement
in subElement.Elements())
233 case "autonomousobjectives":
236 case "appropriateobjectives":
237 case "appropriateorders":
238 subElement.Elements().ForEach(order =>
AppropriateOrders.Add(order.GetAttributeIdentifier(
"identifier",
"")));
249 void loadItemIdentifiers(XElement parentElement,
int variant)
251 foreach (XElement itemElement
in parentElement.GetChildElements(
"Item"))
253 if (itemElement.Element(
"name") !=
null)
255 DebugConsole.ThrowErrorLocalized(
"Error in job config \"" +
Name +
"\" - use identifiers instead of names to configure the items.");
260 if (itemIdentifier.IsEmpty)
262 DebugConsole.ThrowErrorLocalized(
"Error in job config \"" +
Name +
"\" - item with no identifier.");
266 previewItems[variant].Add(
new PreviewItem(itemIdentifier, itemElement.GetAttributeBool(
"showpreview",
true)));
268 loadItemIdentifiers(itemElement, variant);
272 PreviewItems = previewItems.Select(kvp => (kvp.Key, kvp.Value.ToImmutableArray()))
273 .ToImmutableDictionary();
277 Skills.Sort((x,y) => y.LevelRange.Start.CompareTo(x.LevelRange.Start));
280 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
static readonly PrefabCollection< ItemRepairPriority > Prefabs
ItemRepairPriority(XElement element, JobsFile file)
PreviewItem(Identifier itemIdentifier, bool showPreview)
readonly bool ShowPreview
readonly Identifier ItemIdentifier
AIObjectiveIdle.BehaviorType IdleBehavior
JobPrefab(ContentXElement element, JobsFile file)
readonly LocalizedString Name
readonly Dictionary< int, ContentXElement > ItemSets
bool OnlyJobSpecificDialog
readonly List< AutonomousObjective > AutonomousObjectives
static IReadOnlyDictionary< Identifier, float > ItemRepairPriorities
Tag -> priority.
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 ImmutableDictionary< int, ImmutableArray< PreviewItem > > PreviewItems
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)