Skip to content

Commit

Permalink
refactor: IEApiWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumearm committed Jan 1, 2025
1 parent f4c5434 commit c4c0fb5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion PTT-Plugin/Data/ExfilsTargets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public bool IsAvailable()
}

bool playerIsHighLevel = Helpers.PlayerProfile.GetLevel() >= 20;
bool playerIsLowLevel = !playerIsHighLevel;
bool isSandboxLow = transitMapId.ToLower() == "sandbox";
bool isSandboxHigh = transitMapId.ToLower() == "sandbox_high";

Expand All @@ -88,7 +89,7 @@ public bool IsAvailable()
return false;
}

if (!playerIsHighLevel && isSandboxHigh)
if (playerIsLowLevel && isSandboxHigh)
{
return false;
}
Expand Down
11 changes: 8 additions & 3 deletions PTT-Plugin/Services/ExfilPromptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ public class ExfilPromptService(
ExfilsTargetsService exfilsTargetsService
)
{
public void InitPromptHandlers()
public void Init()
{
ieService.DisableVanillaActions = true;
InitPromptHandlers();
}

private void InitPromptHandlers()
{
// requires manual activation (no auto-extract even if the player enabled the IEAPI option in BepInEx)
ieService.OnActionsAppliedEvent += RequiresManualActivation;
Expand Down Expand Up @@ -160,13 +166,12 @@ private OnActionsAppliedResult ExfilPromptHandler(ExfiltrationPoint exfil, Custo

private OnActionsAppliedResult RequiresManualActivation(ExfiltrationPoint exfil, CustomExfilTrigger customExfilTrigger, bool exfilIsAvailableToPlayer)
{
// compat with older version of Interactable Exfils API (< 1.4.0)
// avoid crash with older version of Interactable Exfils API (< 1.4.0)
if (customExfilTrigger == null)
{
return null;
}

// TODO: find out why it doesn't work as intended? (in some cases, when player enable/disable the bepinex setting manually)
customExfilTrigger.RequiresManualActivation = true;
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions PTT-Plugin/Services/IEApiWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public static void Init(ExfilsTargetsService exfilsTargetsService)

if (interactableExfilsService != null)
{
interactableExfilsService.DisableVanillaActions = true;
var exfilPromptService = new ExfilPromptService(interactableExfilsService, exfilsTargetsService);
exfilPromptService.InitPromptHandlers();
new ExfilPromptService(interactableExfilsService, exfilsTargetsService).Init();
Logger.Info($"Jehree's Interactable Exfils API: initialized exfils prompt service");
}
else
Expand Down

0 comments on commit c4c0fb5

Please sign in to comment.