forked from ApryllForever/PolyamorySweetLove
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Integrations.cs
56 lines (49 loc) · 1.99 KB
/
Integrations.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
54
55
56
using StardewModdingAPI;
using StardewValley;
using System;
using System.Linq;
namespace PolyamorySweetLove
{
public partial class ModEntry
{
public static IPlannedParenthoodAPI plannedParenthoodAPI;
public static IContentPatcherAPI contentPatcherAPI;
public static void LoadModApis()
{
plannedParenthoodAPI = SHelper.ModRegistry.GetApi<IPlannedParenthoodAPI>("aedenthorn.PlannedParenthood");
if (plannedParenthoodAPI != null)
{
SMonitor.Log("PlannedParenthood API loaded");
}
contentPatcherAPI = SHelper.ModRegistry.GetApi<IContentPatcherAPI>("Pathoschild.ContentPatcher");
if(contentPatcherAPI is not null)
{
contentPatcherAPI.RegisterToken(context.ModManifest, "PlayerSpouses", () =>
{
Farmer player;
if (Context.IsWorldReady)
player = Game1.player;
else if (SaveGame.loaded?.player != null)
player = SaveGame.loaded.player;
else
return null;
var spouses = GetSpouses(player, true).Keys.ToList();
spouses.Sort(delegate (string a, string b) {
player.friendshipData.TryGetValue(a, out Friendship af);
player.friendshipData.TryGetValue(b, out Friendship bf);
if (af == null && bf == null)
return 0;
if (af == null)
return -1;
if (bf == null)
return 1;
if (af.WeddingDate == bf.WeddingDate)
return 0;
return af.WeddingDate > bf.WeddingDate ? -1 : 1;
});
return spouses.ToArray();
});
}
}
}
}