Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Electrocutor committed Nov 19, 2018
1 parent 73d44f5 commit 7b9af54
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions KSPF/KSPF.csproj
Expand Up @@ -42,8 +42,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Parts\Addons\PartVariantsEx.cs" />
<Compile Include="Parts\PartModules\ModulePartVariantsEx.cs" />
<Compile Include="Parts\Addons\ModulePartVariantsEx.cs" />
<Compile Include="Parts\PartModules\ModulePartData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Expand Up @@ -8,7 +8,7 @@ namespace KSPF.Parts.Addons
/// Addon used to hook the existing ModulePartVariants and extend it
/// </summary>
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class PartVariantsEx : MonoBehaviour
public class ModulePartVariantsEx : MonoBehaviour
{
private bool _Debug = false;
private EventData<Part, PartVariant>.OnEvent VariantAppliedEvent;
Expand Down Expand Up @@ -37,7 +37,7 @@ private void VariantAppliedEventHandler(Part oPart, PartVariant oVariant)

foreach (PartResourceDefinition oResourceDef in PartResourceLibrary.Instance.resourceDefinitions)
{
sValue = oVariant.GetExtraInfoValue("resource/" + oResourceDef.name);
sValue = oVariant.GetExtraInfoValue("Resource/" + oResourceDef.name);

if (!string.IsNullOrEmpty(sValue))
{
Expand Down
@@ -1,23 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KSPF.Parts.PartModules
{
/// <summary>
/// Allows persisting of part-level properties per instance of part that are usually only at the AvailablePart definition level
/// </summary>
public class ModulePartVariantsEx : PartModule
public class ModulePartData : PartModule
{
[KSPField(isPersistant = true)]
public string internalModel = null;
public string InternalModel = null;

[KSPField(isPersistant = true)]
public float rescaleFactor = 0.0f;
public float RescaleFactor = 0.0f;

[KSPField(isPersistant = true)]
public float scale = 0.0f;
public float Scale = 0.0f;

public override void OnAwake()
{
Expand All @@ -33,29 +31,29 @@ public override void OnLoad(ConfigNode node)

private void SetInternalModel()
{
if (string.IsNullOrEmpty(this.internalModel))
if (string.IsNullOrEmpty(this.InternalModel))
{ return; }

ConfigNode oConfig = new ConfigNode("INTERNAL");
oConfig.AddValue("name", this.internalModel);
oConfig.AddValue("name", this.InternalModel);

this.part.partInfo.internalConfig = oConfig;
}

private void SetRescaleFactor()
{
if (this.rescaleFactor == 0.0f)
if (this.RescaleFactor == 0.0f)
{ return; }

this.part.rescaleFactor = this.rescaleFactor;
this.part.rescaleFactor = this.RescaleFactor;
}

private void SetScale()
{
if (this.scale == 0.0f)
if (this.Scale == 0.0f)
{ return; }

this.part.scaleFactor = this.scale;
this.part.scaleFactor = this.Scale;
}
}
}
2 changes: 1 addition & 1 deletion README.md
@@ -1,5 +1,5 @@
# Kerbal Space Program Framework
A comprehensive, organized, and efficient API to KSP.
A comprehensive, organized, and efficient API to KSP

## Part Modules
* ModulePartVariantsEx

0 comments on commit 7b9af54

Please sign in to comment.