Skip to content

Commit

Permalink
merged in hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ItMustBeACamel committed Sep 11, 2014
2 parents 0494c51 + 77e6ed3 commit e6108e9
Show file tree
Hide file tree
Showing 29 changed files with 1,296 additions and 295 deletions.
21 changes: 17 additions & 4 deletions GameData/ProcAirships/Parts/BallastTank.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PART
node_attach=0,0,0.5,0,0,-1,1

// --- editor parameters ---
cost = 4000
cost = 300
TechRequired = start
entryCost = 4000
category = Aero
Expand Down Expand Up @@ -49,6 +49,16 @@ PART
name = ProceduralPart
textureSet=Stockalike
shapeName=Fillet Cylinder
TECHLIMIT {

name = start
diameterMin = 0.1
diameterMax = Infinity
lengthMin = 0.1
lengthMax = Infinity
volumeMin = 0.001
volumeMax = Infinity
}
}
MODULE
{
Expand Down Expand Up @@ -129,9 +139,12 @@ PART
MODULE
{
name = BuoyancyStats

}



MODULE
{
name=AirshipCost
costPerCubicMeter=0.1 // cost per m³
}

}
22 changes: 19 additions & 3 deletions GameData/ProcAirships/Parts/Envelope.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ PART
node_attach=0,0,0.5,0,0,-1,1

// --- editor parameters ---
cost = 4000
cost = 300
TechRequired = start
entryCost = 4000
category = Aero
subcategory = 0
title = Airship envelope
title = Airship Envelope
manufacturer = Count Keppelins Airship manufactory
description = TODO

Expand All @@ -49,6 +49,16 @@ PART
name = ProceduralPart
textureSet=PlainWhite
shapeName=Fillet Cylinder
TECHLIMIT {

name = start
diameterMin = 0.1
diameterMax = Infinity
lengthMin = 0.1
lengthMax = Infinity
volumeMin = 0.001
volumeMax = Infinity
}
}
MODULE
{
Expand Down Expand Up @@ -97,7 +107,7 @@ PART
name = AirshipEnvelope
dryMassPerQubicMeter = 0.0005 //in tonnes
idealRelPressure = 0.005 // in bar
PressureTolerance = 0.05 // +- in bar
pressureTolerance = 0.05 // +- in bar
}

MODULE
Expand All @@ -110,4 +120,10 @@ PART
name=BuoyancyStats
}

MODULE
{
name=AirshipCost
costPerCubicMeter=0.2 // cost per m³
}

}
24 changes: 20 additions & 4 deletions GameData/ProcAirships/Parts/EnvelopeCap.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PART
{
// --- general parameters ---
name = AirshipEnvelopeCone
name = AirshipEnvelopeCap
module = Part
author = RadarManFromTheMoon

Expand All @@ -18,12 +18,12 @@ PART
node_stack_bottom=0,-0.5,0,0,-1,0,1

// --- editor parameters ---
cost = 4000
cost = 300
TechRequired = start
entryCost = 4000
category = Aero
subcategory = 0
title = Airship envelope cone
title = Airship Envelope Cap
manufacturer = Count Keppelins Airship manufactory
description = TODO

Expand All @@ -46,6 +46,17 @@ PART
{
name = ProceduralPart
textureSet=PlainWhite
shapeName=Smooth Cone
TECHLIMIT {

name = start
diameterMin = 0.5
diameterMax = Infinity
lengthMin = 0.5
lengthMax = Infinity
volumeMin = 0.001
volumeMax = Infinity
}
}

MODULE
Expand All @@ -66,7 +77,7 @@ PART
name = AirshipEnvelope
dryMassPerQubicMeter = 0.0005 //in tonnes
idealRelPressure = 0.005 // in bar
PressureTolerance = 0.05
pressureTolerance = 0.05 // +- in bar
}

MODULE
Expand All @@ -80,5 +91,10 @@ PART

}

MODULE
{
name=AirshipCost
costPerCubicMeter=0.2 // cost per m³
}

}
2 changes: 2 additions & 0 deletions GameData/ProcAirships/Resources/AirshipResources.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ LIFTING_GAS_OPTIONS
molarMass = 2.01588 // grams per mol.
combustible = true
maxTemperature = 300
cost = 2
}

LIFTING_GAS
Expand All @@ -57,6 +58,7 @@ LIFTING_GAS_OPTIONS
molarMass = 4.002602 // grams per mol.
combustible = false
maxTemperature = 300
cost = 2.3

}
}
6 changes: 0 additions & 6 deletions GameData/ProcAirships/airships.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Procedural Airships
===================

ver. 0.3.0.0 - experimental
ver. 0.4.1.0 - beta

This plugin adds procedural airship envelopes to Kerbal Space Program

**!!!WORK IN PROGRESS!!!**
**This will most certainly be full of bugs and breaks savegames/crafts. Only use it for test purposes**
**This is a beta version. It may contain bugs**

Dependencies:
* swamp_ig's great ProceduralParts mod. Get it [here](http://forum.kerbalspaceprogram.com/threads/70676-0-24-2WIP-Procedural-Parts-Parts-the-way-you-want-em-0-9-18-Aug-6 "ProceduralParts mod").
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 0.4.1.0
-Bugfix: Fixed a major bug that prevents Procedural Airships from function properly in career mode

Version 0.4.0.0
-Feature: FAR compatibility
-Feature: procedural cost handling
-Feature: Parts are no longer controllable without a pod or probecore
-Feature: Center of Buoyancy marker in editor (activates with CoL marker)

Version 0.3.0.0
-Feature: envelopes containing combustrogen will explode when exposed to high temperatures
-Feature: envelopes will explode when their gas pressure exceeds the tolerance
Expand Down
92 changes: 92 additions & 0 deletions source/ProcAirships/AirshipCost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KSPAPIExtensions;
using KSPAPIExtensions.PartMessage;

namespace ProcAirships
{
public class AirshipCost : PartModule, IPartCostModifier
{

[KSPField]
public float costPerCubicMeter = 0.0f;

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

private float envelopeVolume=0.0f;



public override void OnAwake()
{
Log.post(this.ClassName + " OnAwake-callback: ");

base.OnAwake();
PartMessageService.Register(this);
Log.post(this.ClassName + "end of OnAwake-callback: ");
}



// message receiving

[PartMessageListener(typeof(PartVolumeChanged), scenes: ~GameSceneFilter.Flight)]
public void ChangeVolume(string volumeName, float volume)
{
Log.post("AirshipCost received ChangeVolume message for " + volumeName + " Volume: " + volume);
if (volumeName != PartVolumes.Tankage.ToString())
return;

if (volume <= 0f)
{
Log.post("volume is: " + volume.ToString() + " thats odd... setting volume to 1 instead");
envelopeVolume = 1.0f;
}
else
{
Log.post("tank Volume Changed to " + volume, LogLevel.LOG_INFORMATION);

envelopeVolume = volume;
}

}


// interface

public float GetModuleCost()
{
if (util.editorActive())
{
//Log.post(this.ClassName + " getModuleCost");
float cost = costPerCubicMeter * envelopeVolume;

//Log.post(this.ClassName + " volume: " + envelopeVolume);
//Log.post(this.ClassName + " cost per m³: " + costPerCubicMeter);
//Log.post(this.ClassName + " volume costs: " + cost);

foreach (PartResource resource in part.Resources)
{
cost += (float)(resource.info.unitCost * resource.amount);
}
//Log.post(this.ClassName + " cost after resource costs: " + cost);

foreach (AirshipEnvelope e in part.Modules.OfType<AirshipEnvelope>())
{
AirshipEnvelope.LiftingGas lg = e.getCurrentLiftingGas();
if (lg != null)
cost += e.getCurrentLiftingGas().cost * e.LiftingGasAmount;
}
//Log.post(this.ClassName + " cost after lifting gas costs: " + cost);

//Log.post(this.ClassName + " end of getModuleCost");
overallCost = cost;
}

return overallCost;
}
}
}
10 changes: 8 additions & 2 deletions source/ProcAirships/AirshipDrainResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class AirshipDrainResource : PartModule
public void toggleDump(KSPActionParam ap)
{
Log.post("ACTION: toggle dumping '" + displayName + "'.", LogLevel.LOG_INFORMATION);
dumping.Toggle();
dumping = dumping.Toggle();
}

[KSPAction(guiName:"start dumping")]
Expand Down Expand Up @@ -114,6 +114,12 @@ public float DumpRate
}
}

public bool isControllable
{
get { return part.isControllable && !Preferences.alwaysControllable; }

}

#endregion
//------------------------------------------------------------------------------------------------------------------------
#region Message receiving
Expand Down Expand Up @@ -165,7 +171,7 @@ public override void OnStart(StartState state)

public override void OnFixedUpdate()
{
if (dumping)
if (dumping && isControllable)
{
float amountDumped;
Log.post("dumping: " + resourceName + " at rate " + dumpRate);
Expand Down
Loading

0 comments on commit e6108e9

Please sign in to comment.