(a00338777) v0.9.2.1

This commit is contained in:
Joonas Rikkonen
2019-08-26 19:58:19 +03:00
parent 0f63da27b2
commit 80698b58b0
311 changed files with 11763 additions and 4507 deletions
@@ -1,7 +1,6 @@
using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -229,7 +228,13 @@ namespace Barotrauma
surface = rect.Y - rect.Height;
aiTarget = new AITarget(this);
aiTarget = new AITarget(this)
{
MinSightRange = 2000,
MaxSightRange = 5000,
MaxSoundRange = 5000,
SoundRange = 0
};
hullList.Add(this);
@@ -418,13 +423,14 @@ namespace Barotrauma
public override void Update(float deltaTime, Camera cam)
{
base.Update(deltaTime, cam);
UpdateProjSpecific(deltaTime, cam);
Oxygen -= OxygenDeteriorationSpeed * deltaTime;
FireSource.UpdateAll(FireSources, deltaTime);
aiTarget.SightRange = Submarine == null ? 0.0f : Math.Max(Submarine.Velocity.Length() * 2000.0f, AITarget.StaticSightRange);
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
aiTarget.SoundRange -= deltaTime * 1000.0f;
if (!update)
@@ -5,7 +5,6 @@ using Barotrauma.RuinGeneration;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -1673,7 +1672,7 @@ namespace Barotrauma
loaded = null;
}
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
foreach (LevelWall levelWall in extraWalls)
{
@@ -1,6 +1,5 @@
using Barotrauma.Networking;
using FarseerPhysics;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -122,7 +121,7 @@ namespace Barotrauma
return "LevelObject (" + ActivePrefab.Name + ")";
}
public void ServerWrite(NetBuffer msg, Client c)
public void ServerWrite(IWriteMessage msg, Client c)
{
for (int j = 0; j < Triggers.Count; j++)
{
@@ -3,7 +3,6 @@ using Barotrauma.Particles;
#endif
using Barotrauma.Networking;
using FarseerPhysics;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -407,10 +406,10 @@ namespace Barotrauma
partial void RemoveProjSpecific();
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
LevelObject obj = extraData[0] as LevelObject;
msg.WriteRangedInteger(0, objects.Count, objects.IndexOf(obj));
msg.WriteRangedIntegerDeprecated(0, objects.Count, objects.IndexOf(obj));
obj.ServerWrite(msg, c);
}
}
@@ -2,7 +2,6 @@
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -598,7 +597,7 @@ namespace Barotrauma
return vel.ClampLength(ConvertUnits.ToDisplayUnits(ForceVelocityLimit)) * currentForceFluctuation;
}
public void ServerWrite(NetBuffer msg, Client c)
public void ServerWrite(IWriteMessage msg, Client c)
{
if (ForceFluctuationStrength > 0.0f)
{
@@ -339,6 +339,11 @@ namespace Barotrauma
hull.Update(deltaTime, cam);
}
foreach (Structure structure in Structure.WallList)
{
structure.Update(deltaTime, cam);
}
foreach (Gap gap in Gap.GapList)
{
gap.Update(deltaTime, cam);
@@ -40,6 +40,18 @@ namespace Barotrauma
get { return name; }
}
public string GetItemNameTextId()
{
var textId = $"entityname.{Identifier}";
return TextManager.ContainsTag(textId) ? textId : null;
}
public string GetHullNameTextId()
{
var textId = $"roomname.{Identifier}";
return TextManager.ContainsTag(textId) ? textId : null;
}
//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
@@ -4,7 +4,6 @@ using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Factories;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
@@ -373,7 +372,12 @@ namespace Barotrauma
// Only add ai targets automatically to submarine/outpost walls
if (aiTarget == null && HasBody && Tags.Contains("wall") && submarine != null && !Prefab.NoAITarget)
{
aiTarget = new AITarget(this);
aiTarget = new AITarget(this)
{
MinSightRange = 2000,
MaxSightRange = 5000,
MaxSoundRange = 0
};
}
InsertToList();
@@ -460,15 +464,16 @@ namespace Barotrauma
{
if (IsHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / WallSectionSize);
//equivalent to (int)Math.Ceiling((double)rect.Width / WallSectionSize) without the potential for floating point indeterminism
xsections = (rect.Width + WallSectionSize - 1) / WallSectionSize;
Sections = new WallSection[xsections];
width = (int)WallSectionSize;
width = WallSectionSize;
}
else
{
ysections = (int)Math.Ceiling((float)rect.Height / WallSectionSize);
ysections = (rect.Height + WallSectionSize - 1) / WallSectionSize;
Sections = new WallSection[ysections];
height = (int)WallSectionSize;
height = WallSectionSize;
}
}
@@ -1184,21 +1189,32 @@ namespace Barotrauma
ID = (ushort)int.Parse(element.Attribute("ID").Value)
};
SerializableProperty.DeserializeProperties(s, element);
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString())
{
case "section":
int index = subElement.GetAttributeInt("i", -1);
if (index == -1) continue;
s.Sections[index].damage = subElement.GetAttributeFloat("damage", 0.0f);
if (index == -1) { continue; }
if (index < 0 || index >= s.SectionCount)
{
string errorMsg = $"Error while loading structure \"{s.Name}\". Section damage index out of bounds. Index: {index}, section count: {s.SectionCount}.";
DebugConsole.ThrowError(errorMsg);
GameAnalyticsManager.AddErrorEventOnce("Structure.Load:SectionIndexOutOfBounds", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
}
else
{
s.Sections[index].damage = subElement.GetAttributeFloat("damage", 0.0f);
}
break;
}
}
if (element.GetAttributeBool("flippedx", false)) s.FlipX(false);
if (element.GetAttributeBool("flippedy", false)) s.FlipY(false);
SerializableProperty.DeserializeProperties(s, element);
//structures with a body drop a shadow by default
if (element.Attribute("usedropshadow") == null)
@@ -1277,5 +1293,14 @@ namespace Barotrauma
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, Prefab.ConfigElement);
}
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;
}
}
}
}
@@ -3,7 +3,6 @@ using Barotrauma.Networking;
using Barotrauma.RuinGeneration;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -1143,7 +1142,6 @@ namespace Barotrauma
savedSubmarines.Add(sub);
}
public static void RefreshSavedSub(string filePath)
{
string fullPath = Path.GetFullPath(filePath);
@@ -1154,12 +1152,15 @@ namespace Barotrauma
savedSubmarines[i].Dispose();
}
}
var sub = new Submarine(filePath);
if (!sub.IsFileCorrupted)
if (File.Exists(filePath))
{
savedSubmarines.Add(sub);
var sub = new Submarine(filePath);
if (!sub.IsFileCorrupted)
{
savedSubmarines.Add(sub);
}
savedSubmarines = savedSubmarines.OrderBy(s => s.filePath ?? "").ToList();
}
savedSubmarines = savedSubmarines.OrderBy(s => s.filePath ?? "").ToList();
}
public static void RefreshSavedSubs()
@@ -1210,6 +1211,15 @@ namespace Barotrauma
}
}
var contentPackageSubs = ContentPackage.GetFilesOfType(GameMain.Config.SelectedContentPackages, ContentType.Submarine);
foreach (string subPath in contentPackageSubs)
{
if (!filePaths.Any(fp => Path.GetFullPath(fp) == Path.GetFullPath(subPath)))
{
filePaths.Add(subPath);
}
}
foreach (string path in filePaths)
{
var sub = new Submarine(path);