Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
allista committed Jul 30, 2020
2 parents 6f61aaf + 52bbcf5 commit 111e5eb
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Assets/Tests/
*~
*.swp
*.blend1
*.blend1.meta
*.log
*.mdb
*.pyc
*.bak
*.pdb
*.blend1.meta

vessel_positioning.txt
Source/Hangar.userprefs
Assembly-CSharp.dump
Expand Down
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ _You may keep the Hangar.user (if you have one) and config.xml files to preserve

***

* **v3.6.1**
* **v3.6.2**
* Improved Procedural Adapter behaviour in Editor
* Fixed lag in Editor when opening PAW of hangars in symmetry group

* v3.6.1
* **Squad cargo bays can store a vessel in flight now**
* Asteroid Hatch features new UI from Configurable Containers
* **Fixed ship loading into hangars in editor**
Expand Down
2 changes: 1 addition & 1 deletion GameData/Hangar/Hangar.version
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"MAJOR":3,
"MINOR":6,
"PATCH":1,
"PATCH":2,
"BUILD":0
},
"KSP_VERSION_MIN":
Expand Down
42 changes: 24 additions & 18 deletions Source/AuxModules/ProceduralAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System;
using UnityEngine;
using AT_Utils;
using JetBrains.Annotations;

namespace AtHangar
{
Expand All @@ -18,18 +19,21 @@ public class HangarProceduralAdapter : AnisotropicResizableBase
[UI_FloatEdit(scene=UI_Scene.Editor, minValue=0.5f, maxValue=10, incrementLarge=1.0f, incrementSmall=0.1f, incrementSlide=0.001f, sigFigs = 4)]
public float topSize = 1.0f;

[UsedImplicitly] private FloatFieldWatcher topSizeWatcher;

[KSPField(isPersistant=true, guiActiveEditor=true, guiName="Bottom Size", guiFormat="S4")]
[UI_FloatEdit(scene=UI_Scene.Editor, minValue=0.5f, maxValue=10, incrementLarge=1.0f, incrementSmall=0.1f, incrementSlide=0.001f, sigFigs = 4)]
public float bottomSize = 1.0f;

[UsedImplicitly] private FloatFieldWatcher bottomSizeWatcher;

void update_and_break_struts()
{
UpdateMesh();
part.BreakConnectedCompoundParts();
}
protected override void on_aspect_changed(object value) => update_and_break_struts();
protected virtual void on_top_size_changed(object value) => update_and_break_struts();
protected virtual void on_bottom_size_changed(object value) => update_and_break_struts();

protected override void on_aspect_changed() => update_and_break_struts();

//module config
[KSPField] public float AreaCost = 9f;
Expand Down Expand Up @@ -117,19 +121,18 @@ public override void OnStart(StartState state)
setup_field(Fields["topSize"], minSize, maxSize, sizeStepLarge, sizeStepSmall);
setup_field(Fields["bottomSize"], minSize, maxSize, sizeStepLarge, sizeStepSmall);
setup_field(Fields["aspect"], minAspect, maxAspect, aspectStepLarge, aspectStepSmall);
Fields["topSize"].OnValueModified += on_top_size_changed;
Fields["bottomSize"].OnValueModified += on_bottom_size_changed;
topSizeWatcher = new FloatFieldWatcher(Fields[nameof(topSize)])
{
epsilon = 1e-4f, onValueChanged = update_and_break_struts
};
bottomSizeWatcher = new FloatFieldWatcher(Fields[nameof(bottomSize)])
{
epsilon = 1e-4f, onValueChanged = update_and_break_struts
};
}
StartCoroutine(CallbackUtil.WaitUntil(() => passage == null || passage.Ready, UpdateMesh));
}

protected override void OnDestroy()
{
Fields[nameof(topSize)].OnValueModified -= on_top_size_changed;
Fields[nameof(bottomSize)].OnValueModified -= on_bottom_size_changed;
base.OnDestroy();
}

void get_part_components()
{
passage = part.Modules.GetModule<HangarPassage>();
Expand All @@ -138,11 +141,11 @@ void get_part_components()
//get transforms and meshes
Transform bodyT = part.FindModelTransform(BodyName);
if(bodyT == null)
this.Log("'{}' transform does not exists in the {1}",
this.Log("'{}' transform does not exists in the {}",
BodyName, part.name);
Transform colliderT = part.FindModelTransform(ColliderName);
if(colliderT == null)
this.Log("'{}' transform does not exists in the {1}",
this.Log("'{}' transform does not exists in the {}",
ColliderName, part.name);
//The mesh method unshares any shared meshes
MeshFilter body_mesh_filter = bodyT.GetComponent<MeshFilter>();
Expand Down Expand Up @@ -173,13 +176,15 @@ void update_body()
sides += sides%2; // make sides even
//update meshes
var collider_mesh = new Mesh();
body_collider.enabled = false;
body.current.WriteTo(sides, body_mesh);
body.current.WriteTo(sides/2, collider_mesh, for_collider: true);
Destroy(body_collider.sharedMesh);
body_collider.sharedMesh = collider_mesh;
body_collider.enabled = false;
body_collider.enabled = true;
part.ResetModelSkinnedMeshRenderersCache();
part.ResetModelMeshRenderersCache();
part.ResetModelRenderersCache();
//calculate mass and cost changes
mass = body.current.Area*AreaDensity;
cost = body.current.Area*AreaCost;
Expand Down Expand Up @@ -260,11 +265,12 @@ public void UpdateMesh()
var data = new BaseEventDetails(BaseEventDetails.Sender.AUTO);
data.Set<string>("volName", "Tankage");
data.Set<double>("newTotalVolume", body.current.V*UsableVolumeRatio);
part.SendEvent("OnPartVolumeChanged", data);
part.SendEvent("OnPartVolumeChanged", data, 0);
old_size = size;
old_aspect = aspect;
Utils.UpdateEditorGUI();
StartCoroutine(CallbackUtil.DelayedCallback(1, UpdateDragCube));
if(HighLogic.LoadedSceneIsFlight)
StartCoroutine(CallbackUtil.DelayedCallback(1, UpdateDragCube));
part.UpdatePartMenu(true);
just_loaded = false;
}
}
Expand Down
13 changes: 2 additions & 11 deletions Source/HangarStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,12 @@ public override void Setup(bool reset = false)
set_part_params(reset);
}

virtual protected void on_set_part_params()
{
var el = EditorLogic.fetch;
if(el != null) GameEvents.onEditorShipModified.Fire(el.ship);
// else if(part.vessel != null) GameEvents.onVesselWasModified.Fire(part.vessel);
}

virtual protected void set_part_params(bool reset = false)
protected virtual void set_part_params(bool reset = false)
{
_stored_vessels = VesselsCount.ToString();
_stored_mass = Utils.formatMass(VesselsMass);
_stored_cost = VesselsCost.ToString();
_stored_cost = VesselsCost.ToString("F0");
_used_volume = Volume > 0 ? UsedVolumeFrac.ToString("P1") : "N/A";
on_set_part_params();
part.UpdatePartMenu();
}

public override void OnAwake()
Expand Down
2 changes: 1 addition & 1 deletion Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if NIGHTBUILD
[assembly: AssemblyVersion("3.6.*")]
#else
[assembly: AssemblyVersion("3.6.1")]
[assembly: AssemblyVersion("3.6.2")]
#endif
[assembly: KSPAssembly("Hangar", 3, 6)]

Expand Down

0 comments on commit 111e5eb

Please sign in to comment.