0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.SinglePlayer/Utils/TraderServices/LightKeeperServicesManager.cs
2024-05-21 19:10:17 +01:00

65 lines
2.1 KiB
C#

using BepInEx.Logging;
using Comfort.Common;
using EFT;
using HarmonyLib.Tools;
using UnityEngine;
namespace SPT.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("[SPT-LKS] GameWorld or TraderServices null");
Destroy(this);
return;
}
botsController = Singleton<IBotGame>.Instance.BotsController;
if (botsController == null)
{
logger.LogError("[SPT-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;
}
}
}
}