40 lines
1.8 KiB
C#
40 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Verse;
|
|
|
|
namespace BlaxLaws
|
|
{
|
|
/// <summary>
|
|
/// Shared mod detection. Laws has no hard dependency on any other mod. Sibling APIs (CastesApi,
|
|
/// SlavesApi) are bound by reflection into cached delegates at startup by the feature that needs them;
|
|
/// a missing sibling or member is a silent no-op. Package ids of mods a single feature reacts to live
|
|
/// in that feature's partial file of this class (Compat.PrisonLabor.cs and so on), each with the source
|
|
/// it was read from.
|
|
///
|
|
/// Package ids of the Blax mods, from their own About/About.xml (2026-12-01).
|
|
/// </summary>
|
|
public static partial class Compat
|
|
{
|
|
public const string BlaxCastes = "blax.castes";
|
|
public const string BlaxSlaves = "blax.slaves";
|
|
public const string BlaxZones = "blax.zones";
|
|
public const string BlaxDefaults = "blax.defaults";
|
|
|
|
/// <summary>
|
|
/// Package ids tests treat as active. Only tests write it; the runner clears it after every test.
|
|
/// </summary>
|
|
public static readonly HashSet<string> SimulatedActive = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
/// <summary>
|
|
/// Active by packageId, local or Steam copy, or simulated by a test. ModsConfig.IsActive misses a mod
|
|
/// that is installed both ways (the Steam copy gets a "_steam" postfix), so nothing in Blax Laws uses it.
|
|
/// </summary>
|
|
public static bool IsActive(string packageId) =>
|
|
SimulatedActive.Contains(packageId) || ModLister.GetActiveModWithIdentifier(packageId, ignorePostfix: true) != null;
|
|
|
|
public static bool CastesActive => IsActive(BlaxCastes);
|
|
|
|
public static bool SlavesActive => IsActive(BlaxSlaves);
|
|
}
|
|
}
|