38f1ddb...178a853: v0.8.9.1, removed content folder

This commit is contained in:
Joonas Rikkonen
2019-03-18 19:46:58 +02:00
parent 38f1ddb6fe
commit 6c0679c297
1054 changed files with 151673 additions and 144931 deletions
@@ -9,7 +9,7 @@ namespace Barotrauma
[Flags]
enum MapEntityCategory
{
Structure = 1, Machine = 2, Equipment = 4, Electrical = 8, Material = 16, Misc = 32, Alien = 64
Structure = 1, Machine = 2, Equipment = 4, Electrical = 8, Material = 16, Misc = 32, Alien = 64, ItemAssembly = 128, Legacy = 256
}
partial class MapEntityPrefab
@@ -17,6 +17,7 @@ namespace Barotrauma
public readonly static List<MapEntityPrefab> List = new List<MapEntityPrefab>();
protected string name;
protected string identifier;
public Sprite sprite;
@@ -24,7 +25,7 @@ namespace Barotrauma
protected static Vector2 placePosition;
protected ConstructorInfo constructor;
//is it possible to stretch the entity horizontally/vertically
[Serialize(false, false)]
public bool ResizeHorizontal { get; protected set; }
@@ -33,19 +34,24 @@ namespace Barotrauma
//which prefab has been selected for placing
protected static MapEntityPrefab selected;
private int price;
public string Name
{
get { return name; }
}
public List<string> Tags
//Used to differentiate between items when saving/loading
//Allows changing the name of an item without breaking existing subs or having multiple items with the same name
public string Identifier
{
get { return identifier; }
}
public HashSet<string> Tags
{
get;
protected set;
}
} = new HashSet<string>();
public static MapEntityPrefab Selected
{
@@ -66,7 +72,12 @@ namespace Barotrauma
get;
private set;
}
/// <summary>
/// Links defined to identifiers.
/// </summary>
public List<string> AllowedLinks { get; protected set; } = new List<string>();
public MapEntityCategory Category
{
get;
@@ -80,12 +91,8 @@ namespace Barotrauma
protected set;
}
[Serialize(0, false)]
public int Price
{
get { return price; }
protected set { price = Math.Max(value, 0); }
}
[Serialize(1f, true), Editable(0.1f, 10f, DecimalCount = 3)]
public float Scale { get; protected set; }
//If a matching prefab is not found when loading a sub, the game will attempt to find a prefab with a matching alias.
//(allows changing names while keeping backwards compatibility with older sub files)
@@ -97,30 +104,44 @@ namespace Barotrauma
public static void Init()
{
MapEntityPrefab ep = new MapEntityPrefab();
ep.name = "Hull";
ep.Description = "Hulls determine which parts are considered to be \"inside the sub\". Generally every room should be enclosed by a hull.";
ep.constructor = typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep.ResizeHorizontal = true;
ep.ResizeVertical = true;
MapEntityPrefab ep = new MapEntityPrefab
{
identifier = "hull",
name = TextManager.Get("EntityName.hull"),
Description = TextManager.Get("EntityDescription.hull"),
constructor = typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
ResizeHorizontal = true,
ResizeVertical = true
};
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Gap";
ep.Description = "Gaps allow water and air to flow between two hulls. ";
ep.constructor = typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep.ResizeHorizontal = true;
ep.ResizeVertical = true;
ep = new MapEntityPrefab
{
identifier = "gap",
name = TextManager.Get("EntityName.gap"),
Description = TextManager.Get("EntityDescription.gap"),
constructor = typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }),
ResizeHorizontal = true,
ResizeVertical = true
};
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Waypoint";
ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep = new MapEntityPrefab
{
identifier = "waypoint",
name = TextManager.Get("EntityName.waypoint"),
Description = TextManager.Get("EntityDescription.waypoint"),
constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) })
};
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Spawnpoint";
ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep = new MapEntityPrefab
{
identifier = "spawnpoint",
name = TextManager.Get("EntityName.spawnpoint"),
Description = TextManager.Get("EntityDescription.spawnpoint"),
constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) })
};
List.Add(ep);
}
@@ -191,24 +212,37 @@ namespace Barotrauma
}
}
public static MapEntityPrefab Find(string name, bool caseSensitive = false)
/// <summary>
/// Find a matching map entity prefab
/// </summary>
/// <param name="name">The name of the item (can be omitted when searching based on identifier)</param>
/// <param name="identifier">The identifier of the item (if null, the identifier is ignored and the search is done only based on the name)</param>
public static MapEntityPrefab Find(string name, string identifier = null, bool showErrorMessages = true)
{
if (caseSensitive)
if (name != null) name = name.ToLowerInvariant();
foreach (MapEntityPrefab prefab in List)
{
foreach (MapEntityPrefab prefab in List)
if (identifier != null)
{
if (prefab.name == name || (prefab.Aliases != null && prefab.Aliases.Contains(name))) return prefab;
if (prefab.identifier != identifier)
{
continue;
}
else
{
if (string.IsNullOrEmpty(name)) return prefab;
}
}
}
else
{
name = name.ToLowerInvariant();
foreach (MapEntityPrefab prefab in List)
if (!string.IsNullOrEmpty(name))
{
if (prefab.name.ToLowerInvariant() == name || (prefab.Aliases != null && prefab.Aliases.Any(a => a.ToLowerInvariant() == name))) return prefab;
}
}
if (showErrorMessages)
{
DebugConsole.ThrowError("Failed to find a matching MapEntityPrefab (name: \"" + name + "\", identifier: \"" + identifier + "\").\n" + Environment.StackTrace);
}
return null;
}
@@ -237,11 +271,17 @@ namespace Barotrauma
return false;
}
public bool IsLinkAllowed(MapEntityPrefab target)
{
if (target == null) { return false; }
return AllowedLinks.Contains(target.Identifier) || target.AllowedLinks.Contains(identifier)
|| target.Tags.Any(t => AllowedLinks.Contains(t)) || Tags.Any(t => target.AllowedLinks.Contains(t));
}
//a method that allows the GUIListBoxes to check through a delegate if the entityprefab is still selected
public static object GetSelected()
{
return (object)selected;
}
}
}
}