Skip to content

Commit

Permalink
Merge pull request #143 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
1.12 updates
  • Loading branch information
ChrisAdderley committed Jul 21, 2021
2 parents 41e9901 + 17db44b commit 52aba0e
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .mod_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ dependencies: # Configure dependencies
version: 4.1.3
location: s3
B9PartSwitch:
version: 2.17.0
version: 2.18.0
location: s3
CommunityResourcePack:
version: 1.4.2
location: s3
DynamicBatteryStorage:
tag: 2.2.2
tag: 2.2.4
location: github
repository: post-kerbin-mining-corporation/DynamicBatteryStorage
deploy:
Expand Down
Binary file not shown.
Binary file modified GameData/NearFutureElectrical/Parts/NuclearFuel/nuclearfuel-25.mu
Binary file not shown.
Binary file modified GameData/NearFutureElectrical/Plugins/NearFutureElectrical.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
{
"MAJOR":1,
"MINOR":2,
"PATCH":2,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":
{
"MAJOR":1,
"MINOR":11,
"PATCH":2
"MINOR":12,
"PATCH":1
},
"KSP_VERSION_MIN":{
"MAJOR":1,
Expand All @@ -22,7 +22,7 @@
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":11,
"MINOR":12,
"PATCH":99
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Ever wanted some futuristic energy generation that wasn't too... futuristic? I h
### Required
These components are required for the mod to function and are bundled as part of any download:
* [ModuleManager (4.1.4)](https://github.com/sarbian/ModuleManager)
* [B9PartSwitch (2.17.0)](https://github.com/blowfishpro/B9PartSwitch)
* [B9PartSwitch (2.18.0)](https://github.com/blowfishpro/B9PartSwitch)
* [Community Resource Pack (1.4.2)](https://github.com/BobPalmer/CommunityResourcePack)
* [DynamicBatteryStorage (2.2.2)](https://github.com/ChrisAdderley/DynamicBatteryStorage)
* [DynamicBatteryStorage (2.2.4)](https://github.com/ChrisAdderley/DynamicBatteryStorage)

## Installation

Expand Down
119 changes: 63 additions & 56 deletions Source/NearFutureElectrical/FissionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,90 @@
///

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using KSP.Localization;

namespace NearFutureElectrical
{
public class FissionGenerator: FissionConsumer
{
public class FissionGenerator : FissionConsumer, IContractObjectiveModule
{

// Maximum power generation
[KSPField(isPersistant = false)]
public float PowerGeneration = 100f;
// Maximum power generation
[KSPField(isPersistant = false)]
public float PowerGeneration = 100f;

// Current power generation
[KSPField(isPersistant = true)]
public float CurrentGeneration = 0f;
// Current power generation
[KSPField(isPersistant = true)]
public float CurrentGeneration = 0f;

// Reactor Status string
[KSPField(isPersistant = false, guiActive = true, guiName = "Generation")]
public string GeneratorStatus;
// Reactor Status string
[KSPField(isPersistant = false, guiActive = true, guiName = "Generation")]
public string GeneratorStatus;

public override string GetInfo()
{
return Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_PartInfo", PowerGeneration.ToString("F0"));
}
public string GetModuleTitle()
{
return "FissionGenerator";
}
public override string GetModuleDisplayName()
{
return Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_ModuleName");
}
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);
public override string GetInfo()
{
return Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_PartInfo", PowerGeneration.ToString("F0"));
}
public string GetModuleTitle()
{
return "FissionGenerator";
}
public override string GetModuleDisplayName()
{
return Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_ModuleName");
}

Fields["GeneratorStatus"].guiName = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus");
}
public virtual string GetContractObjectiveType()
{
return "Generator";
}
public virtual bool CheckContractObjectiveValidity()
{
return true;
}

public void FixedUpdate()
{
if (HighLogic.LoadedScene == GameScenes.FLIGHT)
{
public override void OnStart(PartModule.StartState state)
{
base.OnStart(state);

Fields["GeneratorStatus"].guiName = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus");
}

if (Status)
{
public void FixedUpdate()
{
if (HighLogic.LoadedScene == GameScenes.FLIGHT)
{

double generated = (double)(Mathf.Clamp01(CurrentHeatUsed / HeatUsed) * PowerGeneration);
if (Status)
{

double delta = 0d;
for (int i = 0; i < this.vessel.parts.Count; i++)
double generated = (double)(Mathf.Clamp01(CurrentHeatUsed / HeatUsed) * PowerGeneration);

{
if (this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id) != null)
delta += this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id).maxAmount -
this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id).amount;
}
double delta = 0d;
for (int i = 0; i < this.vessel.parts.Count; i++)

double generatedActual = Math.Min(delta, TimeWarp.fixedDeltaTime * generated);
{
if (this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id) != null)
delta += this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id).maxAmount -
this.vessel.parts[i].Resources.Get(PartResourceLibrary.Instance.GetDefinition("ElectricCharge").id).amount;
}

double amt = this.part.RequestResource("ElectricCharge", -generatedActual);
double generatedActual = Math.Min(delta, TimeWarp.fixedDeltaTime * generated);

if (double.IsNaN(generated))
generated = 0.0;
double amt = this.part.RequestResource("ElectricCharge", -generatedActual);

CurrentGeneration = (float)generated;
GeneratorStatus = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus_Normal", generated.ToString("F1"));
}
else
GeneratorStatus = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus_Offline");
}
if (double.IsNaN(generated))
generated = 0.0;

CurrentGeneration = (float)generated;
GeneratorStatus = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus_Normal", generated.ToString("F1"));
}

else
GeneratorStatus = Localizer.Format("#LOC_NFElectrical_ModuleFissionGenerator_Field_GeneratorStatus_Offline");
}

}


}
}
13 changes: 11 additions & 2 deletions Source/NearFutureElectrical/RadioisotopeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace NearFutureElectrical
{
public class ModuleRadioisotopeGenerator : PartModule
public class ModuleRadioisotopeGenerator : PartModule, IContractObjectiveModule
{
// Power generated at max
[KSPField(isPersistant = false)]
Expand Down Expand Up @@ -40,7 +40,16 @@ public class ModuleRadioisotopeGenerator : PartModule

protected double localHalfLife = 0d;

protected void Start()
public virtual string GetContractObjectiveType()
{
return "Generator";
}
public virtual bool CheckContractObjectiveValidity()
{
return true;
}

protected void Start()
{
localHalfLife = Utils.KerbinYearsToLocalYears(HalfLife);
}
Expand Down
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v1.2.3
------
- KSP 1.12
- Updated B9PartSwitch to 2.18.0
- Updated DynamicBatteryStorage to 2.2.4
- RadioisotopeGenerator and FissionGenerator modules now count for contract objective completion

v1.2.2
------
- Updated DynamicBatteryStorage to 2.2.2
Expand Down
8 changes: 4 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=============================
NEAR FUTURE ELECTRICAL v1.2.1
============================2
NEAR FUTURE ELECTRICAL v1.2.3
=============================

This pack contains advanced electrical parts - capacitors, nuclear reactors and new battery packs.

Expand All @@ -9,10 +9,10 @@ DEPENDENCIES
============

Required:
- B9PartSwitch (2.17.0)
- B9PartSwitch (2.18.0)
- Community Resource Pack (1.4.2)
- ModuleManager (4.1.4)
- DynamicBatteryStorage (2.2.2)
- DynamicBatteryStorage (2.2.4)

Optional
- Community Tech Tree (v2.2+)
Expand Down

0 comments on commit 52aba0e

Please sign in to comment.