2021-08-12 16:52:06 +01:00
|
|
|
|
using Generator.Helpers;
|
|
|
|
|
using Generator.Models;
|
|
|
|
|
using Generator.Models.Input;
|
|
|
|
|
using Generator.Models.Output;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Generator
|
|
|
|
|
{
|
|
|
|
|
public class BaseBotGenerator
|
|
|
|
|
{
|
|
|
|
|
private readonly List<Datum> _rawParsedBots;
|
|
|
|
|
|
|
|
|
|
public BaseBotGenerator(List<Datum> parsedBots)
|
|
|
|
|
{
|
|
|
|
|
_rawParsedBots = parsedBots;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Bot> AddBaseDetails()
|
|
|
|
|
{
|
|
|
|
|
var stopwatch = Stopwatch.StartNew();
|
|
|
|
|
LoggingHelpers.LogToConsole("Started processing bot base");
|
|
|
|
|
|
|
|
|
|
var assaultBot = new Bot(BotType.assault);
|
|
|
|
|
var raiderBot = new Bot(BotType.pmcBot);
|
|
|
|
|
var marksmanBot = new Bot(BotType.marksman);
|
|
|
|
|
|
|
|
|
|
var rawBots = new List<Bot>
|
|
|
|
|
{
|
|
|
|
|
assaultBot,
|
|
|
|
|
raiderBot,
|
|
|
|
|
marksmanBot
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var botToUpdate in rawBots)
|
|
|
|
|
{
|
|
|
|
|
var rawBotData = _rawParsedBots
|
|
|
|
|
.Where(x => string.Equals(x.Info.Settings.Role, botToUpdate.botType.ToString(), StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
UpdateBodyPartHealth(botToUpdate, rawBotData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var bot in rawBots)
|
|
|
|
|
{
|
|
|
|
|
AddDifficulties(bot, _rawParsedBots);
|
|
|
|
|
foreach (var rawParsedBot in _rawParsedBots)
|
|
|
|
|
{
|
|
|
|
|
AddVisualAppearanceItems(bot, rawParsedBot);
|
|
|
|
|
AddName(bot, rawParsedBot.Info.Nickname);
|
2021-08-12 21:40:41 +01:00
|
|
|
|
AddVoice(bot, rawParsedBot);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopwatch.Stop();
|
2021-08-12 21:31:15 +01:00
|
|
|
|
LoggingHelpers.LogToConsole($"Finished processing bot base. Took {LoggingHelpers.LogTimeTaken(stopwatch.Elapsed.TotalSeconds)} seconds");
|
2021-08-12 16:52:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rawBots;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 21:40:41 +01:00
|
|
|
|
private void AddVoice(Bot bot, Datum rawParsedBot)
|
|
|
|
|
{
|
|
|
|
|
if (bot.botType == BotType.assault || bot.botType == BotType.marksman)
|
|
|
|
|
{
|
|
|
|
|
if (rawParsedBot.Info.Voice.StartsWith("scav", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
bot.appearance.voice.AddUnique(rawParsedBot.Info.Voice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 16:52:06 +01:00
|
|
|
|
private void AddDifficulties(Bot bot, List<Datum> rawParsedBots)
|
|
|
|
|
{
|
2021-08-12 22:17:40 +01:00
|
|
|
|
switch (bot.botType)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
|
|
|
|
case BotType.assault:
|
|
|
|
|
DifficultyHelper.AddAssaultDifficulties(bot);
|
|
|
|
|
break;
|
|
|
|
|
case BotType.pmcBot:
|
|
|
|
|
break;
|
|
|
|
|
case BotType.marksman:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateBodyPartHealth(Bot botToUpdate, List<Datum> rawParsedBots)
|
|
|
|
|
{
|
2021-08-12 22:17:40 +01:00
|
|
|
|
var firstBotOfDesiredType = rawParsedBots.FirstOrDefault(x => x.Info.Settings.Role == botToUpdate.botType.ToString());
|
|
|
|
|
if (firstBotOfDesiredType == null)
|
|
|
|
|
{
|
|
|
|
|
LoggingHelpers.LogToConsole($"bottype of: {botToUpdate.botType} not found, unable to update body part health.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 16:52:06 +01:00
|
|
|
|
botToUpdate.health.BodyParts.Head.min = firstBotOfDesiredType.Health.BodyParts.Head.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.Head.max = firstBotOfDesiredType.Health.BodyParts.Head.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.Chest.min = firstBotOfDesiredType.Health.BodyParts.Chest.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.Chest.max = firstBotOfDesiredType.Health.BodyParts.Chest.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.Stomach.min = firstBotOfDesiredType.Health.BodyParts.Stomach.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.Stomach.max = firstBotOfDesiredType.Health.BodyParts.Stomach.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.LeftArm.min = firstBotOfDesiredType.Health.BodyParts.LeftArm.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.LeftArm.max = firstBotOfDesiredType.Health.BodyParts.LeftArm.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.RightArm.min = firstBotOfDesiredType.Health.BodyParts.RightArm.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.RightArm.max = firstBotOfDesiredType.Health.BodyParts.RightArm.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.LeftLeg.min = firstBotOfDesiredType.Health.BodyParts.LeftLeg.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.LeftLeg.max = firstBotOfDesiredType.Health.BodyParts.LeftLeg.Health.Maximum;
|
|
|
|
|
|
|
|
|
|
botToUpdate.health.BodyParts.RightLeg.min = firstBotOfDesiredType.Health.BodyParts.RightLeg.Health.Current;
|
|
|
|
|
botToUpdate.health.BodyParts.RightLeg.max = firstBotOfDesiredType.Health.BodyParts.RightLeg.Health.Maximum;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 21:40:41 +01:00
|
|
|
|
private void AddVisualAppearanceItems(Bot botToUpdate, Datum rawBot)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
2021-08-12 21:40:41 +01:00
|
|
|
|
botToUpdate.appearance.head.AddUnique(rawBot.Customization.Head);
|
|
|
|
|
botToUpdate.appearance.body.AddUnique(rawBot.Customization.Body);
|
|
|
|
|
botToUpdate.appearance.hands.AddUnique(rawBot.Customization.Hands);
|
|
|
|
|
botToUpdate.appearance.feet.AddUnique(rawBot.Customization.Feet);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 21:40:41 +01:00
|
|
|
|
private void AddName(Bot botToUpdate, string nickName)
|
2021-08-12 16:52:06 +01:00
|
|
|
|
{
|
|
|
|
|
var name = nickName.Split();
|
2021-08-12 21:40:41 +01:00
|
|
|
|
botToUpdate.firstName.AddUnique(name[0]);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
if (name.Length > 1)
|
|
|
|
|
{
|
2021-08-12 21:40:41 +01:00
|
|
|
|
botToUpdate.lastName.AddUnique(name[1]);
|
2021-08-12 16:52:06 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|