(f2e516dfe) v0.9.3.2

This commit is contained in:
Joonas Rikkonen
2019-09-20 20:11:18 +03:00
parent 80698b58b0
commit 9aa12bcac2
144 changed files with 1653 additions and 1559 deletions
@@ -12,10 +12,7 @@ namespace Barotrauma
{
private readonly XElement configElement;
private readonly string configPath;
[Serialize(false, false)]
public bool HideInMenus { get; set; }
public List<Pair<MapEntityPrefab, Rectangle>> DisplayEntities
{
get;
@@ -409,7 +409,7 @@ namespace Barotrauma
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
LevelObject obj = extraData[0] as LevelObject;
msg.WriteRangedIntegerDeprecated(0, objects.Count, objects.IndexOf(obj));
msg.WriteRangedInteger(objects.IndexOf(obj), 0, objects.Count);
obj.ServerWrite(msg, c);
}
}
@@ -344,7 +344,11 @@ namespace Barotrauma
structure.Update(deltaTime, cam);
}
foreach (Gap gap in Gap.GapList)
//update gaps in random order, because otherwise in rooms with multiple gaps
//the water/air will always tend to flow through the first gap in the list,
//which may lead to weird behavior like water draining down only through
//one gap in a room even if there are several
foreach (Gap gap in Gap.GapList.OrderBy(g => Rand.Int(int.MaxValue)))
{
gap.Update(deltaTime, cam);
}
@@ -562,7 +566,7 @@ namespace Barotrauma
}
}
[Serialize(1f, true), Editable(0.1f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
[Serialize(1f, true), Editable(0.01f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
public virtual float Scale { get; set; } = 1;
#endregion
}
@@ -77,7 +77,10 @@ namespace Barotrauma
get;
protected set;
}
[Serialize(false, false)]
public bool HideInMenus { get; set; }
[Serialize(false, false)]
public bool Linkable
{
@@ -8,6 +8,8 @@ namespace Barotrauma
{
public class Md5Hash
{
private static Regex removeWhitespaceRegex = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public string Hash { get; private set; }
public string ShortHash { get; private set; }
@@ -34,14 +36,13 @@ namespace Barotrauma
public Md5Hash(XDocument doc)
{
if (doc == null) return;
string docString = Regex.Replace(doc.ToString(), @"\s+", "");
if (doc == null) { return; }
string docString = removeWhitespaceRegex.Replace(doc.ToString(), "");
byte[] inputBytes = Encoding.ASCII.GetBytes(docString);
Hash = CalculateHash(inputBytes);
Hash = CalculateHash(inputBytes);
ShortHash = GetShortHash(Hash);
}
@@ -1296,7 +1296,6 @@ namespace Barotrauma
public override void Update(float deltaTime, Camera cam)
{
base.Update(deltaTime, cam);
if (aiTarget != null)
{
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
@@ -10,6 +10,7 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Voronoi2;
@@ -82,6 +83,7 @@ namespace Barotrauma
private static float lastPickedFraction;
private static Vector2 lastPickedNormal;
private Task hashTask;
private Md5Hash hash;
private string filePath;
@@ -165,10 +167,12 @@ namespace Barotrauma
{
get
{
if (hash != null) return hash;
XDocument doc = OpenFile(filePath);
hash = new Md5Hash(doc);
if (hash == null)
{
XDocument doc = OpenFile(filePath);
StartHashDocTask(doc);
hashTask.Wait();
}
return hash;
}
@@ -316,7 +320,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Error loading submarine " + filePath + "!", e);
}
if (hash != "")
if (!string.IsNullOrWhiteSpace(hash))
{
this.hash = new Md5Hash(hash);
}
@@ -341,6 +345,11 @@ namespace Barotrauma
if (doc != null && doc.Root != null)
{
if (string.IsNullOrWhiteSpace(hash))
{
StartHashDocTask(doc);
}
displayName = TextManager.Get("Submarine.Name." + name, true);
if (displayName == null || displayName.Length == 0) displayName = name;
@@ -397,6 +406,18 @@ namespace Barotrauma
FreeID();
}
public void StartHashDocTask(XDocument doc)
{
if (hash != null) { return; }
if (hashTask != null) { return; }
hashTask = new Task(() =>
{
hash = new Md5Hash(doc);
});
hashTask.Start();
}
public bool HasTag(SubmarineTag tag)
{
return tags.HasFlag(tag);