Unstable 0.1500.2.0 (Rokvach's dog edition)

This commit is contained in:
Markus Isberg
2021-09-10 04:52:34 +09:00
parent e7b7c1a748
commit 1231170fce
126 changed files with 2424 additions and 1083 deletions
@@ -471,9 +471,8 @@ namespace Barotrauma
{
aiTarget = new AITarget(this)
{
MinSightRange = 2000,
MinSightRange = 1000,
MaxSightRange = 5000,
MaxSoundRange = 5000,
SoundRange = 0
};
}
@@ -787,7 +786,7 @@ namespace Barotrauma
if (aiTarget != null)
{
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : MathHelper.Lerp(aiTarget.MinSightRange, aiTarget.MaxSightRange, Submarine.Velocity.Length() / 10);
aiTarget.SoundRange -= deltaTime * 1000.0f;
}
@@ -1244,6 +1243,44 @@ namespace Barotrauma
return "RoomName.Sub" + roomPos.ToString();
}
/// <summary>
/// Is this hull or any of the items inside it tagged as "airlock"?
/// </summary>
public bool IsTaggedAirlock()
{
if (RoomName != null && RoomName.Contains("airlock", StringComparison.OrdinalIgnoreCase))
{
return true;
}
else
{
foreach (Item item in Item.ItemList)
{
if (item.CurrentHull != this && item.HasTag("airlock"))
{
return true;
}
}
}
return false;
}
/// <summary>
/// Does this hull have any doors leading outside?
/// </summary>
/// <param name="character">Used to check if this character has access to the door leading outside</param>
public bool LeadsOutside(Character character)
{
foreach (var gap in ConnectedGaps)
{
if (gap.ConnectedDoor == null) { continue; }
if (gap.IsRoomToRoom) { continue; }
if (!gap.ConnectedDoor.CanBeTraversed && (character == null || !gap.ConnectedDoor.HasAccess(character))) { continue; }
return true;
}
return false;
}
#region BackgroundSections
private void CreateBackgroundSections()
{
@@ -415,14 +415,13 @@ namespace Barotrauma
//connect clone wires to the clone items and refresh links between doors and gaps
for (int i = 0; i < clones.Count; i++)
{
var cloneItem = clones[i] as Item;
if (cloneItem == null) { continue; }
if (!(clones[i] is Item cloneItem)) { continue; }
var door = cloneItem.GetComponent<Door>();
door?.RefreshLinkedGap();
var cloneWire = cloneItem.GetComponent<Wire>();
if (cloneWire == null) continue;
if (cloneWire == null) { continue; }
var originalWire = ((Item)entitiesToClone[i]).GetComponent<Wire>();
@@ -430,10 +429,23 @@ namespace Barotrauma
for (int n = 0; n < 2; n++)
{
if (originalWire.Connections[n] == null) { continue; }
if (originalWire.Connections[n] == null)
{
var disconnectedFrom = entitiesToClone.Find(e => e is Item item && (item.GetComponent<ConnectionPanel>()?.DisconnectedWires.Contains(originalWire) ?? false));
if (disconnectedFrom == null) { continue; }
int disconnectedFromIndex = entitiesToClone.IndexOf(disconnectedFrom);
var disconnectedFromClone = (clones[disconnectedFromIndex] as Item)?.GetComponent<ConnectionPanel>();
if (disconnectedFromClone == null) { continue; }
disconnectedFromClone.DisconnectedWires.Add(cloneWire);
if (cloneWire.Item.body != null) { cloneWire.Item.body.Enabled = false; }
cloneWire.IsActive = false;
continue;
}
var connectedItem = originalWire.Connections[n].Item;
if (connectedItem == null) continue;
if (connectedItem == null) { continue; }
//index of the item the wire is connected to
int itemIndex = entitiesToClone.IndexOf(connectedItem);
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.Abilities;
#if CLIENT
using Microsoft.Xna.Framework.Graphics;
#endif
@@ -437,8 +438,8 @@ namespace Barotrauma
{
aiTarget = new AITarget(this)
{
MinSightRange = 2000,
MaxSightRange = 5000,
MinSightRange = 1000,
MaxSightRange = 4000,
MaxSoundRange = 0
};
}
@@ -956,11 +957,12 @@ namespace Barotrauma
}
#endif
if (Submarine != null && damageAmount > 0)
if (Submarine != null && damageAmount > 0 && attacker != null)
{
var abilityAttackerSubmarine = new AbilityCharacterSubmarine(attacker, Submarine);
foreach (Character character in Character.CharacterList)
{
character.CheckTalents(AbilityEffectType.AfterSubmarineAttacked, Submarine);
character.CheckTalents(AbilityEffectType.AfterSubmarineAttacked, abilityAttackerSubmarine);
}
}
@@ -1462,7 +1464,7 @@ namespace Barotrauma
{
if (aiTarget != null)
{
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : Submarine.Velocity.Length() / 2 * aiTarget.MaxSightRange;
aiTarget.SightRange = Submarine == null ? aiTarget.MinSightRange : MathHelper.Lerp(aiTarget.MinSightRange, aiTarget.MaxSightRange, Submarine.Velocity.Length() / 10);
}
}
}
@@ -96,6 +96,9 @@ namespace Barotrauma
public OutpostModuleInfo OutpostModuleInfo { get; set; }
public bool IsOutpost => Type == SubmarineType.Outpost || Type == SubmarineType.OutpostModule;
//TODO: replace when the ruin branch is merged
public bool IsRuin => false;
public bool IsWreck => Type == SubmarineType.Wreck;
public bool IsBeacon => Type == SubmarineType.BeaconStation;
public bool IsPlayer => Type == SubmarineType.Player;
@@ -743,7 +746,10 @@ namespace Barotrauma
try
{
stream.Position = 0;
doc = XDocument.Load(stream); //ToolBox.TryLoadXml(file);
using (var reader = XMLExtensions.CreateReader(stream))
{
doc = XDocument.Load(reader);
}
stream.Close();
stream.Dispose();
}
@@ -760,9 +766,10 @@ namespace Barotrauma
try
{
ToolBox.IsProperFilenameCase(file);
doc = XDocument.Load(file, LoadOptions.SetBaseUri);
using var stream = File.Open(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
using var reader = XMLExtensions.CreateReader(stream);
doc = XDocument.Load(reader);
}
catch (Exception e)
{
exception = e;