Map events apart from the map: map_events/<map>/*.json of any mod merged by id (RpgMapEventResolver, RpgMapEventMerge); item Icon look for events; rpg_walk checks a pickup across leaving the map and loading a save

This commit is contained in:
cthangover committed 2026-10-23 19:09:37 +02:00
1 parent 281b722667
commit c4d6adf8fb
13 files changed
+396 -20

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Cthangover.Core.Mods;
namespace Cthangover.Mods.Rpg
{
/// <summary>Access to the merged map events of <see cref="RpgMapEventResolver"/>.</summary>
public static class RpgMapEvents
{
/// <summary>The events of a map (an empty list when it has none); the list is shared, do not change it.</summary>
public static IReadOnlyList<RpgMapEvent> Of(string map)
{
var maps = ModManager.Instance.GetResolver<RpgMapEventResolver>()?.Collect();
return map != null && maps != null && maps.TryGetValue(map, out var list) ? list : new List<RpgMapEvent>();
}
/// <summary>Forgets the collected events, so the next <see cref="Of"/> reads the files again (after an editor save).</summary>
public static void Invalidate() => ModManager.Instance.GetResolver<RpgMapEventResolver>()?.ClearCache();
}
}