4 using System.Collections.Generic;
22 private readonly HashSet<Identifier> moduleFlags =
new HashSet<Identifier>();
25 get {
return moduleFlags; }
28 private readonly HashSet<Identifier> allowAttachToModules =
new HashSet<Identifier>();
31 get {
return allowAttachToModules; }
34 private readonly HashSet<Identifier> allowedLocationTypes =
new HashSet<Identifier>();
37 get {
return allowedLocationTypes; }
43 [
Serialize(10.0f,
IsPropertySaveable.Yes, description:
"How likely it is for the module to get picked when selecting from a set of modules during the outpost generation."),
Editable]
46 [
Serialize(
GapPosition.None,
IsPropertySaveable.Yes, description:
"Which sides of the module have gaps on them (i.e. from which sides the module can be attached to other modules). Center = no gaps available.")]
52 public string Name {
get;
private set; }
58 Name = $
"OutpostModuleInfo ({submarineInfo.Name})";
61 element.GetAttributeIdentifierArray(
"flags",
null) ??
62 element.GetAttributeIdentifierArray(
"moduletypes", Array.Empty<Identifier>()));
63 SetAllowAttachTo(element.GetAttributeIdentifierArray(
"allowattachto", Array.Empty<Identifier>()));
64 allowedLocationTypes =
new HashSet<Identifier>(element.GetAttributeIdentifierArray(
"allowedlocationtypes", Array.Empty<Identifier>()));
69 Name = $
"OutpostModuleInfo ({submarineInfo.Name})";
75 moduleFlags =
new HashSet<Identifier>(original.moduleFlags);
76 allowAttachToModules =
new HashSet<Identifier>(original.allowAttachToModules);
77 allowedLocationTypes =
new HashSet<Identifier>(original.allowedLocationTypes);
80 foreach (KeyValuePair<Identifier, SerializableProperty> kvp
in original.SerializableProperties)
85 kvp.Value.TrySetValue(
this, kvp.Value.GetValue(original));
90 public void SetFlags(IEnumerable<Identifier> newFlags)
93 if (newFlags.Contains(
"hallwayhorizontal".ToIdentifier()))
95 moduleFlags.Add(
"hallwayhorizontal".ToIdentifier());
96 if (newFlags.Contains(
"ruin".ToIdentifier())) { moduleFlags.Add(
"ruin".ToIdentifier()); }
98 if (newFlags.Contains(
"hallwayvertical".ToIdentifier()))
100 moduleFlags.Add(
"hallwayvertical".ToIdentifier());
101 if (newFlags.Contains(
"ruin".ToIdentifier())) { moduleFlags.Add(
"ruin".ToIdentifier()); }
105 moduleFlags.Add(
"none".ToIdentifier());
107 foreach (Identifier flag
in newFlags)
109 if (flag ==
"none" && newFlags.Count() > 1) {
continue; }
110 moduleFlags.Add(flag);
115 allowAttachToModules.Clear();
116 if (!allowAttachTo.Any())
118 allowAttachToModules.Add(
"any".ToIdentifier());
120 foreach (Identifier flag
in allowAttachTo)
122 if (flag ==
"any" && allowAttachTo.Count() > 1) {
continue; }
123 allowAttachToModules.Add(flag);
129 this.allowedLocationTypes.Clear();
130 foreach (Identifier locationType
in allowedLocationTypes)
132 if (locationType ==
"any") {
continue; }
133 this.allowedLocationTypes.Add(locationType);
138 return allowedLocationTypes.None() || allowedLocationTypes.Contains(
"Any".ToIdentifier());
144 return allowedLocationTypes.Contains(locationType.
Identifier);
156 bool portFound =
false;
165 if (portFound) {
continue; }
173 public void Save(XElement element)
176 element.SetAttributeValue(
"flags",
string.Join(
",",
ModuleFlags));
virtual Vector2 WorldPosition
static List< Gap > GapList
static IEnumerable< DockingPort > List
bool UseBetweenOutpostModules
readonly List< MapEntity > linkedTo
OutpostModuleInfo(SubmarineInfo submarineInfo)
void DetermineGapPositions(Submarine sub)
void SetFlags(IEnumerable< Identifier > newFlags)
IEnumerable< Identifier > AllowedLocationTypes
IEnumerable< Identifier > AllowAttachToModules
bool IsAllowedInAnyLocationType()
IEnumerable< Identifier > ModuleFlags
void SetAllowAttachTo(IEnumerable< Identifier > allowAttachTo)
OutpostModuleInfo(OutpostModuleInfo original)
bool IsAllowedInLocationType(LocationType locationType)
void SetAllowedLocationTypes(IEnumerable< Identifier > allowedLocationTypes)
GapPosition CanAttachToPrevious
OutpostModuleInfo(SubmarineInfo submarineInfo, XElement element)
void Save(XElement element)
Dictionary< Identifier, SerializableProperty > SerializableProperties
readonly Identifier Identifier
static Dictionary< Identifier, SerializableProperty > DeserializeProperties(object obj, XElement element=null)
static string GetSupportedTypeName(Type type)
static void SerializeProperties(ISerializableEntity obj, XElement element, bool saveIfDefault=false, bool ignoreEditable=false)
static bool RectContains(Rectangle rect, Vector2 pos, bool inclusive=false)