Skip to content

Commit ef7f6e7

Browse files
authored
Merge pull request #19 from KSP2Community/dev
0.6.0
2 parents e6fb681 + a196d2a commit ef7f6e7

37 files changed

Lines changed: 1304 additions & 190 deletions

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
<PropertyGroup Label="Build and namespace configuration">
1717
<SolutionDir Condition="'$(SolutionDir)'==''">$(MSBuildThisFileDirectory)</SolutionDir>
18-
<PluginBinPath>$(SolutionDir)build/bin/plugin</PluginBinPath>
19-
<PatcherBinPath>$(SolutionDir)build/bin/patcher</PatcherBinPath>
18+
<PluginBinPath>$(SolutionDir)build/bin/plugin/$(Configuration)</PluginBinPath>
19+
<PatcherBinPath>$(SolutionDir)build/bin/patcher/$(Configuration)</PatcherBinPath>
2020
<BaseOutputPath>$(PluginBinPath)/$(MSBuildProjectName)</BaseOutputPath>
2121
<BaseIntermediateOutputPath>$(SolutionDir)build/obj/plugin/$(MSBuildProjectName)</BaseIntermediateOutputPath>
2222
<AssemblyName>$(MSBuildProjectName)</AssemblyName>

PatchManager.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchManager.Planets", "src
2424
EndProject
2525
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchManager.Science", "src\PatchManager.Science\PatchManager.Science.csproj", "{E6AD9C2A-D53E-47DD-B48F-7A9AF6ACDC55}"
2626
EndProject
27+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PatchManager.Missions", "src\PatchManager.Missions\PatchManager.Missions.csproj", "{67F415B1-5651-4426-8D4C-F607CA31A338}"
28+
EndProject
2729
Global
2830
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2931
Debug|Any CPU = Debug|Any CPU
@@ -128,5 +130,13 @@ Global
128130
{E6AD9C2A-D53E-47DD-B48F-7A9AF6ACDC55}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
129131
{E6AD9C2A-D53E-47DD-B48F-7A9AF6ACDC55}.DeployAndRun|Any CPU.ActiveCfg = DeployAndRun|Any CPU
130132
{E6AD9C2A-D53E-47DD-B48F-7A9AF6ACDC55}.DeployAndRun|Any CPU.Build.0 = DeployAndRun|Any CPU
133+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
134+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Debug|Any CPU.Build.0 = Debug|Any CPU
135+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Release|Any CPU.ActiveCfg = Release|Any CPU
136+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Release|Any CPU.Build.0 = Release|Any CPU
137+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU
138+
{67F415B1-5651-4426-8D4C-F607CA31A338}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
139+
{67F415B1-5651-4426-8D4C-F607CA31A338}.DeployAndRun|Any CPU.ActiveCfg = DeployAndRun|Any CPU
140+
{67F415B1-5651-4426-8D4C-F607CA31A338}.DeployAndRun|Any CPU.Build.0 = DeployAndRun|Any CPU
131141
EndGlobalSection
132142
EndGlobal

plugin_template/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Patch Manager",
66
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
77
"source": "https://github.com/KSP2Community/PatchManager",
8-
"version": "0.5.0",
8+
"version": "0.6.0",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.1.5",

src/PatchManager.Core/PatchManager.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- References -->
44
<ItemGroup Label="NuGet package references">
55
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
6-
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.5" PrivateAssets="all" />
6+
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.2.0" PrivateAssets="all" Publicize="true" />
77
<PackageReference Include="SpaceWarp" Version="1.5.2" PrivateAssets="all" Publicize="true"/>
88
</ItemGroup>
99
<ItemGroup Label="Project references">
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using JetBrains.Annotations;
2+
using PatchManager.SassyPatching.Attributes;
3+
4+
namespace PatchManager.Missions.Builtins;
5+
6+
[SassyLibrary("builtin","missions")]
7+
[UsedImplicitly]
8+
public class MissionsBuiltins
9+
{
10+
11+
[SassyMethod("get-property-watcher"), UsedImplicitly]
12+
public static string GetPropertyWatcher([SassyName("property-watcher-name")] string propertyWatcherName) =>
13+
MissionsTypes.PropertyWatchers[propertyWatcherName].AssemblyQualifiedName!;
14+
15+
[SassyMethod("get-message"), UsedImplicitly]
16+
public static string GetMessage([SassyName("message-name")] string messageName) =>
17+
MissionsTypes.Messages[messageName].AssemblyQualifiedName!;
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using JetBrains.Annotations;
2+
using PatchManager.Shared.Modules;
3+
4+
namespace PatchManager.Missions;
5+
6+
[UsedImplicitly]
7+
public class MissionsModule : BaseModule
8+
{
9+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using KSP.Game.Missions;
2+
using KSP.Messages;
3+
using KSP.Messages.PropertyWatchers;
4+
5+
namespace PatchManager.Missions;
6+
7+
public static class MissionsTypes
8+
{
9+
public static Dictionary<string, Type> Conditions = new();
10+
public static Dictionary<string, Type> Actions = new();
11+
public static Dictionary<string, Type> Messages = new();
12+
public static Dictionary<string, Type> PropertyWatchers = new();
13+
14+
static MissionsTypes()
15+
{
16+
foreach (var type in AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).Where(t => !t.IsAbstract))
17+
{
18+
if (type.IsSubclassOf(typeof(Condition)))
19+
{
20+
Conditions.Add(type.Name,type);
21+
}
22+
23+
if (typeof(IMissionAction).IsAssignableFrom(type))
24+
{
25+
Actions.Add(type.Name, type);
26+
}
27+
28+
if (type.IsSubclassOf(typeof(MessageCenterMessage)))
29+
{
30+
Messages.Add(type.Name, type);
31+
}
32+
33+
if (type.IsSubclassOf(typeof(PropertyWatcher)))
34+
{
35+
PropertyWatchers.Add(type.Name, type);
36+
}
37+
}
38+
}
39+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using PatchManager.Missions.Selectables;
2+
using PatchManager.SassyPatching;
3+
using PatchManager.SassyPatching.Modifiables;
4+
5+
namespace PatchManager.Missions.Modifiables;
6+
7+
public class MissionModifiable : JTokenModifiable
8+
{
9+
private MissionSelectable _missionSelectable;
10+
11+
public MissionModifiable(MissionSelectable selectable) : base(selectable.MissionObject, selectable.SetModified)
12+
{
13+
_missionSelectable = selectable;
14+
}
15+
16+
public override void Set(DataValue dataValue)
17+
{
18+
if (dataValue.IsDeletion)
19+
{
20+
_missionSelectable.SetDeleted();
21+
}
22+
base.Set(dataValue);
23+
}
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\PatchManager.SassyPatching\PatchManager.SassyPatching.csproj" />
10+
<ProjectReference Include="..\PatchManager.Shared\PatchManager.Shared.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.2.0" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using KSP.Game.Missions.Definitions;
2+
using Newtonsoft.Json.Linq;
3+
using PatchManager.Missions.Selectables;
4+
using PatchManager.SassyPatching;
5+
using PatchManager.SassyPatching.Attributes;
6+
using PatchManager.SassyPatching.Interfaces;
7+
using PatchManager.SassyPatching.NewAssets;
8+
9+
namespace PatchManager.Missions.Rulesets;
10+
11+
[PatcherRuleset("missions","missions")]
12+
public class MissionRuleset : IPatcherRuleSet
13+
{
14+
public bool Matches(string label) => label == "missions";
15+
16+
public ISelectable ConvertToSelectable(string type, string name, string jsonData) =>
17+
new MissionSelectable(JObject.Parse(jsonData));
18+
19+
public INewAsset CreateNew(List<DataValue> dataValues)
20+
{
21+
var missionDataObject = new MissionData
22+
{
23+
ID = dataValues[0].String
24+
};
25+
26+
return new NewGenericAsset("missions", dataValues[0].String,
27+
new MissionSelectable(JObject.FromObject(missionDataObject)));
28+
}
29+
}

0 commit comments

Comments
 (0)