mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 17:30:43 -05:00
use new containerIds dictionary when choosing container to spawn
This commit is contained in:
parent
5982d26a81
commit
d2d1581859
@ -1,4 +1,5 @@
|
||||
using Aki.Custom.Airdrops.Models;
|
||||
using Aki.Common.Http;
|
||||
using Aki.Custom.Airdrops.Models;
|
||||
using Aki.Custom.Airdrops.Utils;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
@ -69,7 +70,7 @@ namespace Aki.Custom.Airdrops
|
||||
if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned)
|
||||
{
|
||||
StartBox();
|
||||
BuildLootContainer();
|
||||
BuildLootContainer(airdropParameters.Config);
|
||||
}
|
||||
|
||||
if (airdropParameters.DistanceTraveled < airdropParameters.DistanceToTravel)
|
||||
@ -100,10 +101,11 @@ namespace Aki.Custom.Airdrops
|
||||
airdropBox.StartCoroutine(airdropBox.DropCrate(dropPos));
|
||||
}
|
||||
|
||||
private void BuildLootContainer()
|
||||
private void BuildLootContainer(AirdropConfigModel config)
|
||||
{
|
||||
factory.BuildContainer(airdropBox.container);
|
||||
factory.AddLoot(airdropBox.container);
|
||||
var lootData = factory.GetLoot();
|
||||
factory.BuildContainer(airdropBox.container, config, lootData.DropType);
|
||||
factory.AddLoot(airdropBox.container, lootData);
|
||||
}
|
||||
|
||||
private void SetDistanceToDrop()
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aki.Custom.Airdrops.Models
|
||||
{
|
||||
@ -27,6 +28,9 @@ namespace Aki.Custom.Airdrops.Models
|
||||
|
||||
[JsonProperty("crateFallSpeed")]
|
||||
public float CrateFallSpeed { get; set; }
|
||||
|
||||
[JsonProperty("containerIds")]
|
||||
public Dictionary<string, string> ContainerIds { get; set; }
|
||||
}
|
||||
|
||||
public class AirdropChancePercent
|
||||
|
@ -1,7 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Aki.Custom.Airdrops.Models
|
||||
{
|
||||
public class AirdropLootResultModel
|
||||
{
|
||||
[JsonProperty("dropType")]
|
||||
public string DropType { get; set; }
|
||||
|
||||
[JsonProperty("loot")]
|
||||
public IEnumerable<AirdropLootModel> Loot { get;set;}
|
||||
}
|
||||
|
||||
|
||||
public class AirdropLootModel
|
||||
{
|
||||
[JsonProperty("tpl")]
|
||||
|
@ -8,40 +8,36 @@ using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Aki.Custom.Airdrops.Models;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Aki.Custom.Airdrops.Utils
|
||||
{
|
||||
public class ItemFactoryUtil
|
||||
{
|
||||
private ItemFactory itemFactory;
|
||||
private static readonly string DropContainer = "6223349b3136504a544d1608";
|
||||
private readonly ItemFactory itemFactory;
|
||||
|
||||
public ItemFactoryUtil()
|
||||
{
|
||||
itemFactory = Singleton<ItemFactory>.Instance;
|
||||
}
|
||||
|
||||
public void BuildContainer(LootableContainer container)
|
||||
public void BuildContainer(LootableContainer container, AirdropConfigModel config, string dropType)
|
||||
{
|
||||
if (itemFactory.ItemTemplates.TryGetValue(DropContainer, out var template))
|
||||
var containerId = config.ContainerIds[dropType];
|
||||
if (itemFactory.ItemTemplates.TryGetValue(containerId, out var template))
|
||||
{
|
||||
Item item = itemFactory.CreateItem(DropContainer, template._id, null);
|
||||
Item item = itemFactory.CreateItem(containerId, template._id, null);
|
||||
LootItem.CreateLootContainer(container, item, "CRATE", Singleton<GameWorld>.Instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[AKI-AIRDROPS]: unable to find template: {DropContainer}");
|
||||
Debug.LogError($"[AKI-AIRDROPS]: unable to find template: {containerId}");
|
||||
}
|
||||
}
|
||||
|
||||
public async void AddLoot(LootableContainer container)
|
||||
public async void AddLoot(LootableContainer container, AirdropLootResultModel lootToAdd)
|
||||
{
|
||||
List<AirdropLootModel> loot = GetLoot();
|
||||
|
||||
Item actualItem;
|
||||
|
||||
foreach (var item in loot)
|
||||
foreach (var item in lootToAdd.Loot)
|
||||
{
|
||||
ResourceKey[] resources;
|
||||
if (item.IsPreset)
|
||||
@ -62,12 +58,12 @@ namespace Aki.Custom.Airdrops.Utils
|
||||
}
|
||||
}
|
||||
|
||||
private List<AirdropLootModel> GetLoot()
|
||||
public AirdropLootResultModel GetLoot()
|
||||
{
|
||||
var json = RequestHandler.GetJson("/client/location/getAirdropLoot");
|
||||
var loot = JsonConvert.DeserializeObject<List<AirdropLootModel>>(json);
|
||||
var result = JsonConvert.DeserializeObject<AirdropLootResultModel> (json);
|
||||
|
||||
return loot;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user