Skip to content

Commit

Permalink
Allow SRB failures on EnginesFX modules
Browse files Browse the repository at this point in the history
  • Loading branch information
602p committed Dec 7, 2014
1 parent 33f5db6 commit e0b24d1
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 268 deletions.
12 changes: 12 additions & 0 deletions Entropy/Entropy/Entropy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,22 @@
<Compile Include="FailureModules\Parachutes.cs" />
<Compile Include="FailureModules\Animate.cs" />
<Compile Include="FailureModules\Generator.cs" />
<Compile Include="FailureModules\SRB_engineFX.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="FailureModules\" />
<Folder Include="Utilities\" />
</ItemGroup>
<ItemGroup>
<None Include="ModuleManager\Animations.cfg" />
<None Include="ModuleManager\Engines_Coolant.cfg" />
<None Include="ModuleManager\Generators.cfg" />
<None Include="ModuleManager\Intakes.cfg" />
<None Include="ModuleManager\Parachutes.cfg" />
<None Include="ModuleManager\SmallTanks.cfg" />
<None Include="ModuleManager\Solar.cfg" />
<None Include="ModuleManager\SRBs.cfg" />
<None Include="ModuleManager\Stock_Ignores.cfg" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions Entropy/Entropy/Entropy.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entropy", "Entropy.csproj", "{7EFBE627-9945-4E79-8976-CC0C67FA6C18}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7EFBE627-9945-4E79-8976-CC0C67FA6C18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EFBE627-9945-4E79-8976-CC0C67FA6C18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EFBE627-9945-4E79-8976-CC0C67FA6C18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EFBE627-9945-4E79-8976-CC0C67FA6C18}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Entropy.csproj
EndGlobalSection
EndGlobal
61 changes: 61 additions & 0 deletions Entropy/Entropy/FailureModules/SRB_engineFX.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections;
using System.Linq;
using System.Text;
using ippo;
using UnityEngine;
using KSP;

namespace coffeeman
{
public class ModuleSRBFXReliability : ippo.FailureModule
{
ModuleEnginesFX srb;

public override string DebugName { get { return "O-Ring"; } }
public override string ScreenName { get { return "O-Ring"; } }
public override string FailureMessage { get { return "An O-Ring has cracked, Abort!"; } }
public override string RepairMessage { get { return ""; } }
public override string FailGuiName { get { return "Fail O-Ring"; } }
public override string EvaRepairGuiName { get { return ""; } }
public override string MaintenanceString { get { return "Replace O-Ring"; } }

public bool overloading = false;
public float overloadbonus = 0F;

public override bool PartIsActive()
{
// A SRB is active if it is running
return srb.EngineIgnited & srb.CalculateThrust()>0;
}

protected override void DI_Start(StartState state)
{
srb = this.part.Modules.OfType<ModuleEnginesFX>().Single();
}

protected override bool DI_FailBegin()
{
return true;
}

protected override void DI_Disable()
{
srb.heatProduction += srb.part.maxTemp/4F; //Increase the heat so it explodes
overloading = true;
}

protected override void DI_EvaRepair(){}

protected override void DI_Update(){
if (overloading){
srb.rigidbody.AddRelativeForce(Vector3.forward * overloadbonus); //Increase thrust thru hack
overloadbonus += srb.maxThrust / 60; //This is a considerable amount
if (!PartIsActive ()) {
overloading = false; //Stop if the part is disabled
}
}
}
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@PART[*]:HAS[@MODULE[ModuleEngines]:HAS[@PROPELLANT[SolidFuel]],!MODULE[NoSRBFailures],]:NEEDS[DangIt]:FOR[Entropy]
@PART[*]:HAS[@MODULE[ModuleEnginesFX]:HAS[@PROPELLANT[SolidFuel]],!MODULE[NoSRBFailures],]:NEEDS[DangIt]:FOR[Entropy]
{
MODULE
{
name = ModuleSRBReliability
name = ModuleSRBFXReliability

// Annual Failure Rate: 100%
MTBF = 8000;
Expand Down
13 changes: 13 additions & 0 deletions Entropy/Entropy/Utilities/PermissiveEnginesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ public float CurrentThrottle
}
}

public float CurrentThrust
{
get
{
float throttle = 0;

if (engines.Count > 0) throttle = engines.Max(e => e.CalculateThrust());
if (enginesFX.Count > 0) throttle = Math.Max(throttle, enginesFX.Max(e => e.CalculateThrust()));

return throttle;
}
}


/// <summary>
/// Disables all the engine modules.
Expand Down
Binary file removed Output/GameData/Entropy/Entropy.dll
Binary file not shown.
36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Animations.cfg

This file was deleted.

36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Engines_Coolant.cfg

This file was deleted.

36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Generators.cfg

This file was deleted.

36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Intakes.cfg

This file was deleted.

36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Parachutes.cfg

This file was deleted.

36 changes: 0 additions & 36 deletions Output/GameData/Entropy/ModuleManager/Solar.cfg

This file was deleted.

14 changes: 0 additions & 14 deletions Output/GameData/Entropy/ModuleManager/Stock_Ignores.cfg

This file was deleted.

Binary file not shown.
Loading

0 comments on commit e0b24d1

Please sign in to comment.