From 1a4a6b551043c7960724686cdf593f4bd9dfc65f Mon Sep 17 00:00:00 2001 From: George Sedov Date: Wed, 14 Jun 2017 13:24:43 +0300 Subject: [PATCH] initial 2: the return of the initial --- .gitignore | 8 ++---- PhysicsCalmer.cs | 58 ++++++++++++++++++++++++++++++++++++++ PhysicsCalmer.csproj | 52 ++++++++++++++++++++++++++++++++++ PhysicsCalmer.sln | 22 +++++++++++++++ Properties/AssemblyInfo.cs | 38 +++++++++++++++++++++++++ README.md | 8 +++++- 6 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 PhysicsCalmer.cs create mode 100644 PhysicsCalmer.csproj create mode 100644 PhysicsCalmer.sln create mode 100644 Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore index e915029..aa2c54c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ - -/.vs +/.vs +/BUILD +/obj diff --git a/PhysicsCalmer.cs b/PhysicsCalmer.cs new file mode 100644 index 0000000..177c789 --- /dev/null +++ b/PhysicsCalmer.cs @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2017, George Sedov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ + +using UnityEngine; + +namespace PhysicsCalmer +{ + [KSPAddon (KSPAddon.Startup.Flight, false)] + public class PhysicsCalmer : MonoBehaviour + { + private bool crash; + private bool joints; + + public void Awake () { + crash = CheatOptions.NoCrashDamage; + joints = CheatOptions.UnbreakableJoints; + CheatOptions.NoCrashDamage = true; + CheatOptions.UnbreakableJoints = true; + + Debug.Log ("[Physics Calmer] Enabled cheat options"); + + StartCoroutine (ResetPhysics ()); + } + + private System.Collections.IEnumerator ResetPhysics () { + yield return new WaitForSeconds (5f); + + CheatOptions.NoCrashDamage = crash; + CheatOptions.UnbreakableJoints = joints; + + Debug.Log ("[Physics Calmer] Returned cheat options to the original state: NoCrashDamage=" + crash.ToString () + " UnbreakableJoints=" + joints.ToString ()); + } + } +} diff --git a/PhysicsCalmer.csproj b/PhysicsCalmer.csproj new file mode 100644 index 0000000..e4e7be4 --- /dev/null +++ b/PhysicsCalmer.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {96BA7914-A66E-4C19-98ED-4C88F4AB3221} + Library + Properties + PhysicsCalmer + PhysicsCalmer + v3.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + none + true + BUILD\ + + + prompt + 4 + + + + ..\Libs\Assembly-CSharp.dll + + + ..\Libs\Assembly-CSharp-firstpass.dll + + + + + ..\Libs\UnityEngine.dll + + + + + + + + \ No newline at end of file diff --git a/PhysicsCalmer.sln b/PhysicsCalmer.sln new file mode 100644 index 0000000..c92ef93 --- /dev/null +++ b/PhysicsCalmer.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsCalmer", "PhysicsCalmer.csproj", "{96BA7914-A66E-4C19-98ED-4C88F4AB3221}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96BA7914-A66E-4C19-98ED-4C88F4AB3221}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96BA7914-A66E-4C19-98ED-4C88F4AB3221}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96BA7914-A66E-4C19-98ED-4C88F4AB3221}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96BA7914-A66E-4C19-98ED-4C88F4AB3221}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c43cba4 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PhysicsCalmer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PhysicsCalmer")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("96ba7914-a66e-4c19-98ed-4c88f4ab3221")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: KSPAssembly("PhysicsCalmer", 1, 0)] \ No newline at end of file diff --git a/README.md b/README.md index e2e7ad2..e2606d7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # KSPPhysicsCalmer -Physics Calmer mod for KSP +Physics Calmer mod for KSP. This mod disables the crash damage and joints breaking for 5 seconds after the flight scene load. This should be enough for all the wobbling, caused by the drop of your craft, to calm. + +## Install +Just copy the dll file into your GameData folder. + +## Usage +Nothing is needed from you. You won't even notice it's there.