mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 22:30:44 -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 Aki.Custom.Airdrops.Utils;
|
||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
@ -69,7 +70,7 @@ namespace Aki.Custom.Airdrops
|
|||||||
if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned)
|
if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned)
|
||||||
{
|
{
|
||||||
StartBox();
|
StartBox();
|
||||||
BuildLootContainer();
|
BuildLootContainer(airdropParameters.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (airdropParameters.DistanceTraveled < airdropParameters.DistanceToTravel)
|
if (airdropParameters.DistanceTraveled < airdropParameters.DistanceToTravel)
|
||||||
@ -100,10 +101,11 @@ namespace Aki.Custom.Airdrops
|
|||||||
airdropBox.StartCoroutine(airdropBox.DropCrate(dropPos));
|
airdropBox.StartCoroutine(airdropBox.DropCrate(dropPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildLootContainer()
|
private void BuildLootContainer(AirdropConfigModel config)
|
||||||
{
|
{
|
||||||
factory.BuildContainer(airdropBox.container);
|
var lootData = factory.GetLoot();
|
||||||
factory.AddLoot(airdropBox.container);
|
factory.BuildContainer(airdropBox.container, config, lootData.DropType);
|
||||||
|
factory.AddLoot(airdropBox.container, lootData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDistanceToDrop()
|
private void SetDistanceToDrop()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Aki.Custom.Airdrops.Models
|
namespace Aki.Custom.Airdrops.Models
|
||||||
{
|
{
|
||||||
@ -27,6 +28,9 @@ namespace Aki.Custom.Airdrops.Models
|
|||||||
|
|
||||||
[JsonProperty("crateFallSpeed")]
|
[JsonProperty("crateFallSpeed")]
|
||||||
public float CrateFallSpeed { get; set; }
|
public float CrateFallSpeed { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("containerIds")]
|
||||||
|
public Dictionary<string, string> ContainerIds { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AirdropChancePercent
|
public class AirdropChancePercent
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Aki.Custom.Airdrops.Models
|
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
|
public class AirdropLootModel
|
||||||
{
|
{
|
||||||
[JsonProperty("tpl")]
|
[JsonProperty("tpl")]
|
||||||
|
@ -8,40 +8,36 @@ using Newtonsoft.Json;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Aki.Custom.Airdrops.Models;
|
using Aki.Custom.Airdrops.Models;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Aki.Custom.Airdrops.Utils
|
namespace Aki.Custom.Airdrops.Utils
|
||||||
{
|
{
|
||||||
public class ItemFactoryUtil
|
public class ItemFactoryUtil
|
||||||
{
|
{
|
||||||
private ItemFactory itemFactory;
|
private readonly ItemFactory itemFactory;
|
||||||
private static readonly string DropContainer = "6223349b3136504a544d1608";
|
|
||||||
|
|
||||||
public ItemFactoryUtil()
|
public ItemFactoryUtil()
|
||||||
{
|
{
|
||||||
itemFactory = Singleton<ItemFactory>.Instance;
|
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);
|
LootItem.CreateLootContainer(container, item, "CRATE", Singleton<GameWorld>.Instance);
|
||||||
}
|
}
|
||||||
else
|
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;
|
Item actualItem;
|
||||||
|
foreach (var item in lootToAdd.Loot)
|
||||||
foreach (var item in loot)
|
|
||||||
{
|
{
|
||||||
ResourceKey[] resources;
|
ResourceKey[] resources;
|
||||||
if (item.IsPreset)
|
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 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