Skip to content

Commit debac0f

Browse files
committed
Example mod for 0.2.0 StarMap
1 parent 231ae22 commit debac0f

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

StarMap.SimpleMod/Patcher.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using HarmonyLib;
2+
using KSA;
23

34
namespace StarMap.SimpleExampleMod
45
{
@@ -10,13 +11,20 @@ internal static class Patcher
1011
public static void Patch()
1112
{
1213
Console.WriteLine("Patching SimpleMod...");
13-
_harmony?.PatchAll();
14+
_harmony?.PatchAll(typeof(Patcher).Assembly);
1415
}
1516

1617
public static void Unload()
1718
{
1819
_harmony?.UnpatchAll(_harmony.Id);
1920
_harmony = null;
2021
}
22+
23+
[HarmonyPatch(typeof(ModLibrary), nameof(ModLibrary.LoadAll))]
24+
[HarmonyPostfix]
25+
public static void AfterLoad()
26+
{
27+
Console.WriteLine("ModLibrary.LoadAll patched by SimpleMod.");
28+
}
2129
}
2230
}

StarMap.SimpleMod/SimpleMod.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using Brutal.ImGuiApi;
2+
using KSA;
23
using StarMap.API;
34

45
namespace StarMap.SimpleExampleMod
56
{
6-
public class SimpleMod : IStarMapMod, IStarMapOnUi
7+
[StarMapMod]
8+
public class SimpleMod
79
{
8-
public bool ImmediateUnload => false;
9-
10+
[StarMapAfterGui]
1011
public void OnAfterUi(double dt)
1112
{
1213
ImGuiWindowFlags flags = ImGuiWindowFlags.MenuBar;
@@ -62,22 +63,25 @@ public void OnAfterUi(double dt)
6263
ImGui.End();
6364
}
6465

65-
public void OnBeforeUi(double dt)
66+
[StarMapImmediateLoad]
67+
public void OnImmediateLoad(Mod mod)
6668
{
69+
Console.WriteLine("SimpleMod - On immediate loaded");
70+
6771
}
6872

73+
[StarMapAllModsLoaded]
6974
public void OnFullyLoaded()
7075
{
76+
Console.WriteLine("SimpleMod - On fully loaded");
7177
Patcher.Patch();
7278

7379
}
7480

75-
public void OnImmediatLoad()
76-
{
77-
}
78-
81+
[StarMapUnload]
7982
public void Unload()
8083
{
84+
Console.WriteLine("SimpleMod - Unload");
8185
Patcher.Unload();
8286
}
8387
}

StarMap.SimpleMod/StarMap.SimpleMod.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</None>
1818
</ItemGroup>
1919

20-
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
20+
<ItemGroup>
2121
<Reference Include="..\..\Import\KSA.dll">
2222
<ExcludeAssets>runtime</ExcludeAssets>
2323
</Reference>
@@ -35,10 +35,14 @@
3535
</Reference>
3636
</ItemGroup>
3737

38-
<ItemGroup Condition="'$(Configuration)' != 'Debug'">
39-
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.4">
38+
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
39+
<Reference Include="..\..\Import\StarMap.API.dll">
4040
<ExcludeAssets>runtime</ExcludeAssets>
41-
</PackageReference>
41+
</Reference>
42+
</ItemGroup>
43+
44+
<ItemGroup Condition="'$(Configuration)' != 'Debug'">
45+
<PackageReference Include="StarMap.API" Version="0.2.1" />
4246
</ItemGroup>
4347

4448
</Project>

0 commit comments

Comments
 (0)