-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFile.cs
More file actions
68 lines (63 loc) · 2.35 KB
/
MainFile.cs
File metadata and controls
68 lines (63 loc) · 2.35 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
using System.Collections.Generic;
using System.Linq;
using BaseLib.Abstracts;
using Godot;
using HakureiReimu.HakureiReimuMod.Cards;
using HakureiReimu.HakureiReimuMod.Command;
using HakureiReimu.HakureiReimuMod.Core;
using HakureiReimu.HakureiReimuMod.Patches;
using HarmonyLib;
using MegaCrit.Sts2.Core.Combat;
using MegaCrit.Sts2.Core.Entities.Players;
using MegaCrit.Sts2.Core.Modding;
using MegaCrit.Sts2.Core.Models;
using MegaCrit.Sts2.Core.Nodes;
using MegaCrit.Sts2.Core.Runs;
using MegaCrit.Sts2.Core.Saves;
namespace HakureiReimu;
[ModInitializer(nameof(Initialize))]
public partial class MainFile : Node
{
public const string ModId = "HakureiReimu"; //Used for resource filepath
public static MegaCrit.Sts2.Core.Logging.Logger Logger { get; } = new(ModId, MegaCrit.Sts2.Core.Logging.LogType.Generic);
public static void Initialize()
{
Harmony harmony = new(ModId);
harmony.PatchAll();
Godot.Bridge.ScriptManagerBridge.LookupScriptsInAssembly(typeof(MainFile).Assembly);
// foreach (CardModel c in ModelDb.AllCards.Where(c=>c is AbstractCard))
// {
// SaveManager.Instance.Progress.MarkCardAsSeen(c.Id);
// }
ModHelper.SubscribeForCombatStateHooks(ModId,CombatHookSubscription );
CombatManager.Instance.CombatSetUp += _ => FollowDanmakuManager.Clear();
CombatManager.Instance.CombatEnded += _ => FollowDanmakuManager.Clear();
}
public static IEnumerable<AbstractModel> CombatHookSubscription(CombatState state)
{
bool alreadyFind = false;
foreach (Player p in state.Players)
{
if (!alreadyFind && p.Creature.CombatState != null && p.Character is HakureiReimuMod.Character.HakureiReimu c)
{
alreadyFind = true;
yield return c;
}
if (p.PlayerCombatState != null)
{
YinYangOrbManager m=YinYangOrbPatch.Managers[p.PlayerCombatState];
if (m != null)
{
yield return m;
foreach (YinYangOrb orb in m.Orbs)
{
if (!orb.HasBeenRemovedFromState && orb.Owner.IsActiveForHooks)
{
yield return orb;
}
}
}
}
}
}
}