worldbox-observer-mod/IdleSpectator/BookInterestCatalog.cs

69 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
namespace IdleSpectator;
/// <summary>Authored interest overlay for every live book_types asset.</summary>
public static class BookInterestCatalog
{
private static readonly Dictionary<string, DiscreteEventEntry> Entries =
new Dictionary<string, DiscreteEventEntry>(StringComparer.OrdinalIgnoreCase);
static BookInterestCatalog()
{
Add("family_story", 52f, "Culture", InterestOwnership.Ambient, "Family story: {a}");
Add("love_story", 58f, "Culture", InterestOwnership.Ambient, "Love story: {a}");
Add("friendship_story", 50f, "Culture", InterestOwnership.Ambient, "Friendship story: {a}");
Add("bad_story_about_king", 62f, "Culture", InterestOwnership.Signal, "Scandalous book: {a}");
Add("fable", 48f, "Culture", InterestOwnership.Ambient, "Fable: {a}");
Add("warfare_manual", 60f, "Culture", InterestOwnership.Ambient, "Warfare manual: {a}");
Add("economy_manual", 48f, "Culture", InterestOwnership.Ambient, "Economy manual: {a}");
Add("stewardship_manual", 48f, "Culture", InterestOwnership.Ambient, "Stewardship manual: {a}");
Add("diplomacy_manual", 55f, "Culture", InterestOwnership.Ambient, "Diplomacy manual: {a}");
Add("mathbook", 45f, "Culture", InterestOwnership.Ambient, "Math book: {a}");
Add("biology_book", 45f, "Culture", InterestOwnership.Ambient, "Biology book: {a}");
Add("history_book", 55f, "Culture", InterestOwnership.Ambient, "History book: {a}");
}
private static void Add(
string id,
float strength,
string category,
InterestOwnership owns,
string label)
{
Entries[id] = new DiscreteEventEntry
{
Id = id,
EventStrength = strength,
Category = category,
OwnsCamera = owns,
CreatesInterest = true,
LabelTemplate = label
};
}
public static IEnumerable<string> AuthoredIds => Entries.Keys;
public static bool HasAuthored(string id) =>
!string.IsNullOrEmpty(id) && Entries.ContainsKey(id.Trim());
public static DiscreteEventEntry GetOrFallback(string id)
{
if (!string.IsNullOrEmpty(id) && Entries.TryGetValue(id.Trim(), out DiscreteEventEntry entry))
{
return entry;
}
string key = string.IsNullOrEmpty(id) ? "unknown" : id.Trim();
return new DiscreteEventEntry
{
Id = key,
EventStrength = 45f,
Category = "Culture",
OwnsCamera = InterestOwnership.Ambient,
LabelTemplate = "Book ({id}): {a}",
IsFallback = true
};
}
}