Skip to content

Commit

Permalink
Merge pull request #21 from KSP2Community/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
cheese3660 authored Dec 24, 2023
2 parents ef7f6e7 + 5945c5a commit 7783653
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin_template/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Patch Manager",
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
"source": "https://github.com/KSP2Community/PatchManager",
"version": "0.6.0",
"version": "0.6.1",
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
"ksp2_version": {
"min": "0.1.5",
Expand Down
2 changes: 1 addition & 1 deletion src/PatchManager.Core/Assets/PatchingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static void CreateNewAssets(Action resolve, Action<string> reject)
try
{
var text = generator.Create(out var label, out var name);
Logging.LogInfo($"Generated an asset with the label {label}, and name {name}:\n{text}");
Logging.LogDebug($"Generated an asset with the label {label}, and name {name}:\n{text}");

if (!_createdAssets.ContainsKey(label))
_createdAssets[label] = new List<(string name, string text)>();
Expand Down
1 change: 1 addition & 0 deletions src/PatchManager.Missions/Modifiables/MissionModifiable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public override void Set(DataValue dataValue)
if (dataValue.IsDeletion)
{
_missionSelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace PatchManager.SassyPatching.Attributes;
using JetBrains.Annotations;
using PatchManager.SassyPatching.Interfaces;

namespace PatchManager.SassyPatching.Attributes;



Expand All @@ -8,6 +11,8 @@
/// </summary>

[AttributeUsage(AttributeTargets.Class)]
[BaseTypeRequired(typeof(IPatcherRuleSet))]
[MeansImplicitUse]
public class PatcherRulesetAttribute : Attribute
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace PatchManager.SassyPatching.Attributes;
using JetBrains.Annotations;

namespace PatchManager.SassyPatching.Attributes;

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
[MeansImplicitUse]
public class SassyConstantAttribute : Attribute
{
public string ConstantName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace PatchManager.SassyPatching.Attributes;
using JetBrains.Annotations;

namespace PatchManager.SassyPatching.Attributes;

/// <summary>
/// Represents a builtin (C#) library for the sassy patcher execution engine
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
[MeansImplicitUse]
public class SassyLibraryAttribute : Attribute
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
namespace PatchManager.SassyPatching.Attributes;
using JetBrains.Annotations;

namespace PatchManager.SassyPatching.Attributes;

/// <summary>
/// Defines this as a method for sassy patcher, it can define any argument type it wants, and reflection will be used to convert them at runtime
/// Method overloading is not allowed
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
[MeansImplicitUse]
public class SassyMethodAttribute : Attribute
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public override void Set(DataValue dataValue)
if (dataValue.IsDeletion)
{
_experimentSelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
Expand Down
1 change: 1 addition & 0 deletions src/PatchManager.Science/Modifiables/ScienceModifiable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public override void Set(DataValue dataValue)
if (dataValue.IsDeletion)
{
_scienceSelectable.SetDeleted();
return;
}
base.Set(dataValue);
}
Expand Down
5 changes: 3 additions & 2 deletions src/PatchManager.Science/Rulesets/ScienceRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using PatchManager.SassyPatching.Interfaces;
using PatchManager.SassyPatching.NewAssets;
using PatchManager.SassyPatching.Selectables;
using PatchManager.Science.Selectables;

namespace PatchManager.Science.Rulesets;

Expand All @@ -13,12 +14,12 @@ public class ScienceRuleset : IPatcherRuleSet
public bool Matches(string label) => label == "techNodeData";

public ISelectable ConvertToSelectable(string type, string name, string jsonData) =>
new JTokenSelectable(() => { }, JObject.Parse(jsonData), name, type);
new ScienceSelectable(JObject.Parse(jsonData));


public INewAsset CreateNew(List<DataValue> dataValues)
{
return new NewGenericAsset("techNodeData", dataValues[0].String,
new JTokenSelectable(() => { }, JObject.Parse($"{{\n \"Version\": 12,\n \"ID\": \"{dataValues[0].String}\",\n \"NameLocKey\": \"Science/TechNodes/Names/tNode_4v_docking_01\",\n \"IconID\": \"ICO-RDCenter-Docking-24x\",\n \"CategoryID\": \"\",\n \"HiddenByNodeID\": \"\",\n \"DescriptionLocKey\": \"Science/TechNodes/Descriptions/tNode_4v_docking_01\",\n \"RequiredSciencePoints\": 7000,\n \"UnlockedPartsIDs\": [\n \"dockingring_4v_inline\",\n \"dockingport_3v_inline\"\n ],\n \"RequiredTechNodeIDs\": [\n \"tNode_4v_decouplers_01\"\n ],\n \"TierToUnlock\": 0,\n \"TechTreePosition\": {{\n \"x\": 5220.0,\n \"y\": 310.0\n }}\n}}"), dataValues[0].String, "techNodeData"));
new ScienceSelectable(JObject.Parse($"{{\n \"Version\": 12,\n \"ID\": \"{dataValues[0].String}\",\n \"NameLocKey\": \"Science/TechNodes/Names/tNode_4v_docking_01\",\n \"IconID\": \"ICO-RDCenter-Docking-24x\",\n \"CategoryID\": \"\",\n \"HiddenByNodeID\": \"\",\n \"DescriptionLocKey\": \"Science/TechNodes/Descriptions/tNode_4v_docking_01\",\n \"RequiredSciencePoints\": 7000,\n \"UnlockedPartsIDs\": [\n \"dockingring_4v_inline\",\n \"dockingport_3v_inline\"\n ],\n \"RequiredTechNodeIDs\": [\n \"tNode_4v_decouplers_01\"\n ],\n \"TierToUnlock\": 0,\n \"TechTreePosition\": {{\n \"x\": 5220.0,\n \"y\": 310.0\n }}\n}}")));
}
}

0 comments on commit 7783653

Please sign in to comment.