commit 2f107db0475bf4b9a8b6f405b9ce8ec489cbc0ba Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 16:30:24 2019 +0200 Another nullref fix to the OpenHealthWindow property setter. Closes #1090 commit 1d15d18d2501bedaa1b42ac8e0e7e09e2600960e Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 16:19:05 2019 +0200 Fixed crashing when an incompatible content package is selected in config.xml or if the content package cannot be found. Happened because the game attempted to use TextManager.Get before text files had been loaded. Partially fixes #1093 commit 9ec1980fe90bcae65333c188b265ba16a6db6c05 Author: ezjamsen <ezjames.fi@gmail.com> Date: Thu Feb 7 16:16:53 2019 +0200 added correct effects for alien blood commit b6d2c56910b5d58477703abc6785ef80719a89a6 Author: ezjamsen <ezjames.fi@gmail.com> Date: Thu Feb 7 15:41:25 2019 +0200 adjustments to fent, glue and antibiotics commit 8df16acdaac0a521fe09fb62c6815a46a87f6f25 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 15:30:51 2019 +0200 More descriptive ping exception error messages (only shown in debug builds now), some extra checks to prevent using the workshop without steam (although the checks that actually matter are implemented at Steam's side now) commit 959c503c140196287ab60ec2357feb8bd5c85b18 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 14:00:48 2019 +0200 Don't allow severing the joint between a moloch's shell and the "bladder" commit 0c0b033016c2e82b8cf1b5a4e3f6faa9cde39f40 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 13:51:58 2019 +0200 Fixed incorrect item panel positioning in the crew command interface when the sub is docked to something. Closes #1082 commit 68366a4bf3c73b70288f043199d3ab9b2f5f4d06 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 13:23:38 2019 +0200 Fixed outdated damage modifiers in security and clown gear (used damage types instead of afflictions), not defining any affliction types for a damage modifier makes it affect all types of damage. Closes #1088 commit 5d3ab5084b8bc5357bc4a53993ad8dfcc44d0412 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 13:04:55 2019 +0200 Fixed client-side nullref exception if the round ends while the health window is open. Closes #1090 commit 8249d789a60dfe4bcdd1705d26d6ca36ed407058 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Thu Feb 7 12:48:34 2019 +0200 The dedicated server doesn't initialize a Steam client (not required to use any of the Steam server functionality). Fixes players being unable to log in as a client when they're hosting a dedicated server on another machine. TODO: SteamCMD support commit 55fb0bb1ba4bb8385dabbf6e40d4651bf86294a9 Author: ezjamsen <ezjames.fi@gmail.com> Date: Thu Feb 7 12:31:46 2019 +0200 Added linked hulls commit 937d50dca50d8c889a7c11b55765c208d2d16b67 Merge: 8109ae1a3 57731761f Author: EdusFF <pitkanen.eetu@gmail.com> Date: Thu Feb 7 12:16:43 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit 8109ae1a3377910ff9bf066ccac582d879dfb0a4 Author: EdusFF <pitkanen.eetu@gmail.com> Date: Thu Feb 7 12:16:37 2019 +0200 Fixed: AI not reloading coilgun if an empty box of ammunition is inserted. commit 57731761f64bb33a4f4e7baa38367cfb7cf1f873 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Feb 7 12:10:59 2019 +0200 Refactor character head customization logic and store the data in a dedicated class. In the net lobby, generate new head when the user presses the right arrow button. Pressing the left arrow will restore the previous head. When the user presses the right arrow after the left arrow, the first head is restored again. So it's effectively (and technically) undo/redo logic. commit 37577931e2706ce432cee2d48cd55990bc2bab4a Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Feb 7 12:04:49 2019 +0200 Add properties for getting the count of the undo and redo stacks. commit f226beb05a55749ac961e3a33ac594fdf903fc3b Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 21:15:56 2019 +0200 Fixes to hull linking & displaying them as one hull on the minimap: - Links between hulls are now saved. - Simplified grouping logic (just store a list of linked hulls in hulldata). - Fixed water/oxygen calculations (use the average of the values instead of their sum). TODO: DRY (there's now duplicate linking logic in Item and Hull), merge the hull sprites on the minimap, maybe automatize the linking? commit 5dfea1fbb24c5bd91605caf65baaac9aca9cfbbf Merge: 2ad9b5de4 d06a1557f Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Wed Feb 6 20:18:31 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit d06a1557ffb85cd32bbb884fadef60b6d9dd27cf Author: Alex <olimpickusa6@gmail.com> Date: Wed Feb 6 18:26:40 2019 +0200 Test for connecting hulls task
290 lines
9.7 KiB
C#
290 lines
9.7 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace Barotrauma
|
|
{
|
|
[Flags]
|
|
enum MapEntityCategory
|
|
{
|
|
Structure = 1, Machine = 2, Equipment = 4, Electrical = 8, Material = 16, Misc = 32, Alien = 64, ItemAssembly = 128, Legacy = 256
|
|
}
|
|
|
|
partial class MapEntityPrefab
|
|
{
|
|
public readonly static List<MapEntityPrefab> List = new List<MapEntityPrefab>();
|
|
|
|
protected string name;
|
|
protected string identifier;
|
|
|
|
public Sprite sprite;
|
|
|
|
//the position where the structure is being placed (needed when stretching the structure)
|
|
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; }
|
|
[Serialize(false, false)]
|
|
public bool ResizeVertical { get; protected set; }
|
|
|
|
//which prefab has been selected for placing
|
|
protected static MapEntityPrefab selected;
|
|
|
|
public string Name
|
|
{
|
|
get { return name; }
|
|
}
|
|
|
|
//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
|
|
{
|
|
get { return selected; }
|
|
set { selected = value; }
|
|
}
|
|
|
|
[Serialize("", false)]
|
|
public string Description
|
|
{
|
|
get;
|
|
protected set;
|
|
}
|
|
|
|
[Serialize(false, false)]
|
|
public bool Linkable
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Links defined to identifiers.
|
|
/// </summary>
|
|
public List<string> AllowedLinks { get; protected set; } = new List<string>();
|
|
|
|
public MapEntityCategory Category
|
|
{
|
|
get;
|
|
protected set;
|
|
}
|
|
|
|
[Serialize("1.0,1.0,1.0,1.0", false)]
|
|
public Color SpriteColor
|
|
{
|
|
get;
|
|
protected set;
|
|
}
|
|
|
|
[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)
|
|
public string[] Aliases
|
|
{
|
|
get;
|
|
protected set;
|
|
}
|
|
|
|
public static void Init()
|
|
{
|
|
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,
|
|
Linkable = true
|
|
};
|
|
ep.AllowedLinks.Add("hull");
|
|
List.Add(ep);
|
|
|
|
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
|
|
{
|
|
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
|
|
{
|
|
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);
|
|
}
|
|
|
|
public MapEntityPrefab()
|
|
{
|
|
Category = MapEntityCategory.Structure;
|
|
}
|
|
|
|
public virtual void UpdatePlacing(Camera cam)
|
|
{
|
|
Vector2 placeSize = Submarine.GridSize;
|
|
|
|
if (placePosition == Vector2.Zero)
|
|
{
|
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
|
|
|
if (PlayerInput.LeftButtonHeld()) placePosition = position;
|
|
}
|
|
else
|
|
{
|
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
|
|
|
if (ResizeHorizontal) placeSize.X = position.X - placePosition.X;
|
|
if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y;
|
|
|
|
Rectangle newRect = Submarine.AbsRect(placePosition, placeSize);
|
|
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
|
|
newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
|
|
|
|
if (Submarine.MainSub != null)
|
|
{
|
|
newRect.Location -= MathUtils.ToPoint(Submarine.MainSub.Position);
|
|
}
|
|
|
|
if (PlayerInput.LeftButtonReleased())
|
|
{
|
|
CreateInstance(newRect);
|
|
placePosition = Vector2.Zero;
|
|
selected = null;
|
|
}
|
|
|
|
newRect.Y = -newRect.Y;
|
|
}
|
|
|
|
if (PlayerInput.RightButtonHeld())
|
|
{
|
|
placePosition = Vector2.Zero;
|
|
selected = null;
|
|
}
|
|
}
|
|
|
|
protected virtual void CreateInstance(Rectangle rect)
|
|
{
|
|
object[] lobject = new object[] { this, rect };
|
|
constructor.Invoke(lobject);
|
|
}
|
|
|
|
public static bool SelectPrefab(object selection)
|
|
{
|
|
if ((selected = selection as MapEntityPrefab) != null)
|
|
{
|
|
placePosition = Vector2.Zero;
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return 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 (name != null) name = name.ToLowerInvariant();
|
|
foreach (MapEntityPrefab prefab in List)
|
|
{
|
|
if (identifier != null)
|
|
{
|
|
if (prefab.identifier != identifier)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(name)) return prefab;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if the name or any of the aliases of this prefab match the given name.
|
|
/// </summary>
|
|
public bool NameMatches(string name, bool caseSensitive = false)
|
|
{
|
|
if (caseSensitive)
|
|
{
|
|
return this.name == name || (Aliases != null && Aliases.Any(a => a == name));
|
|
}
|
|
else
|
|
{
|
|
name = name.ToLowerInvariant();
|
|
return this.name.ToLowerInvariant() == name || (Aliases != null && Aliases.Any(a => a.ToLowerInvariant() == name));
|
|
}
|
|
}
|
|
|
|
public bool NameMatches(IEnumerable<string> allowedNames, bool caseSensitive = false)
|
|
{
|
|
foreach (string name in allowedNames)
|
|
{
|
|
if (NameMatches(name, caseSensitive)) return true;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|