81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace IdleSpectator;
|
|
|
|
/// <summary>
|
|
/// Live-seeded interest catalogs: every live library id is authored (Ambient default),
|
|
/// with curated Signal overlays for spectacle / kingdom-affecting entries.
|
|
/// </summary>
|
|
public static class LiveLibraryInterest
|
|
{
|
|
public static void EnsureSeeded(
|
|
Dictionary<string, DiscreteEventEntry> entries,
|
|
Func<List<string>> enumerateLive,
|
|
string category,
|
|
string labelTemplate,
|
|
float ambientStrength,
|
|
HashSet<string> signalIds,
|
|
float signalStrength,
|
|
Func<string, bool> signalPredicate = null,
|
|
bool ambientCreatesInterest = true)
|
|
{
|
|
if (entries == null || enumerateLive == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
List<string> live;
|
|
try
|
|
{
|
|
live = enumerateLive() ?? new List<string>();
|
|
}
|
|
catch
|
|
{
|
|
live = new List<string>();
|
|
}
|
|
|
|
for (int i = 0; i < live.Count; i++)
|
|
{
|
|
string id = live[i];
|
|
if (string.IsNullOrEmpty(id) || entries.ContainsKey(id))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
bool signal = (signalIds != null && signalIds.Contains(id))
|
|
|| (signalPredicate != null && signalPredicate(id));
|
|
entries[id] = new DiscreteEventEntry
|
|
{
|
|
Id = id,
|
|
EventStrength = signal ? signalStrength : ambientStrength,
|
|
Category = category,
|
|
CreatesInterest = signal || ambientCreatesInterest,
|
|
LabelTemplate = labelTemplate
|
|
};
|
|
}
|
|
}
|
|
|
|
public static DiscreteEventEntry Lookup(
|
|
Dictionary<string, DiscreteEventEntry> entries,
|
|
string id,
|
|
string category,
|
|
string labelTemplate,
|
|
float fallbackStrength = 40f)
|
|
{
|
|
if (!string.IsNullOrEmpty(id) && entries != null && entries.TryGetValue(id.Trim(), out DiscreteEventEntry entry))
|
|
{
|
|
return entry;
|
|
}
|
|
|
|
string key = string.IsNullOrEmpty(id) ? "unknown" : id.Trim();
|
|
return new DiscreteEventEntry
|
|
{
|
|
Id = key,
|
|
EventStrength = fallbackStrength,
|
|
Category = category,
|
|
LabelTemplate = labelTemplate,
|
|
IsFallback = true
|
|
};
|
|
}
|
|
}
|