Skip to content

Commit

Permalink
Merge pull request #9 from cvusmo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
blacksheepcosmo authored Aug 11, 2023
2 parents c8f6179 + 653624f commit 8ff8aa9
Show file tree
Hide file tree
Showing 17 changed files with 622 additions and 199 deletions.
11 changes: 6 additions & 5 deletions FFT/swinfo.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"mod_id": "FFT",
"mod_id": "com.github.cvusmo.fancyfueltanks",
"author": "cvusmo",
"name": "FFT",
"name": "Fancy Fuel Tanks",
"description": "Fancy Fuel Tanks",
"source": "https://github.com/cvusmo/FFT",
"version": "0.1.3",
"version_check": "https://raw.githubusercontent.com/cvusmo/FFT/dev/FFT/swinfo.json",
"version": "0.1.4",
"spec": "1.3",
"version_check": "https://raw.githubusercontent.com/cvusmo/FFT/Master/FFT/swinfo.json",
"dependencies": [
{
"id": "com.github.x606.spacewarp",
Expand All @@ -19,4 +20,4 @@
"min": "0.1.0",
"max": "*"
}
}
}
21 changes: 12 additions & 9 deletions FFTProject/FFT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<AssemblyName>FFT</AssemblyName>
<AssemblyName>com.github.cvusmo.fancyfueltanks</AssemblyName>
<Product>FFT</Product>
<Description>Fancy Fuel Tanks</Description>
<Version>0.1.3</Version>
<Version>0.1.4</Version>
<RestoreAdditionalProjectSources>
https://nuget.spacewarp.org/v3/index.json
</RestoreAdditionalProjectSources>
Expand All @@ -18,23 +18,26 @@
<RepositoryUrl></RepositoryUrl>
<PackageTags>KSP2-mods</PackageTags>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.0" PrivateAssets="all" />
<PackageReference Include="BepInEx.Analyzers" Version="1.0.8" PrivateAssets="all" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
<PackageReference Include="HarmonyX" Version="2.10.1" />
<PackageReference Include="SpaceWarp" Version="1.1.1" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33" IncludeAssets="compile" />
<PackageReference Include="SpaceWarp" Version="1.4.0" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.33.1" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program 2\KSP2_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Publicize>true</Publicize>
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program 2\KSP2_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Publicize>true</Publicize>
<Private>false</Private>
</Reference>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="rm -rf &quot;$(ProjectDir)..\$(ConfigurationName)\&quot;&#xA;echo d | xcopy /y /s &quot;$(ProjectDir)..\$(ModId)\&quot; &quot;$(ProjectDir)..\$(ConfigurationName)\BepInEx\plugins\$(ModId)\&quot;&#xA;echo f | xcopy /y &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\$(ConfigurationName)\BepInEx\plugins\$(ModId)\$(ModId).dll&quot;&#xA;if $(ConfigurationName) == Debug echo f | xcopy /y &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(ProjectDir)..\$(ConfigurationName)\BepInEx\plugins\$(ModId)\$(ModId).pdb&quot;&#xA;xcopy /y &quot;$(ProjectDir)..\LICENSE&quot; &quot;$(ProjectDir)..\$(ConfigurationName)\BepInEx\plugins\$(ModId)\&quot;&#xA;echo f | xcopy /y &quot;$(ProjectDir)..\README.md&quot; &quot;$(ProjectDir)..\$(ConfigurationName)\BepInEx\plugins\$(ModId)\README.txt&quot;" />
</Target>
</Project>
</Project>
25 changes: 25 additions & 0 deletions FFTProject/FFT.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33829.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FFT", "FFT.csproj", "{A06C1571-D0D1-4873-AC96-D55679AB50F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A06C1571-D0D1-4873-AC96-D55679AB50F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A06C1571-D0D1-4873-AC96-D55679AB50F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A06C1571-D0D1-4873-AC96-D55679AB50F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A06C1571-D0D1-4873-AC96-D55679AB50F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EFA788CF-0DC4-478A-B919-68F58032113A}
EndGlobalSection
EndGlobal
59 changes: 36 additions & 23 deletions FFTProject/FFTPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
using BepInEx.Logging;
using FFT.Modules;
using KSP.Game;
using KSP.Messages.PropertyWatchers;
using KSP.Sim.impl;
using SpaceWarp;
using SpaceWarp.API.Mods;
using UnityEngine;

namespace FFT
{
Expand All @@ -18,22 +15,21 @@ public class FFTPlugin : BaseSpaceWarpPlugin
public const string ModName = MyPluginInfo.PLUGIN_NAME;
public const string ModVer = MyPluginInfo.PLUGIN_VERSION;

public GameInstance _gameInstance;
public VesselComponent _vesselComponent;
public IsActiveVessel _isActiveVessel;
public GameInstance gameInstance;
public GameState? _state;
public FuelTankDefinitions _fuelTankDefinitions;
public Data_FuelTanks _dataFuelTanks;
public FuelTankDefinitions fuelTankDefinitions;
public Data_FuelTanks dataFuelTanks;
public VentValveDefinitions ventValveDefinitions;
public Data_ValveParts dataValveParts;
public Module_TriggerVFX Module_TriggerVFX { get; private set; }
public Module_VentValve Module_VentValve { get; private set; }
public static FFTPlugin Instance { get; set; }
public new static ManualLogSource Logger { get; set; }
public static string Path { get; private set; }

public override void OnPreInitialized()
{
FFTPlugin.Path = this.PluginFolderPath;
}

public override void OnInitialized()
{
base.OnInitialized();
Expand All @@ -42,35 +38,52 @@ public override void OnInitialized()
Logger = base.Logger;
Logger.LogInfo("Loaded");

_gameInstance = GameManager.Instance.Game;
_isActiveVessel = new IsActiveVessel();
_vesselComponent = new VesselComponent();
_fuelTankDefinitions = new FuelTankDefinitions();
gameInstance = GameManager.Instance.Game;
fuelTankDefinitions = new FuelTankDefinitions();
dataFuelTanks = new Data_FuelTanks();
ventValveDefinitions = new VentValveDefinitions();
dataValveParts = new Data_ValveParts();
}

public void Update()
{
_state = BaseSpaceWarpPlugin.Game?.GlobalGameState?.GetState();

if (_state == GameState.Launchpad || _state == GameState.FlightView || _state == GameState.Runway)
if (_state == GameState.FlightView)
{
if (_fuelTankDefinitions == null)
if (fuelTankDefinitions == null)
{
_fuelTankDefinitions = FindObjectOfType<FuelTankDefinitions>();
return; // Exit if FuelTankDefinitions is still not available
} else if (_fuelTankDefinitions != null && _dataFuelTanks != null)
fuelTankDefinitions = FindObjectOfType<FuelTankDefinitions>();
}
if (ventValveDefinitions == null)
{
_fuelTankDefinitions.PopulateFuelTanks(_dataFuelTanks);
ventValveDefinitions = FindObjectOfType<VentValveDefinitions>();
}

if (fuelTankDefinitions != null && dataFuelTanks != null)
{
fuelTankDefinitions.PopulateFuelTanks(dataFuelTanks);
}

if (ventValveDefinitions != null && dataValveParts != null)
{
ventValveDefinitions.PopulateVentValve(dataValveParts);
}

foreach (var module in FindObjectsOfType<Module_VentValve>())
{
module.Activate();
}
foreach (var module in FindObjectsOfType<Module_TriggerVFX>())
{
module.Activate();
}
}
}

public GameState? GetGameState()
{
Logger.LogInfo("_state" + _state);
return _state;
}

public override void OnPostInitialized() => base.OnPostInitialized();
}
}
38 changes: 38 additions & 0 deletions FFTProject/Modules/Data_FuelTanks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using UnityEngine;

namespace FFT.Modules
{
public class Data_FuelTanks : MonoBehaviour
{
public Dictionary<string, GameObject> fuelTankDict;

public void Awake()
{
fuelTankDict = new Dictionary<string, GameObject>();

fuelTankDict.Add("CV401", CV401);
fuelTankDict.Add("CV411", CV411);
fuelTankDict.Add("CV421", CV421);
fuelTankDict.Add("SP701", SP701);
fuelTankDict.Add("SR812", SR812);
fuelTankDict.Add("SR812A", SR812A);
fuelTankDict.Add("SR813", SR813);
}

[SerializeField]
public GameObject CV401;
[SerializeField]
public GameObject CV411;
[SerializeField]
public GameObject CV421;
[SerializeField]
public GameObject SP701;
[SerializeField]
public GameObject SR812;
[SerializeField]
public GameObject SR812A;
[SerializeField]
public GameObject SR813;

}
}
23 changes: 23 additions & 0 deletions FFTProject/Modules/Data_ValveParts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using KSP.Sim;
using KSP.Sim.Definitions;
using UnityEngine;

namespace FFT.Modules
{
public class Data_ValveParts : MonoBehaviour
{
public Dictionary<string, GameObject> ventValveDict;
public void Awake()
{
ventValveDict = new Dictionary<string, GameObject>();

ventValveDict.Add("RF1", RF1);
ventValveDict.Add("RF2", RF2);
}

[SerializeField]
public GameObject RF1;
[SerializeField]
public GameObject RF2;
}
}
23 changes: 23 additions & 0 deletions FFTProject/Modules/Data_VentValve.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using FFT.Modules;
using KSP.Sim;
using KSP.Sim.Definitions;
using System;
using UnityEngine;

namespace FFT.Modules
{
[Serializable]
public class Data_VentValve : ModuleData
{
public override Type ModuleType => typeof(Module_VentValve);

[KSPState]
public AnimationCurve VFXASLCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1000, 0));
[KSPState]
public AnimationCurve VFXAGLCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1000, 0));
[KSPState]
public AnimationCurve VFXVerticalSpeedCurve;
[KSPState]
public AnimationCurve VFXHorizontalSpeedCurve;
}
}
33 changes: 0 additions & 33 deletions FFTProject/Modules/Definitions/Data_FuelTanks.cs

This file was deleted.

36 changes: 0 additions & 36 deletions FFTProject/Modules/Definitions/FuelTankDefinitions.cs

This file was deleted.

Loading

0 comments on commit 8ff8aa9

Please sign in to comment.