forked from FlashShifter/StardewValleyExpanded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomWeddingGuests.cs
executable file
·53 lines (47 loc) · 1.81 KB
/
CustomWeddingGuests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using StardewModdingAPI;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StardewValleyExpanded
{
class CustomWeddingGuests : IAssetLoader
{
private const string AssetName = "Data/CustomWeddingGuestPositions";
private static Mod modInstance;
public CustomWeddingGuests(Mod modInstance)
{
CustomWeddingGuests.modInstance = modInstance;
}
public bool CanLoad<T>(IAssetInfo asset)
{
return asset.AssetNameEquals(AssetName);
}
public T Load<T>(IAssetInfo asset)
{
return (T)(object)new Dictionary<string, string>();
}
public static string getCelebrationPositionsForDatables_Postfix(string originalValue, List<string> people_to_exclude)
{
try
{
Dictionary<string, string> locations = Game1.content.Load<Dictionary<string, string>>(AssetName);
Log($"Setting custom wedding positions for {locations.Count} custom NPCs", LogLevel.Trace);
return locations.Where(kvp => !people_to_exclude.Contains(kvp.Key)).
Aggregate(originalValue, (locationString, kvp) => locationString + kvp.Key + " " + kvp.Value + " ");
}
catch (Exception ex)
{
Log($"Error setting wedding positions for custom NPCs: {ex}", LogLevel.Error);
return originalValue;
}
}
private static void Log(string message, LogLevel level = LogLevel.Trace)
{
if (CustomWeddingGuests.modInstance != null)
{
CustomWeddingGuests.modInstance.Monitor.Log(message, level);
}
}
}
}