Unstable v0.10.600.0
This commit is contained in:
@@ -7,14 +7,13 @@ namespace Barotrauma
|
||||
{
|
||||
private Vector2 maxSize;
|
||||
|
||||
public bool Removed
|
||||
{
|
||||
get { return removed; }
|
||||
}
|
||||
public bool CausedByPsychosis;
|
||||
|
||||
public DummyFireSource(Vector2 maxSize, Vector2 worldPosition, Hull spawningHull = null, bool isNetworkMessage = false) : base(worldPosition, spawningHull, isNetworkMessage)
|
||||
{
|
||||
this.maxSize = maxSize;
|
||||
DamagesItems = false;
|
||||
DamagesCharacters = true;
|
||||
}
|
||||
|
||||
public override float DamageRange
|
||||
@@ -24,11 +23,7 @@ namespace Barotrauma
|
||||
|
||||
protected override void LimitSize()
|
||||
{
|
||||
if (hull == null) return;
|
||||
|
||||
position.X = Math.Max(hull.Rect.X, position.X);
|
||||
position.Y = Math.Min(hull.Rect.Y, position.Y);
|
||||
|
||||
base.LimitSize();
|
||||
size.X = Math.Min(maxSize.X, size.X);
|
||||
size.Y = Math.Min(maxSize.Y, size.Y);
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ namespace Barotrauma
|
||||
if (value == NullEntityID)
|
||||
{
|
||||
DebugConsole.ThrowError("Cannot set the ID of an entity to " + NullEntityID +
|
||||
"! The value is reserved for entity events referring to a non-existent (e.g. removed) entity.\n" + Environment.StackTrace);
|
||||
"! The value is reserved for entity events referring to a non-existent (e.g. removed) entity.\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
if (value == EntitySpawnerID)
|
||||
{
|
||||
DebugConsole.ThrowError("Cannot set the ID of an entity to " + EntitySpawnerID +
|
||||
"! The value is reserved for EntitySpawner.\n" + Environment.StackTrace);
|
||||
"! The value is reserved for EntitySpawner.\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
"Entity.RemoveAll:Exception" + e.ToString(),
|
||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||
"Error while removing entity \"" + e.ToString() + " (" + exception.Message + ")\n" + exception.StackTrace);
|
||||
"Error while removing entity \"" + e.ToString() + " (" + exception.Message + ")\n" + exception.StackTrace.CleanupStackTrace());
|
||||
}
|
||||
}
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
@@ -266,7 +266,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
"Entity.FreeID:EntityNotFound" + ID,
|
||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||
"Entity " + ToString() + " (" + ID + ") not present in entity dictionary.\n" + Environment.StackTrace);
|
||||
"Entity " + ToString() + " (" + ID + ") not present in entity dictionary.\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
}
|
||||
else if (existingEntity != this)
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Barotrauma
|
||||
|
||||
if (hull != null && !string.IsNullOrWhiteSpace(decal) && decalSize > 0.0f)
|
||||
{
|
||||
hull.AddDecal(decal, worldPosition, decalSize, true);
|
||||
hull.AddDecal(decal, worldPosition, decalSize, isNetworkEvent: false);
|
||||
}
|
||||
|
||||
float displayRange = attack.Range;
|
||||
@@ -340,6 +340,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (c == Character.Controlled && !c.IsDead)
|
||||
{
|
||||
Limb head = c.AnimController.GetLimb(LimbType.Head);
|
||||
if (damages.TryGetValue(head, out float headDamage) && headDamage > 0.0f && distFactors.TryGetValue(head, out float headFactor))
|
||||
{
|
||||
PlayTinnitusProjSpecific(headFactor);
|
||||
}
|
||||
}
|
||||
|
||||
//sever joints
|
||||
if (attack.SeverLimbsProbability > 0.0f)
|
||||
{
|
||||
@@ -402,5 +411,7 @@ namespace Barotrauma
|
||||
|
||||
return damagedStructures;
|
||||
}
|
||||
|
||||
static partial void PlayTinnitusProjSpecific(float volume);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,23 @@ namespace Barotrauma
|
||||
get { return Math.Min((float)Math.Sqrt(size.X) * 10.0f, MaxDamageRange); }
|
||||
}
|
||||
|
||||
public bool DamagesItems
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool DamagesCharacters
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool Removed
|
||||
{
|
||||
get { return removed; }
|
||||
}
|
||||
|
||||
public Hull Hull
|
||||
{
|
||||
get { return hull; }
|
||||
@@ -80,7 +97,7 @@ namespace Barotrauma
|
||||
if (hull == null || worldPosition.Y < hull.WorldSurface) return;
|
||||
|
||||
#if CLIENT
|
||||
if (!isNetworkMessage && GameMain.Client != null) return;
|
||||
if (!isNetworkMessage && GameMain.Client != null) { return; }
|
||||
#endif
|
||||
|
||||
hull.AddFireSource(this);
|
||||
@@ -140,9 +157,43 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void UpdateAll(List<DummyFireSource> fireSources, float deltaTime)
|
||||
{
|
||||
for (int i = fireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
fireSources[i].Update(deltaTime);
|
||||
}
|
||||
|
||||
//combine overlapping fires
|
||||
for (int i = fireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
for (int j = i - 1; j >= 0; j--)
|
||||
{
|
||||
i = Math.Min(i, fireSources.Count - 1);
|
||||
j = Math.Min(j, i - 1);
|
||||
|
||||
if (!fireSources[i].CheckOverLap(fireSources[j])) { continue; }
|
||||
|
||||
float leftEdge = Math.Min(fireSources[i].position.X, fireSources[j].position.X);
|
||||
|
||||
fireSources[j].size.X =
|
||||
Math.Max(fireSources[i].position.X + fireSources[i].size.X, fireSources[j].position.X + fireSources[j].size.X)
|
||||
- leftEdge;
|
||||
|
||||
fireSources[j].position.X = leftEdge;
|
||||
fireSources[i].Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckOverLap(FireSource fireSource)
|
||||
{
|
||||
if (this is DummyFireSource != fireSource is DummyFireSource)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(position.X > fireSource.position.X + fireSource.size.X ||
|
||||
position.X + size.X < fireSource.position.X);
|
||||
}
|
||||
@@ -152,8 +203,8 @@ namespace Barotrauma
|
||||
//the firesource will start to shrink if oxygen percentage is below 10
|
||||
float growModifier = Math.Min((hull.OxygenPercentage / 10.0f) - 1.0f, 1.0f);
|
||||
|
||||
DamageCharacters(deltaTime);
|
||||
DamageItems(deltaTime);
|
||||
if (DamagesCharacters) { DamageCharacters(deltaTime); }
|
||||
if (DamagesItems) { DamageItems(deltaTime); }
|
||||
|
||||
if (hull.WaterVolume > 0.0f)
|
||||
{
|
||||
@@ -161,7 +212,10 @@ namespace Barotrauma
|
||||
if (removed) { return; }
|
||||
}
|
||||
|
||||
ReduceOxygen(deltaTime);
|
||||
if (!(this is DummyFireSource))
|
||||
{
|
||||
ReduceOxygen(deltaTime);
|
||||
}
|
||||
|
||||
AdjustXPos(growModifier, deltaTime);
|
||||
|
||||
@@ -175,21 +229,21 @@ namespace Barotrauma
|
||||
|
||||
LimitSize();
|
||||
|
||||
if (size.X > 256.0f)
|
||||
if (size.X > 256.0f && !(this is DummyFireSource))
|
||||
{
|
||||
if (burnDecals.Count == 0)
|
||||
{
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition + size / 2, 1f, true);
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition + size / 2, 1f, isNetworkEvent: false);
|
||||
if (newDecal != null) { burnDecals.Add(newDecal); }
|
||||
}
|
||||
else if (WorldPosition.X < burnDecals[0].WorldPosition.X - 256.0f)
|
||||
{
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition, 1f, true);
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition, 1f, isNetworkEvent: false);
|
||||
if (newDecal != null) { burnDecals.Insert(0, newDecal); }
|
||||
}
|
||||
else if (WorldPosition.X + size.X > burnDecals[burnDecals.Count - 1].WorldPosition.X + 256.0f)
|
||||
{
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition + Vector2.UnitX * size.X, 1f, true);
|
||||
var newDecal = hull.AddDecal("burnt", WorldPosition + Vector2.UnitX * size.X, 1f, isNetworkEvent: false);
|
||||
if (newDecal != null) { burnDecals.Add(newDecal); }
|
||||
}
|
||||
}
|
||||
@@ -281,14 +335,13 @@ namespace Barotrauma
|
||||
|
||||
private void DamageItems(float deltaTime)
|
||||
{
|
||||
if (size.X <= 0.0f) return;
|
||||
if (size.X <= 0.0f) { return; }
|
||||
#if CLIENT
|
||||
if (GameMain.Client != null) return;
|
||||
if (GameMain.Client != null) { return; }
|
||||
#endif
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue;
|
||||
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) { continue; }
|
||||
|
||||
//don't apply OnFire effects if the item is inside a fireproof container
|
||||
//(or if it's inside a container that's inside a fireproof container, etc)
|
||||
@@ -300,8 +353,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
float range = (float)Math.Sqrt(size.X) * 10.0f;
|
||||
if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue;
|
||||
if (item.Position.Y < position.Y - size.Y || item.Position.Y > hull.Rect.Y) continue;
|
||||
if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) { continue; }
|
||||
if (item.Position.Y < position.Y - size.Y || item.Position.Y > hull.Rect.Y) { continue; }
|
||||
|
||||
item.ApplyStatusEffects(ActionType.OnFire, deltaTime);
|
||||
if (item.Condition <= 0.0f && GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!MathUtils.IsValid(amount))
|
||||
{
|
||||
DebugConsole.ThrowError($"Attempted to move a gap by an invalid amount ({amount})\n{Environment.StackTrace}");
|
||||
DebugConsole.ThrowError($"Attempted to move a gap by an invalid amount ({amount})\n{Environment.StackTrace.CleanupStackTrace()}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +389,8 @@ namespace Barotrauma
|
||||
|
||||
public List<FireSource> FireSources { get; private set; }
|
||||
|
||||
public List<DummyFireSource> FakeFireSources { get; private set; }
|
||||
|
||||
public Hull(MapEntityPrefab prefab, Rectangle rectangle)
|
||||
: this (prefab, rectangle, Submarine.MainSub)
|
||||
{
|
||||
@@ -405,6 +407,7 @@ namespace Barotrauma
|
||||
OxygenPercentage = 100.0f;
|
||||
|
||||
FireSources = new List<FireSource>();
|
||||
FakeFireSources = new List<DummyFireSource>();
|
||||
|
||||
properties = SerializableProperty.GetProperties(this);
|
||||
|
||||
@@ -554,7 +557,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!MathUtils.IsValid(amount))
|
||||
{
|
||||
DebugConsole.ThrowError($"Attempted to move a hull by an invalid amount ({amount})\n{Environment.StackTrace}");
|
||||
DebugConsole.ThrowError($"Attempted to move a hull by an invalid amount ({amount})\n{Environment.StackTrace.CleanupStackTrace()}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -583,11 +586,13 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
List<FireSource> fireSourcesToRemove = new List<FireSource>(FireSources);
|
||||
fireSourcesToRemove.AddRange(FakeFireSources);
|
||||
foreach (FireSource fireSource in fireSourcesToRemove)
|
||||
{
|
||||
fireSource.Remove();
|
||||
}
|
||||
FireSources.Clear();
|
||||
FakeFireSources.Clear();
|
||||
|
||||
if (EntityGrids != null)
|
||||
{
|
||||
@@ -627,10 +632,17 @@ namespace Barotrauma
|
||||
|
||||
public void AddFireSource(FireSource fireSource)
|
||||
{
|
||||
FireSources.Add(fireSource);
|
||||
if (fireSource is DummyFireSource dummyFire)
|
||||
{
|
||||
FakeFireSources.Add(dummyFire);
|
||||
}
|
||||
else
|
||||
{
|
||||
FireSources.Add(fireSource);
|
||||
}
|
||||
}
|
||||
|
||||
public Decal AddDecal(UInt32 decalId, Vector2 worldPosition, float scale, bool isNetworkEvent)
|
||||
public Decal AddDecal(UInt32 decalId, Vector2 worldPosition, float scale, bool isNetworkEvent, int? spriteIndex = null)
|
||||
{
|
||||
//clients are only allowed to create decals when the server says so
|
||||
if (!isNetworkEvent && GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
|
||||
@@ -644,11 +656,11 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError($"Could not find a decal prefab with the UInt identifier {decalId}!");
|
||||
return null;
|
||||
}
|
||||
return AddDecal(decal.Name, worldPosition, scale, isNetworkEvent);
|
||||
return AddDecal(decal.Name, worldPosition, scale, isNetworkEvent, spriteIndex);
|
||||
}
|
||||
|
||||
|
||||
public Decal AddDecal(string decalName, Vector2 worldPosition, float scale, bool isNetworkEvent)
|
||||
public Decal AddDecal(string decalName, Vector2 worldPosition, float scale, bool isNetworkEvent, int? spriteIndex = null)
|
||||
{
|
||||
//clients are only allowed to create decals when the server says so
|
||||
if (!isNetworkEvent && GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
|
||||
@@ -658,7 +670,7 @@ namespace Barotrauma
|
||||
|
||||
if (decals.Count >= MaxDecalsPerHull) { return null; }
|
||||
|
||||
var decal = GameMain.DecalManager.CreateDecal(decalName, scale, worldPosition, this);
|
||||
var decal = GameMain.DecalManager.CreateDecal(decalName, scale, worldPosition, this, spriteIndex);
|
||||
if (decal != null)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
|
||||
@@ -679,7 +691,19 @@ namespace Barotrauma
|
||||
|
||||
Oxygen -= OxygenDeteriorationSpeed * deltaTime;
|
||||
|
||||
if ((Character.Controlled?.CharacterHealth?.GetAffliction("psychosis")?.Strength ?? 0.0f) <= 0.0f)
|
||||
{
|
||||
for (int i = FakeFireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (FakeFireSources[i].CausedByPsychosis)
|
||||
{
|
||||
FakeFireSources[i].Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FireSource.UpdateAll(FireSources, deltaTime);
|
||||
FireSource.UpdateAll(FakeFireSources, deltaTime);
|
||||
|
||||
foreach (Decal decal in decals)
|
||||
{
|
||||
@@ -687,7 +711,6 @@ namespace Barotrauma
|
||||
}
|
||||
decals.RemoveAll(d => d.FadeTimer >= d.LifeTime || d.BaseAlpha <= 0.001f);
|
||||
|
||||
|
||||
if (aiTarget != null)
|
||||
{
|
||||
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
|
||||
@@ -842,17 +865,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void Extinguish(float deltaTime, float amount, Vector2 position)
|
||||
public void Extinguish(float deltaTime, float amount, Vector2 position, bool extinguishRealFires = true, bool extinguishFakeFires = true)
|
||||
{
|
||||
for (int i = FireSources.Count - 1; i >= 0; i--)
|
||||
if (extinguishRealFires)
|
||||
{
|
||||
FireSources[i].Extinguish(deltaTime, amount, position);
|
||||
for (int i = FireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
FireSources[i].Extinguish(deltaTime, amount, position);
|
||||
}
|
||||
}
|
||||
if (extinguishFakeFires)
|
||||
{
|
||||
for (int i = FakeFireSources.Count - 1; i >= 0; i--)
|
||||
{
|
||||
FakeFireSources[i].Extinguish(deltaTime, amount, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveFire(FireSource fire)
|
||||
{
|
||||
FireSources.Remove(fire);
|
||||
if (fire is DummyFireSource dummyFire)
|
||||
{
|
||||
FakeFireSources.Remove(dummyFire);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly HashSet<Hull> adjacentHulls = new HashSet<Hull>();
|
||||
@@ -1221,7 +1258,7 @@ namespace Barotrauma
|
||||
return index >= 0 && row >= 0 && BackgroundSections.Count > index && BackgroundSections[index] != null && BackgroundSections[index].RowIndex == row;
|
||||
}
|
||||
|
||||
public void SetSectionColorOrStrength(BackgroundSection section, Color? color, float? strength, bool requiresUpdate, bool isCleaning)
|
||||
public void IncreaseSectionColorOrStrength(BackgroundSection section, Color? color, float? strength, bool requiresUpdate, bool isCleaning)
|
||||
{
|
||||
bool sectionUpdated = isCleaning;
|
||||
if (color != null)
|
||||
@@ -1263,13 +1300,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSectionColorOrStrength(BackgroundSection section, Color? color, float? strength)
|
||||
{
|
||||
if (color != null)
|
||||
{
|
||||
section.SetColor(color.Value);
|
||||
}
|
||||
|
||||
if (strength != null)
|
||||
{
|
||||
float previous = section.SetColorStrength(Math.Max(minColorStrength, Math.Min(maxColorStrength, section.ColorStrength + strength.Value)));
|
||||
if (previous != -1f)
|
||||
{
|
||||
#if CLIENT
|
||||
paintAmount = Math.Max(0, paintAmount + (section.ColorStrength - previous) / BackgroundSections.Count);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DirtySections(List<BackgroundSection> sections, float dirtyVal)
|
||||
{
|
||||
if (sections == null) { return; }
|
||||
for (int i = 0; i < sections.Count; i++)
|
||||
{
|
||||
float sectionDirtyVal = dirtyVal;
|
||||
SetSectionColorOrStrength(sections[i], sections[i].DirtColor, sectionDirtyVal, false, false);
|
||||
IncreaseSectionColorOrStrength(sections[i], sections[i].DirtColor, dirtyVal, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,11 +1338,14 @@ namespace Barotrauma
|
||||
{
|
||||
decal.Clean(cleanVal);
|
||||
decalsCleaned = true;
|
||||
#if SERVER
|
||||
decalUpdatePending = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (section.ColorStrength == 0 && !decalsCleaned) { return; }
|
||||
SetSectionColorOrStrength(section, null, cleanVal, updateRequired, true);
|
||||
IncreaseSectionColorOrStrength(section, null, cleanVal, updateRequired, true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1341,10 +1399,12 @@ namespace Barotrauma
|
||||
Vector2 pos = subElement.GetAttributeVector2("pos", Vector2.Zero);
|
||||
float scale = subElement.GetAttributeFloat("scale", 1.0f);
|
||||
float timer = subElement.GetAttributeFloat("timer", 1.0f);
|
||||
float baseAlpha = subElement.GetAttributeFloat("alpha", 1.0f);
|
||||
var decal = hull.AddDecal(id, pos + hull.WorldRect.Location.ToVector2(), scale, true);
|
||||
if (decal != null)
|
||||
{
|
||||
decal.FadeTimer = timer;
|
||||
decal.BaseAlpha = baseAlpha;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1362,7 +1422,7 @@ namespace Barotrauma
|
||||
if (int.TryParse(backgroundSectionData[0], out int index) &&
|
||||
float.TryParse(backgroundSectionData[2], NumberStyles.Any, CultureInfo.InvariantCulture, out float strength))
|
||||
{
|
||||
hull.SetSectionColorOrStrength(hull.BackgroundSections[index], color, strength, false, false);
|
||||
hull.SetSectionColorOrStrength(hull.BackgroundSections[index], color, strength);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1377,7 +1437,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (Submarine == null)
|
||||
{
|
||||
string errorMsg = "Error - tried to save a hull that's not a part of any submarine.\n" + Environment.StackTrace;
|
||||
string errorMsg = "Error - tried to save a hull that's not a part of any submarine.\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Hull.Save:WorldHull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return null;
|
||||
@@ -1420,7 +1480,8 @@ namespace Barotrauma
|
||||
new XAttribute("id", decal.Prefab.Identifier),
|
||||
new XAttribute("pos", XMLExtensions.Vector2ToString(decal.NonClampedPosition)),
|
||||
new XAttribute("scale", decal.Scale.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("timer", decal.FadeTimer.ToString("G", CultureInfo.InvariantCulture))
|
||||
new XAttribute("timer", decal.FadeTimer.ToString("G", CultureInfo.InvariantCulture)),
|
||||
new XAttribute("alpha", decal.BaseAlpha.ToString("G", CultureInfo.InvariantCulture))
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,13 @@ namespace Barotrauma
|
||||
|
||||
protected override void CreateInstance(Rectangle rect)
|
||||
{
|
||||
CreateInstance(rect.Location.ToVector2(), Submarine.MainSub);
|
||||
var loaded = CreateInstance(rect.Location.ToVector2(), Submarine.MainSub);
|
||||
#if CLIENT
|
||||
if (Screen.Selected is SubEditorScreen)
|
||||
{
|
||||
SubEditorScreen.StoreCommand(new AddOrDeleteCommand(loaded, false));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public List<MapEntity> CreateInstance(Vector2 position, Submarine sub, bool selectPrefabs = false)
|
||||
|
||||
@@ -1398,7 +1398,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (!suitablePositions.Any())
|
||||
{
|
||||
string errorMsg = "Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace;
|
||||
string errorMsg = "Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:PositionTypeNotFound", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
@@ -1418,7 +1418,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (!farEnoughPositions.Any())
|
||||
{
|
||||
string errorMsg = "Could not find a position of interest far enough from the submarines. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace;
|
||||
string errorMsg = "Could not find a position of interest far enough from the submarines. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace.CleanupStackTrace();
|
||||
GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:TooCloseToSubs", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
|
||||
@@ -132,7 +132,15 @@ namespace Barotrauma
|
||||
|
||||
public override MapEntity Clone()
|
||||
{
|
||||
return CreateDummy(Submarine, filePath, Position);
|
||||
|
||||
var path = filePath;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
var linkedSubmarine = CreateDummy(Submarine, saveElement, Position);
|
||||
linkedSubmarine.saveElement = saveElement;
|
||||
return linkedSubmarine;
|
||||
}
|
||||
return CreateDummy(Submarine, path, Position);
|
||||
}
|
||||
|
||||
private void GenerateWallVertices(XElement rootElement)
|
||||
@@ -176,7 +184,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
string levelSeed = element.GetAttributeString("location", "");
|
||||
LevelData levelData = GameMain.GameSession.Campaign?.NextLevel ?? GameMain.GameSession.Level?.LevelData;
|
||||
LevelData levelData = GameMain.GameSession.Campaign?.NextLevel ?? GameMain.GameSession.LevelData;
|
||||
linkedSub = new LinkedSubmarine(submarine)
|
||||
{
|
||||
purchasedLostShuttles = GameMain.GameSession.GameMode is CampaignMode campaign && campaign.PurchasedLostShuttles,
|
||||
|
||||
@@ -424,12 +424,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (!Type.HasHireableCharacters)
|
||||
{
|
||||
DebugConsole.ThrowError("Cannot hire a character from location \"" + Name + "\" - the location has no hireable characters.\n" + Environment.StackTrace);
|
||||
DebugConsole.ThrowError("Cannot hire a character from location \"" + Name + "\" - the location has no hireable characters.\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
if (HireManager == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Cannot hire a character from location \"" + Name + "\" - hire manager has not been instantiated.\n" + Environment.StackTrace);
|
||||
DebugConsole.ThrowError("Cannot hire a character from location \"" + Name + "\" - hire manager has not been instantiated.\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -524,12 +524,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (SelectedConnection == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not move to the next location (no connection selected).\n"+Environment.StackTrace);
|
||||
DebugConsole.ThrowError("Could not move to the next location (no connection selected).\n"+Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
if (SelectedLocation == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not move to the next location (no location selected).\n" + Environment.StackTrace);
|
||||
DebugConsole.ThrowError("Could not move to the next location (no location selected).\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
"MapEntity.Clone:" + e.Name,
|
||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||
"Cloning entity \"" + e.Name + "\" failed (" + ex.Message + ").\n" + ex.StackTrace);
|
||||
"Cloning entity \"" + e.Name + "\" failed (" + ex.Message + ").\n" + ex.StackTrace.CleanupStackTrace());
|
||||
return clones;
|
||||
}
|
||||
Debug.Assert(clones.Last() != null);
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace Barotrauma
|
||||
|
||||
if (showErrorMessages)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to find a matching MapEntityPrefab (name: \"" + name + "\", identifier: \"" + identifier + "\").\n" + Environment.StackTrace);
|
||||
DebugConsole.ThrowError("Failed to find a matching MapEntityPrefab (name: \"" + name + "\", identifier: \"" + identifier + "\").\n" + Environment.StackTrace.CleanupStackTrace());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.NewMessage($"Failed to load hash cache: {e.Message}\n{e.StackTrace}", Microsoft.Xna.Framework.Color.Orange);
|
||||
DebugConsole.NewMessage($"Failed to load hash cache: {e.Message}\n{e.StackTrace.CleanupStackTrace()}", Microsoft.Xna.Framework.Color.Orange);
|
||||
cache.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class OrderTarget : ISpatialEntity
|
||||
{
|
||||
public Vector2 Position { get; private set; }
|
||||
public Hull Hull { get; private set; }
|
||||
|
||||
public Vector2 WorldPosition => Submarine == null ? Position : Position + Submarine.Position;
|
||||
public Vector2 SimPosition => ConvertUnits.ToSimUnits(Position);
|
||||
public Submarine Submarine => Hull?.Submarine;
|
||||
|
||||
public OrderTarget(Vector2 position, Hull hull, bool creatingFromExistingData = false)
|
||||
{
|
||||
if (!creatingFromExistingData && hull?.Submarine != null) { position -= hull.Submarine.Position; }
|
||||
Position = position;
|
||||
Hull = hull;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1407,11 +1407,16 @@ namespace Barotrauma
|
||||
if (item != null) { item.SpawnedInOutpost = true; }
|
||||
}
|
||||
npc.GiveIdCardTags(gotoTarget as WayPoint);
|
||||
var humanAI = npc.AIController as HumanAIController;
|
||||
if (humanAI != null)
|
||||
if (npc.AIController is HumanAIController humanAI)
|
||||
{
|
||||
var idleObjective = humanAI.ObjectiveManager.GetObjective<AIObjectiveIdle>();
|
||||
if (idleObjective != null)
|
||||
if (humanPrefab.CampaignInteractionType != CampaignMode.InteractionType.None)
|
||||
{
|
||||
idleObjective.Behavior = AIObjectiveIdle.BehaviorType.StayInHull;
|
||||
idleObjective.TargetHull = AIObjectiveGoTo.GetTargetHull(gotoTarget);
|
||||
(GameMain.GameSession.GameMode as CampaignMode)?.AssignNPCMenuInteraction(npc, humanPrefab.CampaignInteractionType);
|
||||
}
|
||||
else
|
||||
{
|
||||
idleObjective.Behavior = humanPrefab.BehaviorType;
|
||||
foreach (string moduleType in humanPrefab.PreferredOutpostModuleTypes)
|
||||
@@ -1420,21 +1425,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanPrefab.CampaignInteractionType != CampaignMode.InteractionType.None)
|
||||
{
|
||||
if (humanAI != null)
|
||||
{
|
||||
Hull goToHull = gotoTarget as Hull ?? (gotoTarget as WayPoint)?.CurrentHull ?? (gotoTarget as Item)?.CurrentHull;
|
||||
var goToObjective = new AIObjectiveGoTo(gotoTarget, npc, humanAI.ObjectiveManager, repeat: true, getDivingGearIfNeeded: false, closeEnough: 200);
|
||||
if (goToHull != null)
|
||||
{
|
||||
goToObjective.priorityGetter = () => npc.CurrentHull == goToHull ? 0.0f : AIObjectiveManager.OrderPriority;
|
||||
}
|
||||
humanAI.ObjectiveManager.SetOrder(goToObjective);
|
||||
humanAI.ObjectiveManager.GetObjective<AIObjectiveIdle>().Behavior = AIObjectiveIdle.BehaviorType.StayInHull;
|
||||
}
|
||||
(GameMain.GameSession.GameMode as CampaignMode)?.AssignNPCMenuInteraction(npc, humanPrefab.CampaignInteractionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!MathUtils.IsValid(amount))
|
||||
{
|
||||
DebugConsole.ThrowError($"Attempted to move a structure by an invalid amount ({amount})\n{Environment.StackTrace}");
|
||||
DebugConsole.ThrowError($"Attempted to move a structure by an invalid amount ({amount})\n{Environment.StackTrace.CleanupStackTrace()}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -986,12 +986,20 @@ namespace Barotrauma
|
||||
{
|
||||
diffFromCenter = (gapRect.Center.X - this.rect.Center.X) / (float)this.rect.Width * BodyWidth;
|
||||
if (BodyWidth > 0.0f) { gapRect.Width = (int)(BodyWidth * (gapRect.Width / (float)this.rect.Width)); }
|
||||
if (BodyHeight > 0.0f) { gapRect.Height = (int)BodyHeight; }
|
||||
if (BodyHeight > 0.0f)
|
||||
{
|
||||
gapRect.Y = (gapRect.Y - gapRect.Height / 2) + (int)(BodyHeight / 2 + BodyOffset.Y * scale);
|
||||
gapRect.Height = (int)BodyHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
diffFromCenter = ((gapRect.Y - gapRect.Height / 2) - (this.rect.Y - this.rect.Height / 2)) / (float)this.rect.Height * BodyHeight;
|
||||
if (BodyWidth > 0.0f) { gapRect.Width = (int)BodyWidth; }
|
||||
if (BodyWidth > 0.0f)
|
||||
{
|
||||
gapRect.X = gapRect.Center.X + (int)(-BodyWidth / 2 + BodyOffset.X * scale);
|
||||
gapRect.Width = (int)BodyWidth;
|
||||
}
|
||||
if (BodyHeight > 0.0f) { gapRect.Height = (int)(BodyHeight * (gapRect.Height / (float)this.rect.Height)); }
|
||||
}
|
||||
if (FlippedX) { diffFromCenter = -diffFromCenter; }
|
||||
@@ -1001,7 +1009,7 @@ namespace Barotrauma
|
||||
Vector2 structureCenter = Position;
|
||||
Vector2 gapPos = structureCenter + new Vector2(
|
||||
(float)Math.Cos(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation),
|
||||
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation)) * diffFromCenter;
|
||||
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation)) * diffFromCenter + BodyOffset * scale;
|
||||
gapRect = new Rectangle((int)(gapPos.X - gapRect.Width / 2), (int)(gapPos.Y + gapRect.Height / 2), gapRect.Width, gapRect.Height);
|
||||
}
|
||||
|
||||
|
||||
@@ -661,7 +661,7 @@ namespace Barotrauma
|
||||
catch (System.IO.FileNotFoundException e)
|
||||
{
|
||||
exception = e;
|
||||
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed! (File not found) " + Environment.StackTrace, e);
|
||||
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed! (File not found) " + Environment.StackTrace.CleanupStackTrace(), e);
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user