Skip to content

Commit

Permalink
Merged development branch
Browse files Browse the repository at this point in the history
  • Loading branch information
allista committed Apr 1, 2022
2 parents 118bcdd + 8fd3882 commit 82c8bfc
Show file tree
Hide file tree
Showing 11 changed files with 420 additions and 374 deletions.
646 changes: 342 additions & 304 deletions ChangeLog.md

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions Containers/AssemblySpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class AssemblySpace : SerializableFiledsPartModule, IAssemblySpace, IAnim
[KSPField(isPersistant = true)] public VesselKit Kit = new VesselKit();

[KSPField, SerializeField] public SpawnSpaceManager SpawnManager = new SpawnSpaceManager();
VesselSpawner vessel_spawner;
IAnimator animator;
private VesselSpawner vessel_spawner;
private IAnimator animator;
private ATMagneticDamper damper;
bool can_construct_in_situ;
private bool can_construct_in_situ;

public override void OnAwake()
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public override void OnLoad(ConfigNode node)
Kit.Host = this;
}

void spawn_space_keeper()
private void spawn_space_keeper()
{
if(animator != null && !SpawnManager.SpawnSpaceEmpty)
animator.Open();
Expand All @@ -70,7 +70,7 @@ void spawn_space_keeper()
#region IAssemblySpace
public string Name => Title;
public bool Empty => !Kit && SpawnManager.SpawnSpaceEmpty;
public bool Valid => isEnabled;
public bool Valid => isEnabled && SpawnManager.Valid;
public VesselKit GetKit(Guid id) => Kit.id == id ? Kit : null;
public List<VesselKit> GetKits() => new List<VesselKit> { Kit };

Expand Down Expand Up @@ -121,6 +121,8 @@ public void Close()
public bool Opened =>
animator == null || animator.GetAnimatorState() != AnimatorState.Closed;

public bool HasAnimator => animator != null;

public void SpawnKit() => StartCoroutine(spawn_kit());

public void SpawnEmptyContainer(string part_name) =>
Expand All @@ -146,7 +148,7 @@ IEnumerator<YieldInstruction> spawn_kit()
Utils.Message("Kit construction is already started");
yield break;
}
if(Opened)
if(HasAnimator && Opened)
{
Utils.Message("Need to close assembly space first");
Close();
Expand All @@ -168,7 +170,7 @@ IEnumerator<YieldInstruction> spawn_empty_container(string part_name)
Utils.Message("In progress...");
yield break;
}
if(Opened)
if(HasAnimator && Opened)
{
Utils.Message("Need to close assembly space first");
Close();
Expand Down Expand Up @@ -260,7 +262,7 @@ public bool CanConstruct(VesselKit vessel_kit) =>
&& SpawnManager != null
&& SpawnManager.MetricFits(vessel_kit.ShipMetric));

bool IConstructionSpace.Valid => isEnabled && can_construct_in_situ;
bool IConstructionSpace.Valid => this.Valid && can_construct_in_situ;
public bool ConstructionComplete => Kit && Kit.Complete;

public void Launch()
Expand Down
13 changes: 7 additions & 6 deletions GC.UI/GC.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<OutputType>Library</OutputType>
<RootNamespace>GC.UI</RootNamespace>
<AssemblyName>GC.UI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)/../../CSharp.warnings.xml" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -45,23 +46,23 @@
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>..\..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.dll</HintPath>
<HintPath>..\..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core">
<HintPath>..\..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.Core.dll</HintPath>
<HintPath>..\..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions GameData/GroundConstruction/GroundConstruction.version
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
{
"MAJOR":2,
"MINOR":7,
"PATCH":0,
"PATCH":1,
"BUILD":0
},
"KSP_VERSION_MIN":
{
"MAJOR":1,
"MINOR":11,
"PATCH":1
"MINOR":12,
"PATCH":3
},
"KSP_VERSION_MAX":
{
"MAJOR":1,
"MINOR":11,
"PATCH":1
"MINOR":12,
"PATCH":3
}
}
19 changes: 10 additions & 9 deletions GroundConstruction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<OutputType>Library</OutputType>
<RootNamespace>GroundConstruction</RootNamespace>
<AssemblyName>GroundConstruction</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)/../CSharp.warnings.xml" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -36,35 +37,35 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.Core.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
17 changes: 9 additions & 8 deletions OneTimeResourceConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<OutputType>Library</OutputType>
<RootNamespace>GroundConstruction</RootNamespace>
<AssemblyName>OneTimeResourceConverter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)/../CSharp.warnings.xml" />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
Expand Down Expand Up @@ -36,31 +37,31 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\System.Core.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\KSP-test\KSP_test_1.11.1\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\KSP-test\KSP_test_1.12.3\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#if NIGHTBUILD
[assembly: AssemblyVersion("2.7.*")]
#else
[assembly: AssemblyVersion("2.7.0")]
[assembly: AssemblyVersion("2.7.1")]
#endif
[assembly: KSPAssembly("GroundConstruction", 2, 7)]

Expand All @@ -44,8 +44,8 @@ public class ModInfo : KSP_AVC_Info
{
public ModInfo()
{
MinKSPVersion = new Version(1, 11, 1);
MaxKSPVersion = new Version(1, 11, 1);
MinKSPVersion = new Version(1, 12, 3);
MaxKSPVersion = new Version(1, 12, 3);

VersionURL = "https://raw.githubusercontent.com/allista/GroundConstruction/master/GameData/GroundConstruction/GroundConstruction.version";
UpgradeURL = "https://spacedock.info/mod/1123/Ground%20Construction";
Expand Down
29 changes: 11 additions & 18 deletions WorkshopModel/AssemblyWorkshop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public abstract class AssemblyWorkshop : VesselKitWorkshop<AssemblyKitInfo>, IKi
{
[KSPField]
public string KitParts = "DIYKit";
SortedList<string, string> kit_parts = new SortedList<string, string>();
private readonly SortedList<string, string> kit_parts = new SortedList<string, string>();

[KSPField(isPersistant = true)]
public string SelectedPart = string.Empty;
string kit_part => kit_parts[SelectedPart];

private string kit_part => kit_parts[SelectedPart];

[KSPField(isPersistant = true)]
public PersistentList<VesselKit> Kits = new PersistentList<VesselKit>();
Expand Down Expand Up @@ -71,13 +72,11 @@ protected override bool check_host(AssemblyKitInfo task) =>
protected virtual void process_construct(ShipConstruct construct)
{
var kit = new VesselKit(this, construct, false);
var selected_space_module = selected_space as PartModule;
if(selected_space_module != null)
if (selected_space is PartModule)
{
float ratio;
if(!selected_space.Empty)
Utils.Message("Selected assembly space is occupied");
else if(!selected_space.CheckKit(kit, kit_part, out ratio))
else if (!selected_space.CheckKit(kit, kit_part, out float ratio))
{
if(ratio > 0)
Utils.Message("Selected assembly space is too small");
Expand Down Expand Up @@ -136,8 +135,7 @@ IAssemblySpace find_assembly_space(VesselKit kit, IList<IAssemblySpace> spaces)
{
if(space.Valid)
{
float ratio;
if(space.CheckKit(kit, kit_part, out ratio))
if(space.CheckKit(kit, kit_part, out _))
return space;
}
}
Expand All @@ -152,8 +150,7 @@ IAssemblySpace find_best_assembly_space(VesselKit kit, IList<IAssemblySpace> spa
{
if(space.Valid)
{
float ratio;
if(space.CheckKit(kit, kit_part, out ratio))
if(space.CheckKit(kit, kit_part, out float ratio))
{
if(ratio > best_ratio)
{
Expand Down Expand Up @@ -298,21 +295,18 @@ protected virtual void assembly_spaces_pane()
else
selected_space = null;
}
var module = space as PartModule;
if(module != null)
if (space is PartModule module)
set_highlighted_part(module.part);
if(space.Empty)
{
var animated = space as IAnimatedSpace;
var producer = space as IContainerProducer;
if(producer != null)
if (space is IContainerProducer producer)
{
if(GUILayout.Button(new GUIContent("Create Empty Container",
"Create a new empty container of the selected type"),
Styles.active_button, GUILayout.ExpandWidth(false)))
producer.SpawnEmptyContainer(kit_part);
}
if(animated != null)
if (space is IAnimatedSpace animated && animated.HasAnimator)
{
var opened = animated.Opened;
if(Utils.ButtonSwitch("Close", "Open", opened, "",
Expand All @@ -325,8 +319,7 @@ protected virtual void assembly_spaces_pane()
}
else
{
var construction_space = space as IConstructionSpace;
if(construction_space != null && construction_space.Valid)
if (space is IConstructionSpace construction_space && construction_space.Valid)
GUILayout.Label(new GUIContent(Colors.Enabled.Tag("In-place Construction"),
"It is possible to construct this kit directly in the assembly space"),
Styles.rich_label, GUILayout.ExpandWidth(false));
Expand Down
1 change: 1 addition & 0 deletions WorkshopModel/IKitContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public interface IAnimatedSpace
void Open();
void Close();
bool Opened { get; }
bool HasAnimator { get; }
}

public interface IContainerProducer
Expand Down
13 changes: 0 additions & 13 deletions make-release.sh

This file was deleted.

22 changes: 22 additions & 0 deletions modconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
dll_path: GameData/GroundConstruction/Plugins/GroundConstruction.dll
archive_path: Releases
github_url: allista/GroundConstruction
spacedock_mod_id: 1123
game_data_path: GameData
additional_data_paths:
- '../AT_Utils/GameData'
- '../AT_Utils/ConfigurableContainers/GameData'
exclude_patterns:
- '*/@thumbs/*'
- '*/config.xml'
- '*.user'
- '*.orig'
- '*.mdb'
- '*.pdb'
- '*/System.*.dll'
- '*/Mono.*.dll'
- '*/Unity*.dll'
- 'GameData/000_AT_Utils/Plugins/AnimatedConverters.dll'
- 'GameData/000_AT_Utils/Plugins/SubmodelResizer.dll'
- 'GameData/ConfigurableContainers/Parts/*'
- 'GameData/000_AT_Utils/ResourceHack.cfg'

0 comments on commit 82c8bfc

Please sign in to comment.