New KerbalMassTracker Module that makes parts weigh more when Kerbals are inside.
New KerbalMassTracker Module that makes parts weigh more when Kerbals are inside.

  
  @PART[*]:HAS[#CrewCapacity[*]&!#CrewCapacity[0]]:NEEDS[!RealismOverhaul]:FOR[NidaSampi]
  {
  MODULE
  {
  name = ModuleKerbalMassTracker
  }
  }
 
  @PART[*]:HAS[#CrewCapacity[*]&!#CrewCapacity[0]]:NEEDS[RealismOverhaul]:AFTER[RealismOverhaul]
  {
  MODULE
  {
  name = ModuleKerbalMassTracker
  }
  }
  // NSScientific
  // by toadicus, dudecon
  //
  // KerbalMassTracker.cs
  //
  // This work is released into the Public Domain.
  //
 
  using KSP;
  using System;
  using System.Collections.Generic;
  using ToadicusTools;
  using UnityEngine;
 
  namespace NSScientific
  {
  public class ModuleKerbalMassTracker : PartModule
  {
  private const string KERBAL_RESOURCE_NAME = "KerbalMass";
 
  private PartResourceDefinition kerbalMassInfo;
 
  private PartResource partKerbalMass;
 
  private bool firstRun;
 
  public override void OnAwake()
  {
  Tools.PostDebugMessage(this, "Waking up...");
 
  this.firstRun = true;
 
  base.OnAwake();
 
  if (PartResourceLibrary.Instance != null)
  {
  this.kerbalMassInfo = PartResourceLibrary.Instance.GetDefinition(KERBAL_RESOURCE_NAME);
  }
 
  Tools.PostDebugMessage(
  this,
  "Fetched resource definition for {0}: {1}",
  KERBAL_RESOURCE_NAME,
  this.kerbalMassInfo == null ? "null" : this.kerbalMassInfo.ToString());
 
  if (base.part.CrewCapacity == 0)
  {
  Tools.PostDebugMessage(
  this,
  "Aborting, part has 0 CrewCapacity. Checking if {0} in Resources",
  KERBAL_RESOURCE_NAME);
 
  return;
  }
 
  bool hasResource = (base.part.Resources != null && base.part.Resources.Contains(KERBAL_RESOURCE_NAME));
 
  Tools.PostDebugMessage(this, "hasResource: {0}", hasResource);
 
  if (!hasResource)
  {
  Tools.PostDebugMessage(this, "resource not found, checking components manually just to be sure.");
 
  foreach (PartResource resourceComponent in base.part.GetComponents<PartResource>())
  {
  Tools.PostDebugMessage(this, "Checking {0}", resourceComponent.resourceName);
 
  if (resourceComponent.resourceName == KERBAL_RESOURCE_NAME)
  {
  hasResource = true;
  break;
  }
  }
  }
 
  Tools.PostDebugMessage(this, "hasResource: {0}", hasResource);
 
  if (!hasResource)
  {
  Tools.PostDebugMessage(this, "Adding resource to part");
 
  PartResource resource = base.part.gameObject.AddComponent<PartResource>();
  resource.SetInfo(this.kerbalMassInfo);
  resource.amount = 0;
  resource.maxAmount = base.part.CrewCapacity;
  }
 
  foreach (PartResource resource in base.part.GetComponents<PartResource>())
  {
  if (resource.resourceName == KERBAL_RESOURCE_NAME)
  {
  hasResource = true;
  this.partKerbalMass = resource;
  break;
  }
  }
 
  #if DEBUG
 
  Tools.PostDebugMessage(this, "Resource {0}added.", hasResource ? "" : "not ");
  #endif
 
  GameEvents.onCrewOnEva.Add(this.handleCrewOnEva);
  GameEvents.onCrewBoardVessel.Add(this.handleCrewBoardVessel);
  GameEvents.onCrewTransferred.Add(this.handleCrewTransferred);
 
  Tools.PostDebugMessage(this, "Awake.");
  }
 
  public void FixedUpdate()
  {
  if (this.firstRun)
  {
  Tools.PostDebugMessage(this, "First FixedUpdate.");
 
  this.resetKerbalMass();
 
  this.firstRun = false;
  }
  }
 
  public void OnDestroy()
  {
  GameEvents.onCrewOnEva.Remove(this.handleCrewOnEva);
  GameEvents.onCrewBoardVessel.Remove(this.handleCrewBoardVessel);
  GameEvents.onCrewTransferred.Remove(this.handleCrewTransferred);
 
  Tools.PostDebugMessage(this, "Destroyed.");
  }
 
  private void resetKerbalMass()
  {
  int crewCount = 0;
  if (base.part.protoModuleCrew != null)
  {
  crewCount = base.part.protoModuleCrew.Count;
  }
 
  this.partKerbalMass.amount = crewCount;
  }
 
  private void handleCrewOnEva(GameEvents.FromToAction<Part, Part> data)
  {
  Tools.PostDebugMessage(this, "Handling onCrewOnEva");
 
  this.resetKerbalMass();
  }
 
  private void handleCrewBoardVessel(GameEvents.FromToAction<Part, Part> data)
  {
  Tools.PostDebugMessage(this, "Handling onCrewOnEva");
 
  this.resetKerbalMass();
  }
 
  private void handleCrewTransferred(GameEvents.HostedFromToAction<ProtoCrewMember, Part> data)
  {
  Tools.PostDebugMessage(this, "Handling onCrewOnEva");
 
  this.resetKerbalMass();
  }
  }
  }
 
 
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug_win</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug_win</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D9FC2100-D482-4EF0-ACAE-66D040F903F1}</ProjectGuid> <ProjectGuid>{D9FC2100-D482-4EF0-ACAE-66D040F903F1}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>NSScientific</RootNamespace> <RootNamespace>NSScientific</RootNamespace>
<AssemblyName>NSScientific</AssemblyName> <AssemblyName>NSScientific</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<SynchReleaseVersion>false</SynchReleaseVersion> <SynchReleaseVersion>false</SynchReleaseVersion>
<UseMSBuildEngine>False</UseMSBuildEngine> <UseMSBuildEngine>False</UseMSBuildEngine>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_win|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_win|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants> <DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<CustomCommands> <CustomCommands>
<CustomCommands> <CustomCommands>
<Command type="AfterBuild" command="robocopy.bat ${TargetDir}\ C:\Users\andy\Games\KSP_win\GameData\NidaSampi\Scientific\ /s MM *.cfg ${TargetName}" /> <Command type="AfterBuild" command="robocopy.bat ${TargetDir}\ C:\Users\andy\Games\KSP_win\GameData\NidaSampi\Scientific\ /s MM *.cfg ${TargetName}" />
</CustomCommands> </CustomCommands>
</CustomCommands> </CustomCommands>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_win|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_win|AnyCPU' ">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath> <OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<CustomCommands> <CustomCommands>
<CustomCommands> <CustomCommands>
<Command type="AfterBuild" command="robocopy.bat ${TargetDir}\ C:\Users\andy\Games\KSP_win\GameData\NidaSampi\Scientific\ /s MM *.cfg ${TargetName}" /> <Command type="AfterBuild" command="robocopy.bat ${TargetDir}\ C:\Users\andy\Games\KSP_win\GameData\NidaSampi\Scientific\ /s MM *.cfg ${TargetName}" />
</CustomCommands> </CustomCommands>
</CustomCommands> </CustomCommands>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_linux|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug_linux|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants> <DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<CustomCommands> <CustomCommands>
<CustomCommands> <CustomCommands>
<Command type="AfterBuild" command="cp -avrf ${TargetDir}/MM ${TargetFile} /opt/games/KSP_testing/GameData/NidaSampi/Scientific/" /> <Command type="AfterBuild" command="cp -avrf ${TargetDir}/MM ${TargetFile} /opt/games/KSP_testing/GameData/NidaSampi/Scientific/" />
</CustomCommands> </CustomCommands>
</CustomCommands> </CustomCommands>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_linux|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_linux|AnyCPU' ">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath> <OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<CustomCommands> <CustomCommands>
<CustomCommands> <CustomCommands>
<Command type="AfterBuild" command="cp -avrf ${TargetDir}/MM ${TargetFile} /opt/games/KSP_testing/GameData/NidaSampi/Scientific/" /> <Command type="AfterBuild" command="cp -avrf ${TargetDir}/MM ${TargetFile} /opt/games/KSP_testing/GameData/NidaSampi/Scientific/" />
</CustomCommands> </CustomCommands>
</CustomCommands> </CustomCommands>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\_KSPAssemblies\Assembly-CSharp.dll</HintPath> <HintPath>..\_KSPAssemblies\Assembly-CSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="System"> <Reference Include="System">
<HintPath>..\_KSPAssemblies\System.dll</HintPath> <HintPath>..\_KSPAssemblies\System.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>..\_KSPAssemblies\UnityEngine.dll</HintPath> <HintPath>..\_KSPAssemblies\UnityEngine.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="NSSCelestialBodyFixer.cs" /> <Compile Include="NSSCelestialBodyFixer.cs" />
<Compile Include="..\ToadicusTools\ConfigNodeExtensions.cs"> <Compile Include="..\ToadicusTools\ConfigNodeExtensions.cs">
<Link>ConfigNodeExtensions.cs</Link> <Link>ConfigNodeExtensions.cs</Link>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NSSContractPicker.cs" /> <Compile Include="NSSContractPicker.cs" />
<Compile Include="..\ToadicusTools\Wrapper\ToolbarWrapper.cs"> <Compile Include="..\ToadicusTools\Wrapper\ToolbarWrapper.cs">
<Link>ToolbarWrapper.cs</Link> <Link>ToolbarWrapper.cs</Link>
</Compile> </Compile>
<Compile Include="NSSKerbinExplorer.cs" /> <Compile Include="NSSKerbinExplorer.cs" />
<Compile Include="..\ToadicusTools\Tools.cs"> <Compile Include="..\ToadicusTools\Tools.cs">
<Link>Tools.cs</Link> <Link>Tools.cs</Link>
</Compile> </Compile>
  <Compile Include="ModuleKerbalMassTracker.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="MM\ModuleRedefs.cfg"> <None Include="MM\ModuleRedefs.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="MM\PartRedefs.cfg"> <None Include="MM\PartRedefs.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="MM\ScienceRedefs.cfg"> <None Include="MM\ScienceRedefs.cfg">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </None>
  <None Include="Resources.cfg">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </None>
  <None Include="MM\MassTrackers.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ProjectExtensions> <ProjectExtensions>
<MonoDevelop> <MonoDevelop>
<Properties> <Properties>
<Policies> <Policies>
<StandardHeader Text="${ProjectName}&#xA;by toadicus, dudecon&#xA;&#xA;${FileName}&#xA;&#xA;This work is released into the Public Domain.&#xA;" IncludeInNewFiles="True" /> <StandardHeader Text="${ProjectName}&#xA;by toadicus, dudecon&#xA;&#xA;${FileName}&#xA;&#xA;This work is released into the Public Domain.&#xA;" IncludeInNewFiles="True" />
</Policies> </Policies>
</Properties> </Properties>
</MonoDevelop> </MonoDevelop>
</ProjectExtensions> </ProjectExtensions>
</Project> </Project>
file:b/Resources.cfg (new)
  //
  // NidaSampi Scientific
  // by toadicus, dudecon
  //
  // Resources.cfg
  //
  // This work is released into the Public Domain
  //
  // This software uses ModuleManager © 2014 sarbian, ialdabaoth, et al
  // used under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
  //
 
 
  RESOURCE_DEFINITION
  {
  name = KerbalMass
  density = 0.094
  unitCost = 0
  flowMode = NO_FLOW
  transfer = NONE
  isTweakable = false
  }