Unstable 0.17.6.0

This commit is contained in:
Markus Isberg
2022-04-04 16:46:08 +09:00
parent 44ded0225a
commit 95764d1fa8
78 changed files with 1265 additions and 703 deletions
@@ -15,7 +15,6 @@ namespace Barotrauma
public static readonly PrefabCollection<ItemAssemblyPrefab> Prefabs = new PrefabCollection<ItemAssemblyPrefab>();
public static readonly string VanillaSaveFolder = Path.Combine("Content", "Items", "Assemblies");
public static readonly string SaveFolder = "ItemAssemblies";
private readonly XElement configElement;
@@ -282,7 +282,7 @@ namespace Barotrauma
private void PlaceObject(LevelObjectPrefab prefab, SpawnPosition spawnPosition, Level level, Level.Cave parentCave = null)
{
float rotation = 0.0f;
if (prefab.AlignWithSurface && spawnPosition.Normal.LengthSquared() > 0.001f && spawnPosition != null)
if (prefab.AlignWithSurface && spawnPosition != null && spawnPosition.Normal.LengthSquared() > 0.001f)
{
rotation = MathUtils.VectorToAngle(new Vector2(spawnPosition.Normal.Y, spawnPosition.Normal.X));
}
@@ -359,8 +359,8 @@ namespace Barotrauma
/// How many map progress steps it takes before the discounts should be updated.
/// </summary>
private const int SpecialsUpdateInterval = 3;
private int DailySpecialsCount => Type.DailySpecialsCount;
private int RequestedGoodsCount => Type.RequestedGoodsCount;
public int DailySpecialsCount => Type.DailySpecialsCount;
public int RequestedGoodsCount => Type.RequestedGoodsCount;
private int StepsSinceSpecialsUpdated { get; set; }
public HashSet<Identifier> StoreIdentifiers { get; } = new HashSet<Identifier>();
@@ -1138,7 +1138,7 @@ namespace Barotrauma
{
store.Balance = Math.Min(store.Balance + (int)(StoreInitialBalance / 10.0f), StoreInitialBalance);
}
var stock = store.Stock;
var stock = new List<PurchasedItem>(store.Stock);
var stockToRemove = new List<PurchasedItem>();
foreach (var item in stock)
{
@@ -89,22 +89,18 @@ namespace Barotrauma
{
backwardsCompatibleIdentifier = $"merchant{backwardsCompatibleIdentifier}";
}
string[] storeIdentifiers = childElement.GetAttributeStringArray("storeidentifiers", new string[1] { backwardsCompatibleIdentifier });
foreach (string id in storeIdentifiers)
{
if (string.IsNullOrEmpty(id)) { continue; }
// TODO: Add some error messages if we have defined the min or max amount while the item is not sold
var priceInfo = new PriceInfo((int)(priceMultiplier * basePrice),
sold,
sold ? GetMinAmount(childElement, minAmount) : 0,
sold ? GetMaxAmount(childElement, maxAmount) : 0,
canBeSpecial,
storeMinLevelDifficulty,
storeBuyingMultiplier,
displayNonEmpty,
id);
priceInfos.Add(priceInfo);
}
string storeIdentifier = childElement.GetAttributeString("storeidentifier", backwardsCompatibleIdentifier);
// TODO: Add some error messages if we have defined the min or max amount while the item is not sold
var priceInfo = new PriceInfo((int)(priceMultiplier * basePrice),
sold,
sold ? GetMinAmount(childElement, minAmount) : 0,
sold ? GetMaxAmount(childElement, maxAmount) : 0,
canBeSpecial,
storeMinLevelDifficulty,
storeBuyingMultiplier,
displayNonEmpty,
storeIdentifier);
priceInfos.Add(priceInfo);
}
bool soldElsewhere = soldByDefault && element.GetAttributeBool("soldelsewhere", element.GetAttributeBool("soldeverywhere", false));
defaultPrice = new PriceInfo(basePrice,
@@ -313,7 +313,16 @@ namespace Barotrauma
for (float x = hull.Rect.X + diffFromHullEdge; x <= hull.Rect.Right - diffFromHullEdge; x += minDist)
{
var wayPoint = new WayPoint(new Vector2(x, hull.Rect.Y - hull.Rect.Height + waypointHeight), SpawnType.Path, submarine);
if (previousWaypoint != null) { wayPoint.ConnectTo(previousWaypoint); }
// Too close to stairs, will be assigned as a stair point -> remove
if (wayPoint.FindStairs() != null)
{
removals.Add(wayPoint);
continue;
}
if (previousWaypoint != null)
{
wayPoint.ConnectTo(previousWaypoint);
}
previousWaypoint = wayPoint;
}
if (previousWaypoint == null)
@@ -510,25 +519,29 @@ namespace Barotrauma
}
}
}
removals.ForEach(wp => wp.Remove());
removals.Clear();
// Stairs
foreach (MapEntity mapEntity in mapEntityList.ToList())
{
if (!(mapEntity is Structure structure)) { continue; }
if (structure.StairDirection == Direction.None) { continue; }
WayPoint[] stairPoints = new WayPoint[3];
float margin = -32;
stairPoints[0] = new WayPoint(
new Vector2(structure.Rect.X - 32.0f,
structure.Rect.Y - (structure.StairDirection == Direction.Left ? 80 : structure.Rect.Height) + heightFromFloor), SpawnType.Path, submarine);
stairPoints[0] = new WayPoint(new Vector2(
structure.Rect.X + 5,
structure.Rect.Y - (structure.StairDirection == Direction.Left ? margin : structure.Rect.Height - 100)), SpawnType.Path, submarine);
stairPoints[1] = new WayPoint(
new Vector2(structure.Rect.Right + 32.0f,
structure.Rect.Y - (structure.StairDirection == Direction.Left ? structure.Rect.Height : 80) + heightFromFloor), SpawnType.Path, submarine);
stairPoints[1] = new WayPoint(new Vector2(
structure.Rect.Right - 5,
structure.Rect.Y - (structure.StairDirection == Direction.Left ? structure.Rect.Height - 100 : margin)), SpawnType.Path, submarine);
for (int i = 0; i < 2; i++)
{
for (int dir = -1; dir <= 1; dir += 2)
{
WayPoint closest = stairPoints[i].FindClosest(dir, horizontalSearch: true, new Vector2(100, 70));
WayPoint closest = stairPoints[i].FindClosest(dir, horizontalSearch: true, new Vector2(minDist * 1.5f, minDist / 2));
if (closest == null) { continue; }
stairPoints[i].ConnectTo(closest);
}
@@ -537,9 +550,8 @@ namespace Barotrauma
stairPoints[2] = new WayPoint((stairPoints[0].Position + stairPoints[1].Position) / 2, SpawnType.Path, submarine);
stairPoints[0].ConnectTo(stairPoints[2]);
stairPoints[2].ConnectTo(stairPoints[1]);
stairPoints.ForEach(wp => wp.FindStairs());
}
removals.ForEach(wp => wp.Remove());
removals.Clear();
foreach (Item item in Item.ItemList)
{
@@ -840,7 +852,11 @@ namespace Barotrauma
var body = Submarine.CheckVisibility(SimPosition, wp.SimPosition, ignoreLevel: true, ignoreSubs: true, ignoreSensors: false);
if (body != null && body != ignoredBody && !(body.UserData is Submarine))
{
if (body.UserData is Structure || body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall))
if (body.UserData is Structure)
{
continue;
}
if (body.FixtureList[0].CollisionCategories.HasFlag(Physics.CollisionWall) && body.UserData is Item i && i.GetComponent<Door>() != null)
{
continue;
}
@@ -960,14 +976,15 @@ namespace Barotrauma
FindStairs();
}
private void FindStairs()
private Structure FindStairs()
{
Stairs = null;
Body pickedBody = Submarine.PickBody(SimPosition, SimPosition - Vector2.UnitY * 2.0f, null, Physics.CollisionStairs);
Body pickedBody = Submarine.PickBody(SimPosition, SimPosition - new Vector2(0, 1.2f), null, Physics.CollisionStairs);
if (pickedBody != null && pickedBody.UserData is Structure structure && structure.StairDirection != Direction.None)
{
Stairs = structure;
Stairs = structure;
}
return Stairs;
}
public void InitializeLinks()