(1968ab79f) v0.9.9.1

This commit is contained in:
Joonas Rikkonen
2020-04-30 14:09:23 +03:00
parent ac37a3b0e4
commit ce4ccd99ac
23 changed files with 131 additions and 55 deletions
@@ -2908,7 +2908,10 @@ namespace Barotrauma
causeOfDeathAffliction?.Source ?? LastAttacker, LastDamageSource);
OnDeath?.Invoke(this, CauseOfDeath);
SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath);
if (GameMain.GameSession != null && Screen.Selected == GameMain.GameScreen)
{
SteamAchievementManager.OnCharacterKilled(this, CauseOfDeath);
}
KillProjSpecific(causeOfDeath, causeOfDeathAffliction, log);
@@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Extensions;
using FarseerPhysics.Dynamics;
namespace Barotrauma.Items.Components
{
@@ -655,7 +656,8 @@ namespace Barotrauma.Items.Components
end -= target.Submarine.SimPosition;
}
var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel;
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true);
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true,
customPredicate: (Fixture f) => { return !item.StaticFixtures.Contains(f); });
if (pickedBody == null) { return; }
Character targetCharacter = null;
if (pickedBody.UserData is Character c)
@@ -817,7 +819,8 @@ namespace Barotrauma.Items.Components
end -= closestEnemy.Submarine.SimPosition;
}
var collisionCategories = Physics.CollisionWall | Physics.CollisionCharacter | Physics.CollisionItem | Physics.CollisionLevel;
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true);
var pickedBody = Submarine.PickBody(start, end, null, collisionCategories, allowInsideFixture: true,
customPredicate: (Fixture f) => { return !item.StaticFixtures.Contains(f); });
if (pickedBody == null) { return false; }
Character targetCharacter = null;
if (pickedBody.UserData is Character c)
@@ -166,6 +166,11 @@ namespace Barotrauma
private set;
}
public List<Entity> EntitiesBeforeGenerate { get; private set; } = new List<Entity>();
public int EntityCountBeforeGenerate { get; private set; }
public int EntityCountAfterGenerate { get; private set; }
public float Difficulty
{
get;
@@ -281,8 +286,11 @@ namespace Barotrauma
public void Generate(bool mirror)
{
if (loaded != null) loaded.Remove();
if (loaded != null) { loaded.Remove(); }
loaded = this;
EntitiesBeforeGenerate = GetEntityList();
EntityCountBeforeGenerate = EntitiesBeforeGenerate.Count();
levelObjectManager = new LevelObjectManager();
@@ -759,6 +767,8 @@ namespace Barotrauma
DebugConsole.NewMessage("Generated level with the seed " + seed + " (type: " + generationParams.Name + ")", Color.White);
}
EntityCountAfterGenerate = Entity.GetEntityList().Count();
//assign an ID to make entity events work
ID = FindFreeID();
}
@@ -215,7 +215,7 @@ namespace Barotrauma
public override string ToString()
{
return "Barotrauma.Submarine (" + Info?.Name ?? "[NULL INFO]" + ")";
return "Barotrauma.Submarine (" + (Info?.Name ?? "[NULL INFO]") + ", " + IdOffset + ")";
}
public override bool Removed
@@ -1231,9 +1231,12 @@ namespace Barotrauma
public bool SaveAs(string filePath, MemoryStream previewImage = null)
{
var newInfo = new SubmarineInfo(this);
newInfo.FilePath = filePath;
newInfo.Name = Path.GetFileNameWithoutExtension(filePath);
var newInfo = new SubmarineInfo(this)
{
GameVersion = GameMain.Version,
FilePath = filePath,
Name = Path.GetFileNameWithoutExtension(filePath)
};
Info.Dispose(); Info = newInfo;
return newInfo.SaveAs(filePath, previewImage);
@@ -101,7 +101,11 @@ namespace Barotrauma
set;
}
public readonly XElement SubmarineElement;
public XElement SubmarineElement
{
get;
private set;
}
public override string ToString()
{
@@ -180,28 +184,7 @@ namespace Barotrauma
if (element == null && tryLoad)
{
XDocument doc = null;
int maxLoadRetries = 4;
for (int i = 0; i <= maxLoadRetries; i++)
{
doc = OpenFile(filePath, out Exception e);
if (e != null && !(e is IOException)) { break; }
if (doc != null || i == maxLoadRetries || !File.Exists(filePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + filePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250);
}
if (doc == null || doc.Root == null)
{
IsFileCorrupted = true;
return;
}
if (string.IsNullOrWhiteSpace(hash))
{
StartHashDocTask(doc);
}
SubmarineElement = doc.Root;
Reload();
}
else
{
@@ -215,6 +198,7 @@ namespace Barotrauma
public SubmarineInfo(Submarine sub) : this(sub.Info)
{
GameVersion = GameMain.Version;
SubmarineElement = new XElement("Submarine");
sub.SaveToXElement(SubmarineElement);
Init();
@@ -242,6 +226,30 @@ namespace Barotrauma
#endif
}
public void Reload()
{
XDocument doc = null;
int maxLoadRetries = 4;
for (int i = 0; i <= maxLoadRetries; i++)
{
doc = OpenFile(FilePath, out Exception e);
if (e != null && !(e is IOException)) { break; }
if (doc != null || i == maxLoadRetries || !File.Exists(FilePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + FilePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250);
}
if (doc == null || doc.Root == null)
{
IsFileCorrupted = true;
return;
}
if (hash == null)
{
StartHashDocTask(doc);
}
SubmarineElement = doc.Root;
}
private void Init()
{
DisplayName = TextManager.Get("Submarine.Name." + Name, true);
@@ -371,7 +371,7 @@ namespace Barotrauma
if (charactersInSub.Count == 1)
{
//there must be some non-enemy casualties to get the last mant standing achievement
if (roundData.Casualties.Any(c => !(c.AIController is EnemyAIController)))
if (roundData.Casualties.Any(c => !(c.AIController is EnemyAIController) && c.TeamID == charactersInSub[0].TeamID))
{
UnlockAchievement(charactersInSub[0], "lastmanstanding");
}
@@ -410,7 +410,8 @@ namespace Barotrauma
foreach (FileInfo file in files)
{
string tempPath = Path.Combine(destDirName, file.Name);
file.CopyTo(tempPath, overwriteExisting);
if (!overwriteExisting && File.Exists(tempPath)) { continue; }
file.CopyTo(tempPath, true);
}
// If copying subdirectories, copy them and their contents to new location.