typing changes

This commit is contained in:
CWX
2025-01-15 12:35:17 +00:00
parent 9474487bdd
commit b7c6d6414a
10 changed files with 69 additions and 69 deletions
+1 -1
View File
@@ -316,7 +316,7 @@ public class BotController
_matchBotDetailsCacheService.CacheBot(botToCache);
}
private void UpdateBotGenerationDetailsToRandomBoss(BotGenerationDetails botGenerationDetails, Dictionary<string, int> bossesToConvertToWeights)
private void UpdateBotGenerationDetailsToRandomBoss(BotGenerationDetails botGenerationDetails, Dictionary<string, double> bossesToConvertToWeights)
{
// Seems Actual bosses have the same Brain issues like PMC gaining Boss Brains We can't use all bosses
botGenerationDetails.Role = _weightedRandomHelper.GetWeightedValue(bossesToConvertToWeights);
+1 -1
View File
@@ -434,7 +434,7 @@ public class BotGenerator
public void AddAdditionalPocketLootWeightsForUnheardBot(BotType botJsonTemplate)
{
// Adjust pocket loot weights to allow for 5 or 6 items
var pocketWeights = botJsonTemplate.BotGeneration.Items["pocketLoot"].Weights;
var pocketWeights = botJsonTemplate.BotGeneration.Items.PocketLoot.Weights;
pocketWeights[5] = 1;
pocketWeights[6] = 1;
}
+22 -25
View File
@@ -97,36 +97,33 @@ public class BotLootGenerator
var itemCounts = botJsonTemplate.BotGeneration.Items;
if (
itemCounts["backpackLoot"].Weights is null ||
itemCounts["pocketLoot"].Weights is null ||
itemCounts["vestLoot"].Weights is null ||
itemCounts["specialItems"].Weights is null ||
itemCounts["healing"].Weights is null ||
itemCounts["drugs"].Weights is null ||
itemCounts["food"].Weights is null ||
itemCounts["drink"].Weights is null ||
itemCounts["currency"].Weights is null ||
itemCounts["stims"].Weights is null ||
itemCounts["grenades"].Weights is null
itemCounts.BackpackLoot.Weights is null ||
itemCounts.PocketLoot.Weights is null ||
itemCounts.VestLoot.Weights is null ||
itemCounts.SpecialItems.Weights is null ||
itemCounts.Healing.Weights is null ||
itemCounts.Drugs.Weights is null ||
itemCounts.Food.Weights is null ||
itemCounts.Drink.Weights is null ||
itemCounts.Currency.Weights is null ||
itemCounts.Stims.Weights is null ||
itemCounts.Grenades.Weights is null
)
{
_logger.Warning(_localisationService.GetText("bot-unable_to_generate_bot_loot", botRole));
return;
}
var backpackLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["backpackLoot"].Weights);
var pocketLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["pocketLoot"].Weights);
var vestLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["vestLoot"].Weights);
var specialLootItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["specialItems"].Weights);
var healingItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["healing"].Weights);
var drugItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["drugs"].Weights);
var foodItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["food"].Weights);
var drinkItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["drink"].Weights);
var currencyItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["currency"].Weights);
var stimItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["stims"].Weights);
var grenadeCount = _weightedRandomHelper.GetWeightedValue(itemCounts["grenades"].Weights);
var backpackLootCount = _weightedRandomHelper.GetWeightedValue<int>(itemCounts.BackpackLoot.Weights);
var pocketLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts.PocketLoot.Weights);
var vestLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts.VestLoot.Weights);
var specialLootItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.SpecialItems.Weights);
var healingItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Healing.Weights);
var drugItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Drugs.Weights);
var foodItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Food.Weights);
var drinkItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Drink.Weights);
var currencyItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Currency.Weights);
var stimItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Stims.Weights);
var grenadeCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Grenades.Weights);
// If bot has been flagged as not having loot, set below counts to 0
if (_botConfig.DisableLootOnBotTypes.Contains(botRole.ToLower()))
+3 -1
View File
@@ -278,9 +278,11 @@ public class PlayerScavGenerator
}
// Adjust item spawn quantity values
var props = baseBotNode.BotGeneration.Items.GetType().GetProperties();
foreach (var itemLimitKvP in karmaSettings.ItemLimits)
{
baseBotNode.BotGeneration.Items[itemLimitKvP.Key] = itemLimitKvP.Value;
var prop = props.FirstOrDefault(x => x.Name == itemLimitKvP.Key);
prop.SetValue(baseBotNode.BotGeneration.Items, itemLimitKvP.Value);
}
// Blacklist equipment, keyed by equipment slot
+6 -6
View File
@@ -41,22 +41,22 @@ public class BotType
public class Appearance
{
[JsonPropertyName("body")]
public Dictionary<string, int>? Body { get; set; }
public Dictionary<string, double>? Body { get; set; }
[JsonPropertyName("feet")]
public Dictionary<string, int>? Feet { get; set; }
public Dictionary<string, double>? Feet { get; set; }
[JsonPropertyName("hands")]
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
public Dictionary<string, int>? Hands { get; set; }
public Dictionary<string, double>? Hands { get; set; }
[JsonPropertyName("head")]
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
public Dictionary<string, int>? Head { get; set; }
public Dictionary<string, double>? Head { get; set; }
[JsonPropertyName("voice")]
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
public Dictionary<string, int>? Voice { get; set; }
public Dictionary<string, double>? Voice { get; set; }
}
public class Chances
@@ -303,7 +303,7 @@ public class GenerationData
{
/** key: number of items, value: weighting */
[JsonPropertyName("weights")]
public Dictionary<int, int>? Weights { get; set; }
public Dictionary<int, double>? Weights { get; set; }
/** Array of item tpls */
[JsonPropertyName("whitelist")]
+1 -1
View File
@@ -106,7 +106,7 @@ public class AssaultToBossConversion
public bool BossConvertEnabled { get; set; }
[JsonPropertyName("bossesToConvertToWeights")]
public Dictionary<string, int> BossesToConvertToWeights { get; set; }
public Dictionary<string, double> BossesToConvertToWeights { get; set; }
[JsonPropertyName("bossConvertMinMax")]
public Dictionary<string, MinMax> BossConvertMinMax { get; set; }
+2 -2
View File
@@ -12,11 +12,11 @@ public class PmcConfig : BaseConfig
/** What game version should the PMC have */
[JsonPropertyName("gameVersionWeight")]
public Dictionary<string, int> GameVersionWeight { get; set; }
public Dictionary<string, double> GameVersionWeight { get; set; }
/** What account type should the PMC have */
[JsonPropertyName("accountTypeWeight")]
public Dictionary<MemberCategory, int> AccountTypeWeight { get; set; }
public Dictionary<MemberCategory, double> AccountTypeWeight { get; set; }
/** Global whitelist/blacklist of vest loot for PMCs */
[JsonPropertyName("vestLoot")]
+26 -26
View File
@@ -8,16 +8,16 @@ namespace Core.Models.Spt.Config;
public class WeatherConfig : BaseConfig
{
[JsonPropertyName("kind")]
public string Kind { get; set; } = "spt-weather";
public string? Kind { get; set; } = "spt-weather";
[JsonPropertyName("acceleration")]
public double Acceleration { get; set; }
public double? Acceleration { get; set; }
[JsonPropertyName("weather")]
public WeatherValues Weather { get; set; }
public WeatherValues? Weather { get; set; }
[JsonPropertyName("seasonDates")]
public List<SeasonDateTimes> SeasonDates { get; set; }
public List<SeasonDateTimes>? SeasonDates { get; set; }
[JsonPropertyName("overrideSeason")]
public Season? OverrideSeason { get; set; }
@@ -26,86 +26,86 @@ public class WeatherConfig : BaseConfig
public class SeasonDateTimes
{
[JsonPropertyName("seasonType")]
public Season SeasonType { get; set; }
public Season? SeasonType { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonPropertyName("startDay")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public int StartDay { get; set; }
public int? StartDay { get; set; }
[JsonPropertyName("startMonth")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public int StartMonth { get; set; }
public int? StartMonth { get; set; }
[JsonPropertyName("endDay")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public int EndDay { get; set; }
public int? EndDay { get; set; }
[JsonPropertyName("endMonth")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public int EndMonth { get; set; }
public int? EndMonth { get; set; }
}
public class WeatherValues
{
[JsonPropertyName("seasonValues")]
public Dictionary<string, SeasonalValues> SeasonValues { get; set; }
public Dictionary<string, SeasonalValues>? SeasonValues { get; set; }
/** How many hours to generate weather data into the future */
[JsonPropertyName("generateWeatherAmountHours")]
public int GenerateWeatherAmountHours { get; set; }
public int? GenerateWeatherAmountHours { get; set; }
/** Length of each weather period */
[JsonPropertyName("timePeriod")]
public WeatherSettings<int> TimePeriod { get; set; }
public WeatherSettings<int>? TimePeriod { get; set; }
}
public class SeasonalValues
{
[JsonPropertyName("clouds")]
public WeatherSettings<double> Clouds { get; set; }
public WeatherSettings<double>? Clouds { get; set; }
[JsonPropertyName("windSpeed")]
public WeatherSettings<double> WindSpeed { get; set; }
public WeatherSettings<double>? WindSpeed { get; set; }
[JsonPropertyName("windDirection")]
public WeatherSettings<WindDirection> WindDirection { get; set; }
public WeatherSettings<WindDirection>? WindDirection { get; set; }
[JsonPropertyName("windGustiness")]
public MinMax WindGustiness { get; set; }
public MinMax? WindGustiness { get; set; }
[JsonPropertyName("rain")]
public WeatherSettings<double> Rain { get; set; }
public WeatherSettings<double>? Rain { get; set; }
[JsonPropertyName("rainIntensity")]
public MinMax RainIntensity { get; set; }
public MinMax? RainIntensity { get; set; }
[JsonPropertyName("fog")]
public WeatherSettings<double> Fog { get; set; }
public WeatherSettings<double>? Fog { get; set; }
[JsonPropertyName("temp")]
public TempDayNight Temp { get; set; }
public TempDayNight? Temp { get; set; }
[JsonPropertyName("pressure")]
public MinMax Pressure { get; set; }
public MinMax? Pressure { get; set; }
}
public class TempDayNight
{
[JsonPropertyName("day")]
public MinMax Day { get; set; }
public MinMax? Day { get; set; }
[JsonPropertyName("night")]
public MinMax Night { get; set; }
public MinMax? Night { get; set; }
}
public class WeatherSettings<T>
{
[JsonPropertyName("values")]
public List<T> Values { get; set; }
public List<T>? Values { get; set; }
[JsonPropertyName("weights")]
public List<int> Weights { get; set; }
public List<double>? Weights { get; set; }
}
+1 -1
View File
@@ -54,7 +54,7 @@ public class RaidWeatherService
var staringTimestampMs = _timeUtil.GetTodayMidnightTimeStamp();
// How far into future do we generate weather
var futureTimestampToReachMs = staringTimestampMs + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours) * 1000; // Convert to milliseconds
var futureTimestampToReachMs = staringTimestampMs + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours ?? 1) * 1000; // Convert to milliseconds
// Keep adding new weather until we have reached desired future date
var nextTimestampMs = staringTimestampMs;
+6 -5
View File
@@ -320,13 +320,14 @@ public class SeasonalEventService
if (
DateIsBetweenTwoDates(
currentDate,
seasonRange.StartMonth,
seasonRange.StartDay,
seasonRange.EndMonth,
seasonRange.EndDay)
seasonRange.StartMonth ?? 0,
seasonRange.StartDay ?? 0,
seasonRange.EndMonth ?? 0,
seasonRange.EndDay ?? 0
)
)
{
return seasonRange.SeasonType;
return seasonRange.SeasonType ?? Season.SUMMER;
}
}