0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.SinglePlayer/Utils/TraderServices/LightKeeperServicesManager.cs
DrakiaXYZ d08754fb61 Work towards implementing LK services (!79)
- Move clearing trader service data to raid end instead of as part of BTR Manager
- Fix data type for TraderServices ItemsToPay property
- Add ItemsToReceive property to TraderServices (Used for LK amulet)
- Don't throw NRE when nothing is bound to OnTraderServicePurchased

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#79
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-02-12 09:22:45 +00:00

65 lines
2.1 KiB
C#

using BepInEx.Logging;
using Comfort.Common;
using EFT;
using HarmonyLib.Tools;
using UnityEngine;
namespace Aki.SinglePlayer.Utils.TraderServices
{
internal class LightKeeperServicesManager : MonoBehaviour
{
private static ManualLogSource logger;
GameWorld gameWorld;
BotsController botsController;
private void Awake()
{
logger = BepInEx.Logging.Logger.CreateLogSource(nameof(LightKeeperServicesManager));
gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null || TraderServicesManager.Instance == null)
{
logger.LogError("[AKI-LKS] GameWorld or TraderServices null");
Destroy(this);
return;
}
botsController = Singleton<IBotGame>.Instance.BotsController;
if (botsController == null)
{
logger.LogError("[AKI-LKS] BotsController null");
Destroy(this);
return;
}
TraderServicesManager.Instance.OnTraderServicePurchased += OnTraderServicePurchased;
}
private void OnTraderServicePurchased(ETraderServiceType serviceType, string subserviceId)
{
switch (serviceType)
{
case ETraderServiceType.ExUsecLoyalty:
botsController.BotTradersServices.LighthouseKeeperServices.OnFriendlyExUsecPurchased(gameWorld.MainPlayer);
break;
case ETraderServiceType.ZryachiyAid:
botsController.BotTradersServices.LighthouseKeeperServices.OnFriendlyZryachiyPurchased(gameWorld.MainPlayer);
break;
}
}
private void OnDestroy()
{
if (gameWorld == null || botsController == null)
{
return;
}
if (TraderServicesManager.Instance != null)
{
TraderServicesManager.Instance.OnTraderServicePurchased -= OnTraderServicePurchased;
}
}
}
}