39 lines
1.7 KiB
C#
39 lines
1.7 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 and, in this release, calls no
|
|
/// other mod's code: it only asks whether a mod is active. This file is the only part of the class. A
|
|
/// later feature that reacts to one mod adds its package id here, with the source it was read from, or
|
|
/// in a partial file of its own.
|
|
///
|
|
/// 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);
|
|
}
|
|
}
|