Unstable 0.17.0.0
This commit is contained in:
@@ -101,8 +101,8 @@ namespace Barotrauma
|
||||
|
||||
partial class Hull : MapEntity, ISerializableEntity, IServerSerializable
|
||||
{
|
||||
public static List<Hull> hullList = new List<Hull>();
|
||||
public static List<EntityGrid> EntityGrids { get; } = new List<EntityGrid>();
|
||||
public readonly static List<Hull> HullList = new List<Hull>();
|
||||
public readonly static List<EntityGrid> EntityGrids = new List<EntityGrid>();
|
||||
|
||||
public static bool ShowHulls = true;
|
||||
|
||||
@@ -124,8 +124,8 @@ namespace Barotrauma
|
||||
|
||||
public const int BackgroundSectionsPerNetworkEvent = 16;
|
||||
|
||||
public readonly Dictionary<string, SerializableProperty> properties;
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties
|
||||
public readonly Dictionary<Identifier, SerializableProperty> properties;
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties
|
||||
{
|
||||
get { return properties; }
|
||||
}
|
||||
@@ -155,32 +155,23 @@ namespace Barotrauma
|
||||
|
||||
public readonly List<Gap> ConnectedGaps = new List<Gap>();
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Hull";
|
||||
}
|
||||
}
|
||||
public override string Name => "Hull";
|
||||
|
||||
public string DisplayName
|
||||
public LocalizedString DisplayName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private readonly HashSet<string> moduleTags = new HashSet<string>();
|
||||
private readonly HashSet<Identifier> moduleTags = new HashSet<Identifier>();
|
||||
|
||||
/// <summary>
|
||||
/// Inherited flags from outpost generation.
|
||||
/// </summary>
|
||||
public IEnumerable<string> OutpostModuleTags
|
||||
{
|
||||
get { return moduleTags; }
|
||||
}
|
||||
public IEnumerable<Identifier> OutpostModuleTags => moduleTags;
|
||||
|
||||
private string roomName;
|
||||
[Editable, Serialize("", true, translationTextTag: "RoomName.")]
|
||||
[Editable, Serialize("", IsPropertySaveable.Yes, translationTextTag: "RoomName.")]
|
||||
public string RoomName
|
||||
{
|
||||
get { return roomName; }
|
||||
@@ -188,7 +179,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (roomName == value) { return; }
|
||||
roomName = value;
|
||||
DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName;
|
||||
DisplayName = TextManager.Get(roomName).Fallback(roomName);
|
||||
if (!IsWetRoom && ForceAsWetRoom)
|
||||
{
|
||||
IsWetRoom = true;
|
||||
@@ -200,7 +191,7 @@ namespace Barotrauma
|
||||
|
||||
private Color ambientLight;
|
||||
|
||||
[Editable, Serialize("0,0,0,0", true)]
|
||||
[Editable, Serialize("0,0,0,0", IsPropertySaveable.Yes)]
|
||||
public Color AmbientLight
|
||||
{
|
||||
get { return ambientLight; }
|
||||
@@ -314,7 +305,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(100000.0f, true)]
|
||||
[Serialize(100000.0f, IsPropertySaveable.Yes)]
|
||||
public float Oxygen
|
||||
{
|
||||
get { return oxygen; }
|
||||
@@ -332,7 +323,7 @@ namespace Barotrauma
|
||||
roomName.Contains("airlock", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private bool isWetRoom;
|
||||
[Editable, Serialize(false, true, description: "It's normal for this hull to be filled with water. If the room name contains 'ballast', 'bilge', or 'airlock', you can't disable this setting.")]
|
||||
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "It's normal for this hull to be filled with water. If the room name contains 'ballast', 'bilge', or 'airlock', you can't disable this setting.")]
|
||||
public bool IsWetRoom
|
||||
{
|
||||
get { return isWetRoom; }
|
||||
@@ -347,7 +338,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private bool avoidStaying;
|
||||
[Editable, Serialize(false, true, description: "Bots avoid staying here, but they are still allowed to access the room when needed and go through it. Forced true for wet rooms.")]
|
||||
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "Bots avoid staying here, but they are still allowed to access the room when needed and go through it. Forced true for wet rooms.")]
|
||||
public bool AvoidStaying
|
||||
{
|
||||
get { return avoidStaying || IsWetRoom; }
|
||||
@@ -469,7 +460,7 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
hullList.Add(this);
|
||||
HullList.Add(this);
|
||||
|
||||
if (submarine == null || !submarine.Loading)
|
||||
{
|
||||
@@ -488,11 +479,11 @@ namespace Barotrauma
|
||||
|
||||
public static Rectangle GetBorders()
|
||||
{
|
||||
if (!hullList.Any()) return Rectangle.Empty;
|
||||
if (!HullList.Any()) return Rectangle.Empty;
|
||||
|
||||
Rectangle rect = hullList[0].rect;
|
||||
Rectangle rect = HullList[0].rect;
|
||||
|
||||
foreach (Hull hull in hullList)
|
||||
foreach (Hull hull in HullList)
|
||||
{
|
||||
if (hull.Rect.X < rect.X)
|
||||
{
|
||||
@@ -516,12 +507,15 @@ namespace Barotrauma
|
||||
|
||||
public override MapEntity Clone()
|
||||
{
|
||||
var clone = new Hull(MapEntityPrefab.Find(null, "hull"), rect, Submarine);
|
||||
foreach (KeyValuePair<string, SerializableProperty> property in SerializableProperties)
|
||||
var clone = new Hull(MapEntityPrefab.FindByIdentifier("hull".ToIdentifier()), rect, Submarine);
|
||||
foreach (KeyValuePair<Identifier, SerializableProperty> property in SerializableProperties)
|
||||
{
|
||||
if (!property.Value.Attributes.OfType<Editable>().Any()) { continue; }
|
||||
clone.SerializableProperties[property.Key].TrySetValue(clone, property.Value.GetValue(this));
|
||||
}
|
||||
#if CLIENT
|
||||
clone.lastAmbientLightEditTime = 0.0;
|
||||
#endif
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -536,17 +530,17 @@ namespace Barotrauma
|
||||
{
|
||||
var newGrid = new EntityGrid(submarine, 200.0f);
|
||||
EntityGrids.Add(newGrid);
|
||||
foreach (Hull hull in hullList)
|
||||
foreach (Hull hull in HullList)
|
||||
{
|
||||
if (hull.Submarine == submarine && !hull.IdFreed) { newGrid.InsertEntity(hull); }
|
||||
}
|
||||
return newGrid;
|
||||
}
|
||||
|
||||
public void SetModuleTags(IEnumerable<string> tags)
|
||||
public void SetModuleTags(IEnumerable<Identifier> tags)
|
||||
{
|
||||
moduleTags.Clear();
|
||||
foreach (string tag in tags)
|
||||
foreach (Identifier tag in tags)
|
||||
{
|
||||
moduleTags.Add(tag);
|
||||
}
|
||||
@@ -630,7 +624,7 @@ namespace Barotrauma
|
||||
public override void ShallowRemove()
|
||||
{
|
||||
base.Remove();
|
||||
hullList.Remove(this);
|
||||
HullList.Remove(this);
|
||||
|
||||
if (Submarine == null || (!Submarine.Loading && !Submarine.Unloading))
|
||||
{
|
||||
@@ -659,7 +653,7 @@ namespace Barotrauma
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
hullList.Remove(this);
|
||||
HullList.Remove(this);
|
||||
BallastFlora?.Remove();
|
||||
|
||||
if (Submarine != null && !Submarine.Loading && !Submarine.Unloading)
|
||||
@@ -712,7 +706,7 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
|
||||
var decal = GameMain.DecalManager.Prefabs.Find(p => p.UIntIdentifier == decalId);
|
||||
var decal = DecalManager.Prefabs.Find(p => p.UintIdentifier == decalId);
|
||||
if (decal == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find a decal prefab with the UInt identifier {decalId}!");
|
||||
@@ -732,7 +726,7 @@ namespace Barotrauma
|
||||
|
||||
if (decals.Count >= MaxDecalsPerHull) { return null; }
|
||||
|
||||
var decal = GameMain.DecalManager.CreateDecal(decalName, scale, worldPosition, this, spriteIndex);
|
||||
var decal = DecalManager.CreateDecal(decalName, scale, worldPosition, this, spriteIndex);
|
||||
if (decal != null)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
|
||||
@@ -1110,12 +1104,12 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public static Hull FindHullUnoptimized(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = true)
|
||||
{
|
||||
if (guess != null && hullList.Contains(guess))
|
||||
if (guess != null && HullList.Contains(guess))
|
||||
{
|
||||
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position, inclusive)) return guess;
|
||||
}
|
||||
|
||||
foreach (Hull hull in hullList)
|
||||
foreach (Hull hull in HullList)
|
||||
{
|
||||
if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position, inclusive)) return hull;
|
||||
}
|
||||
@@ -1135,15 +1129,15 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
Hull h = c.CurrentHull;
|
||||
hullList.ForEach(j => j.Visible = false);
|
||||
HullList.ForEach(j => j.Visible = false);
|
||||
List<Hull> visibleHulls;
|
||||
if (h == null || c.Submarine == null)
|
||||
{
|
||||
visibleHulls = hullList.FindAll(j => j.CanSeeOther(null, false));
|
||||
visibleHulls = HullList.FindAll(j => j.CanSeeOther(null, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
visibleHulls = hullList.FindAll(j => h.CanSeeOther(j, true));
|
||||
visibleHulls = HullList.FindAll(j => h.CanSeeOther(j, true));
|
||||
}
|
||||
visibleHulls.ForEach(j => j.Visible = true);
|
||||
foreach (Item it in Item.ItemList)
|
||||
@@ -1164,7 +1158,7 @@ namespace Barotrauma
|
||||
foreach (Gap g in ConnectedGaps)
|
||||
{
|
||||
if (g.ConnectedWall != null && g.ConnectedWall.CastShadow) continue;
|
||||
List<Hull> otherHulls = hullList.FindAll(h => h.ConnectedGaps.Contains(g) && h != this);
|
||||
List<Hull> otherHulls = HullList.FindAll(h => h.ConnectedGaps.Contains(g) && h != this);
|
||||
retVal = otherHulls.Any(h => h == other);
|
||||
if (!retVal && allowIndirect) retVal = otherHulls.Any(h => h.CanSeeOther(other, false));
|
||||
if (retVal) return true;
|
||||
@@ -1174,7 +1168,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Gap g in ConnectedGaps)
|
||||
{
|
||||
if (g.ConnectedDoor != null && !hullList.Any(h => h.ConnectedGaps.Contains(g) && h != this)) return true;
|
||||
if (g.ConnectedDoor != null && !HullList.Any(h => h.ConnectedGaps.Contains(g) && h != this)) return true;
|
||||
}
|
||||
List<MapEntity> structures = mapEntityList.FindAll(me => me is Structure && me.Rect.Intersects(Rect));
|
||||
return structures.Any(st => !(st as Structure).CastShadow);
|
||||
@@ -1209,7 +1203,7 @@ namespace Barotrauma
|
||||
if (moduleFlags != null && moduleFlags.Any() &&
|
||||
(Submarine.Info.Type == SubmarineType.OutpostModule || Submarine.Info.Type == SubmarineType.Outpost))
|
||||
{
|
||||
if (moduleFlags.Contains("airlock") &&
|
||||
if (moduleFlags.Contains("airlock".ToIdentifier()) &&
|
||||
ConnectedGaps.Any(g => !g.IsRoomToRoom && g.ConnectedDoor != null))
|
||||
{
|
||||
return "RoomName.Airlock";
|
||||
@@ -1313,7 +1307,7 @@ namespace Barotrauma
|
||||
|
||||
public static Hull GetCleanTarget(Vector2 worldPosition)
|
||||
{
|
||||
foreach (Hull hull in hullList)
|
||||
foreach (Hull hull in HullList)
|
||||
{
|
||||
Rectangle worldRect = hull.WorldRect;
|
||||
if (worldPosition.X < worldRect.X || worldPosition.X > worldRect.Right) { continue; }
|
||||
@@ -1476,7 +1470,7 @@ namespace Barotrauma
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Hull Load(XElement element, Submarine submarine, IdRemap idRemap)
|
||||
public static Hull Load(ContentXElement element, Submarine submarine, IdRemap idRemap)
|
||||
{
|
||||
Rectangle rect;
|
||||
if (element.Attribute("rect") != null)
|
||||
@@ -1507,7 +1501,7 @@ namespace Barotrauma
|
||||
hull.OriginalAmbientLight = XMLExtensions.ParseColor(originalAmbientLight, false);
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -1525,7 +1519,7 @@ namespace Barotrauma
|
||||
}
|
||||
break;
|
||||
case "ballastflorabehavior":
|
||||
string identifier = subElement.GetAttributeString("identifier", string.Empty);
|
||||
Identifier identifier = subElement.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
BallastFloraPrefab prefab = BallastFloraPrefab.Find(identifier);
|
||||
if (prefab != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user