Skip to content

Commit

Permalink
Fixed drag cube for the ACDSmall, ACD1500, ACDLarge decoupler
Browse files Browse the repository at this point in the history
 Added Mass to USSolarSwitch
 Added display of mass & cost of USSolarSwitch to PAW
 Fixed IndexOutOfRange exception for microsats, due to no _PanelMasses specified (was added for embedded panels)
  • Loading branch information
linuxgurugamer committed Mar 18, 2022
1 parent c033380 commit b604afc
Show file tree
Hide file tree
Showing 20 changed files with 299 additions and 168 deletions.
6 changes: 6 additions & 0 deletions Changelog.txt
Expand Up @@ -87,5 +87,11 @@
Thanks to @jamesErvin for updates to the English localization
Added DockingCamera support for the AdvancedMicroSatWedge

4.0.0.7
Fixed drag cube for the ACDSmall, ACD1500, ACDLarge decoupler
Added Mass to USSolarSwitch
Added display of mass & cost of USSolarSwitch to PAW
Fixed IndexOutOfRange exception for microsats, due to no _PanelMasses specified (was added for embedded panels)

TODO
Update all language files for missing fields
2 changes: 1 addition & 1 deletion GameData/UniversalStorage2/Parts/Control/ACD1500.cfg
Expand Up @@ -216,7 +216,7 @@ PART
minimum_drag = 0.2
DRAG_CUBE
{
Default, 0.1988,0.7448,0.8757, 0.1988,0.7448,0.8757, 1.217,0.9952,0.1299, 1.217,0.9952,0.1299, 0.1988,0.7442,0.8871, 0.1988,0.7442,0.8871, 0,0,0, 1.25,0.16,1.25
cube =Default, 0.1988,0.7448,0.8757, 0.1988,0.7448,0.8757, 1.217,0.9952,0.1299, 1.217,0.9952,0.1299, 0.1988,0.7442,0.8871, 0.1988,0.7442,0.8871, 0,0,0, 1.25,0.16,1.25
}

// Model call
Expand Down
2 changes: 1 addition & 1 deletion GameData/UniversalStorage2/Parts/Control/ACDLarge.cfg
Expand Up @@ -218,7 +218,7 @@ PART
minimum_drag = 0.2
DRAG_CUBE
{
Default, 0.7952,0.745,1.652, 0.7952,0.745,1.652, 4.87,0.9796,0.1611, 4.87,0.9796,0.1611, 0.7952,0.7447,1.673, 0.7952,0.7447,1.673, 0,0,0, 2.5,0.32,2.5
cube = Default, 0.7952,0.745,1.652, 0.7952,0.745,1.652, 4.87,0.9796,0.1611, 4.87,0.9796,0.1611, 0.7952,0.7447,1.673, 0.7952,0.7447,1.673, 0,0,0, 2.5,0.32,2.5
}

// Model call
Expand Down
3 changes: 1 addition & 2 deletions GameData/UniversalStorage2/Parts/Control/ACDSmall.cfg
Expand Up @@ -207,9 +207,8 @@ PART
minimum_drag = 0.2
DRAG_CUBE
{
Default, 0.1988,0.7448,0.8757, 0.1988,0.7448,0.8757, 1.217,0.9952,0.1299, 1.217,0.9952,0.1299, 0.1988,0.7442,0.8871, 0.1988,0.7442,0.8871, 0,0,0, 1.25,0.16,1.25
cube = Default, 0.1988,0.7448,0.8757, 0.1988,0.7448,0.8757, 1.217,0.9952,0.1299, 1.217,0.9952,0.1299, 0.1988,0.7442,0.8871, 0.1988,0.7442,0.8871, 0,0,0, 1.25,0.16,1.25
}

// Model call
MODEL
{
Expand Down
Expand Up @@ -75,7 +75,7 @@ PART

DRAG_CUBE
{
cube = Default, 0.5829,0.8344,0.2631, 0.5829,0.8872,0.3984, 0.2528,0.9224,0.3678, 0.2528,0.9225,0.3678, 0.335,0.845,0.4124, 0.335,0.8448,0.416, -0.02687,-0.02047,-1.49E-08, 0.439,0.8193,0.7224
cube = Default, 0.5829,0.8344,0.2631, 0.5829,0.8872,0.3984, 0.2528,0.9224,0.3678, 0.2528,0.9225,0.3678, 0.335,0.845,0.4124, 0.335,0.8448,0.416, -0.02687,-0.02047,-1.49E-08, 0.439,0.8193,0.7224
}

// Model call
Expand Down
Expand Up @@ -308,13 +308,14 @@ PART
MODULE
{
name = USSolarSwitch
//SwitchID = 0
SwitchID = 0
secondaryTransformName = sunCatcher
solarMeshTransformName = Solar
resourceName = ElectricCharge
chargeRate = 1.4
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 300
AddedPanelMass = 0.010;0
DebugMode = false
}

Expand Down
Expand Up @@ -256,6 +256,7 @@ PART
chargeRate = 4;4
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 900;900
AddedPanelMass = 0.010;0.020;0
DebugMode = false
}
/-
Expand Down
Expand Up @@ -288,6 +288,7 @@ PART
chargeRate = 1;2;3;4
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 225;450;675;900
AddedPanelMass = 0.010;0.020;0.030;0.040;0
DebugMode = false
}
/-
Expand Down
Expand Up @@ -233,8 +233,9 @@ PART
solarMeshTransformName = Solar
resourceName = ElectricCharge
chargeRate = 4;4
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
//toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 900;900
AddedPanelMass = 0.010;0.020;0.030;0.040;0
DebugMode = false
}
/-
Expand Down
Expand Up @@ -259,6 +259,7 @@ PART
chargeRate = 7
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 1800
AddedPanelMass = 0.010;0
DebugMode = false
}

Expand Down
Expand Up @@ -443,8 +443,10 @@ PART
chargeRate = 1;2;3;4;0
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 225;450;675;900;0
AddedPanelMass = 0.010;0.020;0.030;0.040;0
DebugMode = false
}


/-
}
Expand Down
Expand Up @@ -363,6 +363,7 @@ PART
chargeRate = 1;2;3;4;0
toggleSolarPanelEventGUIName = #autoLOC_US_ToggleSolarPanel
AddedCost = 188;376;564;752;0
AddedPanelMass = 0.010;0.020;0.030;0.040;0
DebugMode = false
}

Expand Down
2 changes: 1 addition & 1 deletion GameData/UniversalStorage2/UniversalStorage2.version
Expand Up @@ -7,7 +7,7 @@
"MAJOR": 4,
"MINOR": 0,
"PATCH": 0,
"BUILD": 5
"BUILD": 6
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
6 changes: 3 additions & 3 deletions USSourceDev/UniversalStorage/AssemblyVersion.cs
Expand Up @@ -10,6 +10,6 @@

using System.Reflection;

[assembly: AssemblyVersion("4.0.0.5")]
[assembly: AssemblyFileVersion("4.0.0.5")]
[assembly: AssemblyInformationalVersion("v4.0.0.5")]
[assembly: AssemblyVersion("4.0.0.6")]
[assembly: AssemblyFileVersion("4.0.0.6")]
[assembly: AssemblyInformationalVersion("v4.0.0.6")]
26 changes: 21 additions & 5 deletions USSourceDev/UniversalStorage/SwitchModules/USCostSwitch.cs
Expand Up @@ -26,6 +26,7 @@ public class USCostSwitch : USBaseSwitch, IPartCostModifier

private string _localizedDryCostString = "Part Cost";

private USSolarSwitch solarSwitchModule = null;
public override void OnAwake()
{
base.OnAwake();
Expand All @@ -35,7 +36,7 @@ public override void OnAwake()
if (onFuelRequestCost != null)
onFuelRequestCost.Add(onFuelSwitchRequest);

_localizedDryCostString = Localizer.Format(DisplayCostName);
//_localizedDryCostString = Localizer.Format(DisplayCostName);

Fields["AddedCostValue"].guiName = _localizedDryCostString;
}
Expand All @@ -48,7 +49,7 @@ public override void OnStart(StartState state)
return;

_partCostModifiers = part.FindModulesImplementing<IPartCostModifier>();

solarSwitchModule = part.FindModuleImplementing<USSolarSwitch>();
for (int i = _partCostModifiers.Count - 1; i >= 0; i--)
{
if (_partCostModifiers[i] == (IPartCostModifier)this)
Expand Down Expand Up @@ -116,7 +117,10 @@ private void onFuelSwitchRequest(int index, Part p, USFuelSwitch fuel)
if (_Costs.Length > CurrentSelection)
cost = (float)_Costs[CurrentSelection];

fuel.setMeshCost(cost);
fuel.setMeshCost(cost);

AddedCostValue = AddedCostValue = part.partInfo.cost + cost;
UpdateSolarCost();
}

private float UpdateCost()
Expand All @@ -132,18 +136,30 @@ private float UpdateCost()
{
otherCosts += _partCostModifiers[i].GetModuleCost(0, ModifierStagingSituation.CURRENT);
}


USdebugMessages.USStaticLog("USCostSwitch.GetModuleMass, CurrentSelection: " + CurrentSelection);
AddedCostValue = part.partInfo.cost + cost + otherCosts;


return cost;
}
private void UpdateSolarCost()
{
if (solarSwitchModule!=null)
{
AddedCostValue += solarSwitchModule.GetModuleCost(0, ModifierStagingSituation.CURRENT);
USdebugMessages.USStaticLog("USCostSwitch.GetModuleMass, solarSwitchModuleCost: " + solarSwitchModule.GetModuleCost(0, ModifierStagingSituation.CURRENT));
}
}

public float GetModuleCost(float defaultCost, ModifierStagingSituation sit)
{
if (!_updateCost)
return 0;

return UpdateCost();
var m = UpdateCost();
UpdateSolarCost();
return m;
}

public ModifierChangeWhen GetModuleCostChangeWhen()
Expand Down

0 comments on commit b604afc

Please sign in to comment.