Build 0.18.0.0

This commit is contained in:
Markus Isberg
2022-05-13 00:55:52 +09:00
parent 15d18e6ff6
commit 7547a9b78a
218 changed files with 3881 additions and 2192 deletions
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using StoreBalanceStatus = Barotrauma.LocationType.StoreBalanceStatus;
namespace Barotrauma
{
@@ -92,21 +91,8 @@ namespace Barotrauma
public class StoreInfo
{
private int balance;
public Identifier Identifier { get; }
public int Balance
{
get
{
return balance;
}
set
{
balance = value;
ActiveBalanceStatus = Location.GetStoreBalanceStatus(value);
}
}
public int Balance { get; set; }
public List<PurchasedItem> Stock { get; } = new List<PurchasedItem>();
public List<ItemPrefab> DailySpecials { get; } = new List<ItemPrefab>();
public List<ItemPrefab> RequestedGoods { get; } = new List<ItemPrefab>();
@@ -114,8 +100,6 @@ namespace Barotrauma
/// In percentages. Larger values make buying more expensive and selling less profitable, and vice versa.
/// </summary>
public int PriceModifier { get; set; }
public StoreBalanceStatus ActiveBalanceStatus { get; private set; }
public Color BalanceColor => ActiveBalanceStatus.Color;
public Location Location { get; }
private StoreInfo(Location location)
@@ -298,14 +282,7 @@ namespace Barotrauma
price = Location.DailySpecialPriceModifier * price;
}
// Adjust by current location reputation
if (Location.Reputation.Value > 0.0f)
{
price = MathHelper.Lerp(1.0f, 1.0f - Location.StoreMaxReputationModifier, Location.Reputation.Value / Location.Reputation.MaxReputation) * price;
}
else
{
price = MathHelper.Lerp(1.0f, 1.0f + Location.StoreMaxReputationModifier, Location.Reputation.Value / Location.Reputation.MinReputation) * price;
}
price *= Location.GetStoreReputationModifier(true);
// Price should never go below 1 mk
return Math.Max((int)price, 1);
}
@@ -319,22 +296,13 @@ namespace Barotrauma
float price = Location.StoreSellPriceModifier * priceInfo.Price;
// Adjust by random price modifier
price = (100 - PriceModifier) / 100.0f * price;
// Adjust by current store balance
price = ActiveBalanceStatus.SellPriceModifier * price;
// Adjust by requested good status
if (considerRequestedGoods && RequestedGoods.Contains(item))
{
price = Location.RequestGoodPriceModifier * price;
}
// Adjust by current location reputation
if (Location.Reputation.Value > 0.0f)
{
price = MathHelper.Lerp(1.0f, 1.0f + Location.StoreMaxReputationModifier, Location.Reputation.Value / Location.Reputation.MaxReputation) * price;
}
else
{
price = MathHelper.Lerp(1.0f, 1.0f - Location.StoreMaxReputationModifier, Location.Reputation.Value / Location.Reputation.MinReputation) * price;
}
price *= Location.GetStoreReputationModifier(false);
// Price should never go below 1 mk
return Math.Max((int)price, 1);
}
@@ -353,7 +321,6 @@ namespace Barotrauma
private float RequestGoodPriceModifier => Type.RequestGoodPriceModifier;
public int StoreInitialBalance => Type.StoreInitialBalance;
private int StorePriceModifierRange => Type.StorePriceModifierRange;
private List<StoreBalanceStatus> StoreBalanceStatuses => Type.StoreBalanceStatuses;
/// <summary>
/// How many map progress steps it takes before the discounts should be updated.
@@ -1224,6 +1191,32 @@ namespace Barotrauma
}
}
public float GetStoreReputationModifier(bool buying)
{
if (buying)
{
if (Reputation.Value > 0.0f)
{
return MathHelper.Lerp(1.0f, 1.0f - StoreMaxReputationModifier, Reputation.Value / Reputation.MaxReputation);
}
else
{
return MathHelper.Lerp(1.0f, 1.0f + StoreMaxReputationModifier, Reputation.Value / Reputation.MinReputation);
}
}
else
{
if (Reputation.Value > 0.0f)
{
return MathHelper.Lerp(1.0f, 1.0f + StoreMaxReputationModifier, Reputation.Value / Reputation.MaxReputation);
}
else
{
return MathHelper.Lerp(1.0f, 1.0f - StoreMaxReputationModifier, Reputation.Value / Reputation.MinReputation);
}
}
}
public int GetExtraSpecialSalesCount()
{
var characters = GameSession.GetSessionCrewCharacters(CharacterType.Both);
@@ -1231,21 +1224,6 @@ namespace Barotrauma
return characters.Max(c => (int)c.GetStatValue(StatTypes.ExtraSpecialSalesCount));
}
public StoreBalanceStatus GetStoreBalanceStatus(int balance)
{
StoreBalanceStatus nextStatus = StoreBalanceStatuses[0];
for (int i = 1; i < StoreBalanceStatuses.Count; i++)
{
var status = StoreBalanceStatuses[i];
if (status.PercentageOfInitialBalance < nextStatus.PercentageOfInitialBalance &&
((float)balance / StoreInitialBalance) < status.PercentageOfInitialBalance)
{
nextStatus = status;
}
}
return nextStatus;
}
public void Discover(bool checkTalents = true)
{
if (Discovered) { return; }
@@ -88,27 +88,6 @@ namespace Barotrauma
public int DailySpecialsCount { get; } = 1;
public int RequestedGoodsCount { get; } = 1;
public List<StoreBalanceStatus> StoreBalanceStatuses { get; } = new List<StoreBalanceStatus>()
{
new StoreBalanceStatus(1.0f, 1.0f, Color.White),
new StoreBalanceStatus(0.5f, 0.75f, Color.Orange),
new StoreBalanceStatus(0.25f, 0.2f, Color.Red)
};
public struct StoreBalanceStatus
{
public float PercentageOfInitialBalance { get; }
public float SellPriceModifier { get; }
public Color Color { get; }
public StoreBalanceStatus(float percentage, float sellPriceModifier, Color color)
{
PercentageOfInitialBalance = percentage;
SellPriceModifier = sellPriceModifier;
Color = color;
}
}
public override string ToString()
{
return $"LocationType (" + Identifier + ")";
@@ -208,18 +187,6 @@ namespace Barotrauma
RequestGoodPriceModifier = subElement.GetAttributeFloat("requestgoodpricemodifier", RequestGoodPriceModifier);
StoreInitialBalance = subElement.GetAttributeInt("initialbalance", StoreInitialBalance);
StorePriceModifierRange = subElement.GetAttributeInt("pricemodifierrange", StorePriceModifierRange);
var balanceStatusElements = subElement.GetChildElements("balancestatus");
if (balanceStatusElements.Any())
{
StoreBalanceStatuses.Clear();
foreach (var balanceStatusElement in balanceStatusElements)
{
float percentage = balanceStatusElement.GetAttributeFloat("percentage", 1.0f);
float modifier = balanceStatusElement.GetAttributeFloat("sellpricemodifier", 1.0f);
Color color = balanceStatusElement.GetAttributeColor("color", Color.White);
StoreBalanceStatuses.Add(new StoreBalanceStatus(percentage, modifier, color));
}
}
DailySpecialsCount = subElement.GetAttributeInt("dailyspecialscount", DailySpecialsCount);
RequestedGoodsCount = subElement.GetAttributeInt("requestedgoodscount", RequestedGoodsCount);
break;
@@ -238,6 +238,16 @@ namespace Barotrauma
}
System.Diagnostics.Debug.Assert(StartLocation != null, "Start location not assigned after level generation.");
//ensure all paths from the starting location have 0 difficulty to make the 1st campaign round very easy
foreach (var locationConnection in StartLocation.Connections)
{
if (locationConnection.Difficulty > 0.0f)
{
locationConnection.Difficulty = 0.0f;
locationConnection.LevelData = new LevelData(locationConnection);
}
}
CurrentLocation.Discover(true);
CurrentLocation.CreateStores();
@@ -509,25 +519,13 @@ namespace Barotrauma
foreach (Location location in Locations)
{
location.LevelData = new LevelData(location)
{
Difficulty = MathHelper.Clamp(location.MapPosition.X / Width * 100, 0.0f, 100.0f)
//Difficulty = MathHelper.Clamp(GetLevelDifficulty(location.MapPosition.X / Width), 0.0f, 100.0f)
};
location.LevelData = new LevelData(location, MathHelper.Clamp(location.MapPosition.X / Width * 100, 0.0f, 100.0f));
location.UnlockInitialMissions();
}
foreach (LocationConnection connection in Connections)
{
connection.LevelData = new LevelData(connection);
}
float GetLevelDifficulty(float areaDifficulty)
{
const float CurveModifier = 1.5f;
const float DifficultyMultiplier = 1.14f;
const float BaseDifficulty = -3f;
return (float)(1 - Math.Pow(1 - areaDifficulty, CurveModifier)) * DifficultyMultiplier * 100f + BaseDifficulty;
}
}
partial void GenerateLocationConnectionVisuals();
@@ -1015,8 +1013,7 @@ namespace Barotrauma
{
string prevName = location.Name;
var newType = LocationType.Prefabs[change.ChangeToType];
if (newType == null)
if (!LocationType.Prefabs.TryGet(change.ChangeToType, out var newType))
{
DebugConsole.ThrowError($"Failed to change the type of the location \"{location.Name}\". Location type \"{change.ChangeToType}\" not found.");
return false;