Skip to content

Commit

Permalink
Merge pull request #109 from UmbraSpaceIndustries/DEVELOP
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BobPalmer authored May 26, 2017
2 parents abdf7b0 + 88634bb commit 1236c7b
Show file tree
Hide file tree
Showing 23 changed files with 244 additions and 102 deletions.
5 changes: 5 additions & 0 deletions FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.9.0 - KSP 1.3
-------------------
KSP 1.3 Compatibility
Fix infinite loop with "prev loadout" when USILS is not installed

0.8.18 - 2017.03.17
-------------------
Fixed bugs related to ground tethers and PDU power transfers
Expand Down
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.dll
Binary file not shown.
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb
Binary file not shown.
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.pdb
Binary file not shown.
14 changes: 7 additions & 7 deletions FOR_RELEASE/GameData/000_USITools/USITools.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
},
"VERSION":{
"MAJOR":0,
"MINOR":8,
"PATCH":18,
"MINOR":9,
"PATCH":0,
"BUILD":0
},
"KSP_VERSION":{
"MAJOR":1,
"MINOR":2,
"PATCH":2
"MINOR":3,
"PATCH":0
},
"KSP_VERSION_MIN":{
"MAJOR":1,
"MINOR":2,
"PATCH":0
"PATCH":9
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":2,
"PATCH":2
"MINOR":3,
"PATCH":9
}
}
3 changes: 3 additions & 0 deletions USITools/USITools/Airbags/ModuleBounceCollider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public class ModuleBounceCollider : MonoBehaviour
Vector3 lastVel = Vector3.zero;
void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight)
return;

if (GetComponent<Rigidbody>())
lastVel = GetComponent<Rigidbody>().velocity;
}
Expand Down
3 changes: 3 additions & 0 deletions USITools/USITools/AquaticModules/ModuleAquaticEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class ModuleAquaticEmitter : PartModule

public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight)
return;

var eList = part.GetComponentsInChildren<KSPParticleEmitter>();
//Debug.Log("START: FOUND " + eList.Count() + " EMMITTERS!");

Expand Down
4 changes: 2 additions & 2 deletions USITools/USITools/ConverterPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace USITools
public class ConverterPart
{
public Part HostPart { get; set; }
public List<IEfficiencyBonusConsumer> Converters { get; }
public List<ModuleSwappableConverter> SwapBays { get; }
public List<IEfficiencyBonusConsumer> Converters { get; set; }
public List<ModuleSwappableConverter> SwapBays { get; set; }
public ConverterPart(Part p)
{
Converters = new List<IEfficiencyBonusConsumer>();
Expand Down
42 changes: 38 additions & 4 deletions USITools/USITools/Logistics/ModuleLogisticsConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ namespace USITools
[KSPModule("Logistics Consumer")]
public class ModuleLogisticsConsumer : PartModule
{
private double lastCheck;
[KSPField(isPersistant = true)]
private double lastCheck = -1d;

[KSPField]
public string autoResources = "";

Expand All @@ -25,19 +27,51 @@ public override void OnAwake()
return;

_conMods = part.FindModulesImplementing<ModuleResourceConverter>();
_maxDelta = ResourceUtilities.GetMaxDeltaTime();
}

private List<ModuleResourceConverter> _conMods;
private bool CatchupDone;
private double _maxDelta;
private List<ModuleResourceConverter> _conMods;

private bool InCatchupMode()
{
if (CatchupDone)
return false;

var count = _conMods.Count;
for (int i = 0; i < count; ++i)
{
var c = _conMods[i];
var em = c.GetEfficiencyMultiplier();
if(c.lastTimeFactor / 2 > em)
return true;
}
CatchupDone = true;
return false;
}

public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight)
return;

if (Math.Abs(Planetarium.GetUniversalTime() - lastCheck) < LogisticsSetup.Instance.Config.LogisticsTime)
if (lastCheck < 0)
lastCheck = vessel.lastUT;

if (!HighLogic.LoadedSceneIsFlight)
return;

lastCheck = Planetarium.GetUniversalTime();
var planTime = Planetarium.GetUniversalTime();

if (!InCatchupMode())
{
if (Math.Abs(planTime - lastCheck) < LogisticsSetup.Instance.Config.LogisticsTime)
return;
}

lastCheck = Math.Min(lastCheck + _maxDelta, planTime);

var count = _conMods.Count;
for (int i = 0; i < count; ++i)
{
Expand Down
24 changes: 24 additions & 0 deletions USITools/USITools/ModuleResourceConverter_USI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using USITools.KolonyTools;

namespace USITools
{
Expand All @@ -26,6 +27,29 @@ protected override void PreProcessing()
EfficiencyBonus = GetEfficiencyBonus();
}

protected override ConversionRecipe PrepareRecipe(double deltatime)
{
var recipe = base.PrepareRecipe(deltatime);
if (!USI_DifficultyOptions.ConsumeMachineryEnabled)
{
var iCount = recipe.Inputs.Count;
var oCount = recipe.Outputs.Count;
for (int i = iCount; i-- > 0;)
{
var ip = recipe.Inputs[i];
if (ip.ResourceName == "Machinery")
recipe.Inputs.Remove(ip);
}
for (int o = oCount; o-- > 0;)
{
var op = recipe.Outputs[o];
if (op.ResourceName == "Recyclables")
recipe.Inputs.Remove(op);
}
}
return recipe;
}

protected override void PostProcess(ConverterResults result, double deltaTime)
{
base.PostProcess(result, deltaTime);
Expand Down
25 changes: 2 additions & 23 deletions USITools/USITools/ModuleStabilization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@ namespace USITools
{
public class ModuleStabilization : VesselModule
{
[KSPField(isPersistant = true)]
public double posX;
[KSPField(isPersistant = true)]
public double posY;
[KSPField(isPersistant = true)]
public double posZ;

private Vector3d nuPos;

public static EventData<Vessel,bool,bool> onStabilizationToggle = new EventData<Vessel,bool,bool>("onStabilizationToggle");
private bool _stabilized;

public void Start()
{
onStabilizationToggle.Add(StabilizeVessel);
nuPos = vessel.GetWorldPos3D();
if (Math.Abs(posX + posY + posZ) < ResourceUtilities.FLOAT_TOLERANCE)
{
nuPos = new Vector3d(posX,posY,posZ);
}
}

public void OnDestroy()
Expand All @@ -39,12 +25,6 @@ private void StabilizeVessel(Vessel v, bool state, bool showMsg)
if (_stabilized == state)
return;

var pos = vessel.GetWorldPos3D();
posX = pos.x;
posY = pos.y;
posZ = pos.z;
nuPos = new Vector3d(posX, posY, posZ);

var newState = state;
var msg = "Ground tether released!";
if (newState)
Expand Down Expand Up @@ -73,11 +53,10 @@ public void FixedUpdate()
if (!vessel.Landed)
return;


//vessel.SetPosition(nuPos);
vessel.permanentGroundContact = true;

var c = vessel.parts.Count;
for(int i = 0; i < c; ++i)
for (int i = 0; i < c; ++i)
{
var r = vessel.parts[i].Rigidbody;
r.angularVelocity *= 0;
Expand Down
3 changes: 3 additions & 0 deletions USITools/USITools/ModuleSwappableConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void NextSetup()
[KSPEvent(active = true, guiActiveUnfocused = true, externalToEVAOnly = true, guiName = "B1: Prev. Loadout", unfocusedRange = 10f)]
public void PrevSetup()
{
if (Loadouts.Count < 2)
return;

displayLoadout--;
if (displayLoadout < 0)
{
Expand Down
2 changes: 1 addition & 1 deletion USITools/USITools/PartCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void SubCategories()
{
var icon = GenIcon(categoryTitle);
var filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
PartCategorizer.AddCustomSubcategoryFilter(filter, categoryTitle, icon, EditorItemsFilter);
PartCategorizer.AddCustomSubcategoryFilter(filter, categoryTitle, categoryTitle, icon, EditorItemsFilter);
}

private Icon GenIcon(string iconName)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1236c7b

Please sign in to comment.