- added code to avoid vessel disintegration when deploying balloon at high velocity and also when the physics origin is teleported (happens every 6km, seems like a KSP system to avoid imprecision with big floating point numbers)
- added script to automatically build the zip package in release mode
This commit is contained in:
parent
a49fb7b123
commit
1f3f7ff1a2
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
/Plugin/*.user
|
/Plugin/*.user
|
||||||
/Plugin/obj
|
/Plugin/obj
|
||||||
/Plugin/bin
|
/Plugin/bin
|
||||||
|
/Aerostats.zip
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
PART
|
PART
|
||||||
{
|
{
|
||||||
name = balloon
|
name = heliumBalloon
|
||||||
module = Part
|
module = Part
|
||||||
author = Youen
|
author = Youen
|
||||||
mesh = model.mu
|
mesh = model.mu
|
@ -52,6 +52,9 @@
|
|||||||
<Compile Include="Util.cs" />
|
<Compile Include="Util.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>if $(ConfigurationName)==Release ("$(ProjectDir)..\build\build-package.bat")</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
@ -82,6 +82,8 @@ namespace Aerostats
|
|||||||
|
|
||||||
private bool Staged;
|
private bool Staged;
|
||||||
|
|
||||||
|
private bool Destroyed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gas quantity currently inside the balloon
|
/// Gas quantity currently inside the balloon
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -96,6 +98,8 @@ namespace Aerostats
|
|||||||
private GameObject Balloon;
|
private GameObject Balloon;
|
||||||
private LineRenderer Spring;
|
private LineRenderer Spring;
|
||||||
|
|
||||||
|
private Vector3 EstimatedNextFramePosition;
|
||||||
|
|
||||||
public override void OnStart(PartModule.StartState state)
|
public override void OnStart(PartModule.StartState state)
|
||||||
{
|
{
|
||||||
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; }
|
if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; }
|
||||||
@ -113,6 +117,7 @@ namespace Aerostats
|
|||||||
Balloon.transform.position = part.Rigidbody.position + part.Rigidbody.transform.up;
|
Balloon.transform.position = part.Rigidbody.position + part.Rigidbody.transform.up;
|
||||||
Balloon.AddComponent<Rigidbody>();
|
Balloon.AddComponent<Rigidbody>();
|
||||||
Balloon.rigidbody.mass = BalloonEmptyMass;
|
Balloon.rigidbody.mass = BalloonEmptyMass;
|
||||||
|
Balloon.rigidbody.velocity = part.rigidbody.velocity; // start with the same velocity or everything explodes when deploying from a moving vessel
|
||||||
|
|
||||||
Balloon.rigidbody.angularDrag = 10.0f;
|
Balloon.rigidbody.angularDrag = 10.0f;
|
||||||
|
|
||||||
@ -126,6 +131,8 @@ namespace Aerostats
|
|||||||
Spring.SetVertexCount(2);
|
Spring.SetVertexCount(2);
|
||||||
|
|
||||||
part.OnJustAboutToBeDestroyed += OnPartDestroyed;
|
part.OnJustAboutToBeDestroyed += OnPartDestroyed;
|
||||||
|
|
||||||
|
EstimatedNextFramePosition = part.Rigidbody.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPartDestroyed()
|
private void OnPartDestroyed()
|
||||||
@ -134,10 +141,14 @@ namespace Aerostats
|
|||||||
Balloon = null;
|
Balloon = null;
|
||||||
Spring = null;
|
Spring = null;
|
||||||
part.OnJustAboutToBeDestroyed -= OnPartDestroyed;
|
part.OnJustAboutToBeDestroyed -= OnPartDestroyed;
|
||||||
|
Destroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
if (Destroyed)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && vessel.isActiveVessel && (part.inverseStage == Staging.CurrentStage - 1 || Staging.CurrentStage == 0))
|
if (!Staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && vessel.isActiveVessel && (part.inverseStage == Staging.CurrentStage - 1 || Staging.CurrentStage == 0))
|
||||||
{
|
{
|
||||||
Staged = true;
|
Staged = true;
|
||||||
@ -146,6 +157,16 @@ namespace Aerostats
|
|||||||
|
|
||||||
if (Staged)
|
if (Staged)
|
||||||
{
|
{
|
||||||
|
// detect Krakensbane teleportation, and fix up the balloon position (otherwise it results in instant ship disintegration due to extreme forces on the spring)
|
||||||
|
if((part.Rigidbody.position - EstimatedNextFramePosition).magnitude > 1000.0f)
|
||||||
|
{
|
||||||
|
ScreenMessages.PostScreenMessage("Krakensbane teleportation detected! (dist=" + (part.Rigidbody.position - EstimatedNextFramePosition).magnitude+")");
|
||||||
|
var offset = part.rigidbody.position - EstimatedNextFramePosition;
|
||||||
|
Balloon.rigidbody.position += offset;
|
||||||
|
Balloon.transform.position = Balloon.rigidbody.position;
|
||||||
|
}
|
||||||
|
EstimatedNextFramePosition = part.rigidbody.position + part.rigidbody.velocity * Time.fixedDeltaTime;
|
||||||
|
|
||||||
float externalTemperature = (float)FlightGlobals.getExternalTemperature();
|
float externalTemperature = (float)FlightGlobals.getExternalTemperature();
|
||||||
float balloonInternalTemperature = externalTemperature;
|
float balloonInternalTemperature = externalTemperature;
|
||||||
float externalPressure = Math.Max((float)FlightGlobals.getStaticPressure() * 1000.0f, 0.00001f);
|
float externalPressure = Math.Max((float)FlightGlobals.getStaticPressure() * 1000.0f, 0.00001f);
|
||||||
@ -214,7 +235,7 @@ namespace Aerostats
|
|||||||
if(springLength > restLength)
|
if(springLength > restLength)
|
||||||
{
|
{
|
||||||
float tensingLength = springLength - restLength;
|
float tensingLength = springLength - restLength;
|
||||||
springForceMag = tensingLength * SpringHardness;
|
springForceMag = Math.Min(tensingLength * SpringHardness, 500000.0f);
|
||||||
var springForce = springVec * (springForceMag / springLength * 0.001f);
|
var springForce = springVec * (springForceMag / springLength * 0.001f);
|
||||||
part.rigidbody.AddForce(springForce, ForceMode.Force);
|
part.rigidbody.AddForce(springForce, ForceMode.Force);
|
||||||
Balloon.rigidbody.AddForceAtPosition(-springForce, balloonAttachPoint, ForceMode.Force);
|
Balloon.rigidbody.AddForceAtPosition(-springForce, balloonAttachPoint, ForceMode.Force);
|
||||||
|
56
build/7z-License.txt
Normal file
56
build/7z-License.txt
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
7-Zip
|
||||||
|
~~~~~
|
||||||
|
License for use and distribution
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
7-Zip Copyright (C) 1999-2010 Igor Pavlov.
|
||||||
|
|
||||||
|
Licenses for files are:
|
||||||
|
|
||||||
|
1) 7z.dll: GNU LGPL + unRAR restriction
|
||||||
|
2) All other files: GNU LGPL
|
||||||
|
|
||||||
|
The GNU LGPL + unRAR restriction means that you must follow both
|
||||||
|
GNU LGPL rules and unRAR restriction rules.
|
||||||
|
|
||||||
|
|
||||||
|
Note:
|
||||||
|
You can use 7-Zip on any computer, including a computer in a commercial
|
||||||
|
organization. You don't need to register or pay for 7-Zip.
|
||||||
|
|
||||||
|
|
||||||
|
GNU LGPL information
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You can receive a copy of the GNU Lesser General Public License from
|
||||||
|
http://www.gnu.org/
|
||||||
|
|
||||||
|
|
||||||
|
unRAR restriction
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The decompression engine for RAR archives was developed using source
|
||||||
|
code of unRAR program.
|
||||||
|
All copyrights to original unRAR code are owned by Alexander Roshal.
|
||||||
|
|
||||||
|
The license for original unRAR code has the following restriction:
|
||||||
|
|
||||||
|
The unRAR sources cannot be used to re-create the RAR compression algorithm,
|
||||||
|
which is proprietary. Distribution of modified unRAR sources in separate form
|
||||||
|
or as a part of other software is permitted, provided that it is clearly
|
||||||
|
stated in the documentation and source comments that the code may
|
||||||
|
not be used to develop a RAR (WinRAR) compatible archiver.
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
Igor Pavlov
|
BIN
build/7z.dll
Normal file
BIN
build/7z.dll
Normal file
Binary file not shown.
BIN
build/7z.exe
Normal file
BIN
build/7z.exe
Normal file
Binary file not shown.
47
build/build-package.bat
Normal file
47
build/build-package.bat
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
rem make sure the initial working directory is the one containing the current script
|
||||||
|
SET scriptPath=%~dp0
|
||||||
|
SET initialWD=%CD%
|
||||||
|
cd %scriptPath%
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
rd /s /q package
|
||||||
|
mkdir package
|
||||||
|
cd package
|
||||||
|
mkdir GameData
|
||||||
|
cd GameData
|
||||||
|
|
||||||
|
mkdir Aerostats
|
||||||
|
cd Aerostats
|
||||||
|
xcopy /y ..\..\..\License.txt .
|
||||||
|
xcopy /y ..\..\..\resources.cfg .
|
||||||
|
xcopy /y ..\..\..\TweakScale.cfg .
|
||||||
|
|
||||||
|
mkdir Plugin
|
||||||
|
xcopy /y ..\..\..\Plugin\bin\Release\Aerostats.dll Plugin
|
||||||
|
|
||||||
|
mkdir Parts
|
||||||
|
cd Parts
|
||||||
|
|
||||||
|
mkdir HeliumBalloon
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumBalloon\heliumBalloon.cfg HeliumBalloon
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumBalloon\model.mu HeliumBalloon
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumBalloon\model000.dds HeliumBalloon
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumBalloon\model001.dds HeliumBalloon
|
||||||
|
|
||||||
|
mkdir HeliumTankRadial
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumTankRadial\heliumTankRadial.cfg HeliumTankRadial
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumTankRadial\model.mu HeliumTankRadial
|
||||||
|
xcopy /y ..\..\..\..\Parts\HeliumTankRadial\ksp_r_xenonTank_diff.dds HeliumTankRadial
|
||||||
|
|
||||||
|
cd "%scriptPath%..\package"
|
||||||
|
IF EXIST ..\Aerostats.zip del ..\Aerostats.zip
|
||||||
|
"%scriptPath%7z.exe" a ..\Aerostats.zip GameData
|
||||||
|
cd "%scriptPath%.."
|
||||||
|
rd /s /q package
|
||||||
|
|
||||||
|
cd %initialWD%
|
||||||
|
|
||||||
|
pause
|
Loading…
Reference in New Issue
Block a user