├── Source
└── DeployableEngines
│ ├── obj
│ └── Debug
│ │ ├── DeployableEngines.csproj.CopyComplete
│ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ ├── DeployableEngines.csproj.CoreCompileInputs.cache
│ │ ├── DeployableEngines.dll
│ │ ├── DeployableEngines.pdb
│ │ ├── DesignTimeResolveAssemblyReferences.cache
│ │ ├── DeployableEngines.csprojAssemblyReference.cache
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── DeployableEngines.csprojResolveAssemblyReference.cache
│ │ └── DeployableEngines.csproj.FileListAbsolute.txt
│ ├── DeployableEngines.suo
│ ├── DeployableEngines.csproj.user
│ ├── DeployableEngines.sln
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── ModuleMultiStateEngine.cs
│ ├── ModuleAdvancedLookAtConstraint.cs
│ ├── DeployableEngines.csproj
│ └── ModuleDeployableEngine.cs
├── .ksp_deploy_config.yml
├── GameData
└── DeployableEngines
│ ├── Plugins
│ └── DeployableEngines.dll
│ └── Versioning
│ └── DeployableEngines.version
├── .gitignore
├── .mod_data.yml
├── CKAN
└── DeployableEngines.netkan
├── changelog.txt
├── .github
└── workflows
│ ├── build.yml
│ └── deploy.yml
└── readme.txt
/Source/DeployableEngines/obj/Debug/DeployableEngines.csproj.CopyComplete:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | ea2ccb7b9200665a60dc3e721ea3cb7e1d72e8c4
2 |
--------------------------------------------------------------------------------
/.ksp_deploy_config.yml:
--------------------------------------------------------------------------------
1 | OAUTH_TOKEN_SSM_KEY: pkmc-bot-github-oauth-token
2 | GITHUB_USER_SSM_KEY: pkmc-bot-github-user
3 | GITHUB_USER_EMAIL_SSM_KEY: pkmc-bot-github-user-email
--------------------------------------------------------------------------------
/Source/DeployableEngines/DeployableEngines.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/DeployableEngines.suo
--------------------------------------------------------------------------------
/GameData/DeployableEngines/Plugins/DeployableEngines.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/GameData/DeployableEngines/Plugins/DeployableEngines.dll
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DeployableEngines.dll
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DeployableEngines.pdb
--------------------------------------------------------------------------------
/Source/DeployableEngines/DeployableEngines.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DesignTimeResolveAssemblyReferences.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DesignTimeResolveAssemblyReferences.cache
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DeployableEngines.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/HEAD/Source/DeployableEngines/obj/Debug/DeployableEngines.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | .idea/
3 | build/
4 | tmp/
5 | deploy/
6 | build_scripts/version.txt
7 | build_scripts/changelog.md
8 | Source/DeployableEngines/.vs/DeployableEngines/v15/Server/sqlite3/storage.ide-wal
9 | Source/DeployableEngines/.vs/DeployableEngines/v15/Server/sqlite3/storage.ide-shm
10 | Source/DeployableEngines/.vs/DeployableEngines/v15/Server/sqlite3/storage.ide
11 | Source/DeployableEngines/.vs/DeployableEngines/v15/Server/sqlite3/db.lock
12 | Source/DeployableEngines/.vs/DeployableEngines/v15/.suo
13 |
--------------------------------------------------------------------------------
/.mod_data.yml:
--------------------------------------------------------------------------------
1 | mod-name: DeployableEngines
2 | package:
3 | include-dependencies: true # Include dependencies in the package
4 | included-gamedata:
5 | - DeployableEngines
6 | included-support: # Include these root-level files in packages
7 | - readme.txt
8 | - changelog.txt
9 | deploy:
10 | SpaceDock:
11 | enabled: false # activate/deactivate this deployment script
12 | mod-id: 558 # The Spacedock mod ID for deployment
13 | CurseForge:
14 | enabled: false # activate/deactivate this deployment script
15 | mod-id: 220671 # The CurseForge mod ID for deployment
16 | GitHub:
17 | enabled: true # activate/deactivate this deployment script
18 |
--------------------------------------------------------------------------------
/GameData/DeployableEngines/Versioning/DeployableEngines.version:
--------------------------------------------------------------------------------
1 | {
2 | "NAME":"DeployableEngines",
3 | "URL":"https://raw.githubusercontent.com/post-kerbin-mining-corporation/DeployableEngines/master/GameData/DeployableEngines/Versioning/DeployableEngines.version",
4 | "DOWNLOAD":"https://github.com/post-kerbin-mining-corporation/DeployableEngines/releases",
5 | "VERSION":
6 | {
7 | "MAJOR":1,
8 | "MINOR":3,
9 | "PATCH":1,
10 | "BUILD":0
11 | },
12 | "KSP_VERSION":
13 | {
14 | "MAJOR":1,
15 | "MINOR":12,
16 | "PATCH":1
17 | },
18 | "KSP_VERSION_MIN":{
19 | "MAJOR":1,
20 | "MINOR":8,
21 | "PATCH":0
22 | },
23 | "KSP_VERSION_MAX":{
24 | "MAJOR":1,
25 | "MINOR":12,
26 | "PATCH":99
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/CKAN/DeployableEngines.netkan:
--------------------------------------------------------------------------------
1 | {
2 | "spec_version": "v1.4",
3 | "identifier": "DeployableEngines",
4 | "abstract": "A plugin to manage extending/retracting engine nozzles",
5 | "name": "Deployable Engines Plugin",
6 | "author": "Nertea (Chris Adderley)",
7 | "$kref": "#/ckan/github/post-kerbin-mining-corporation/DeployableEngines",
8 | "$vref": "#/ckan/ksp-avc",
9 | "license": "MIT",
10 | "resources": {
11 | "homepage": "https://github.com/post-kerbin-mining-corporation/DeployableEngines/wiki",
12 | "repository": "https://github.com/post-kerbin-mining-corporation/DeployableEngines"
13 | },
14 | "supports": [
15 | { "name": "KerbalAtomics" },
16 | { "name": "CryoEngines" }
17 | ],
18 | "install": [
19 | {
20 | "find": "DeployableEngines",
21 | "install_to": "GameData"
22 | }
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/DeployableEngines.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C# Express 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeployableEngines", "DeployableEngines.csproj", "{63037415-6C26-47C4-A8E5-4BE51E1CE838}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {63037415-6C26-47C4-A8E5-4BE51E1CE838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {63037415-6C26-47C4-A8E5-4BE51E1CE838}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {63037415-6C26-47C4-A8E5-4BE51E1CE838}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {63037415-6C26-47C4-A8E5-4BE51E1CE838}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 | v1.3.1
2 | ------
3 | - KSP 1.12
4 |
5 | v1.3.0
6 | ------
7 | - ModuleAdvancedLookAtConstraint now supports constraining uniquely on one axis
8 | - Fixed a visual incompatibility between ModuleDeployableEngine and Waterfall
9 |
10 | v1.2.3
11 | ------
12 | - KSP 1.11
13 |
14 | v1.2.2
15 | ------
16 | - KSP 1.10
17 |
18 | v1.2.1
19 | ------
20 | - KSP 1.9
21 |
22 | v1.2.0
23 | ------
24 | - KSP 1.8
25 | - Upgraded to .NET 4.5
26 | - Fixed a few logging issues
27 |
28 | v1.1.0
29 | ------
30 | - Added new ModuleAdvancedLookAtConstraint module
31 | -- Version of basic FXModuleLookConstraint with the addition of viewing vector setting
32 | -- Tries (mostly successfully) to ensure a constrained object's up vector (green transform in unity) matches the up vector of the target object, which resolves problems with almost vertical/vertical gimbal pistons
33 | -- Same syntax for configs as FXModuleLookConstraint
34 |
35 | v1.0.1
36 | ------
37 | - KSP 1.7.x
38 |
39 | v1.0.0
40 | ------
41 | - Standalone release, license change (MIT)
42 | - Version file now included
43 | - 1.6.x compatible
44 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DeployableEngines")]
9 | [assembly: AssemblyDescription("KSP Plugin for animating engines")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Chris Adderley")]
12 | [assembly: AssemblyProduct("DeployableEngines")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7c9c513b-7d14-426a-9b90-3181ec429d6c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.2.0.0")]
36 | [assembly: AssemblyFileVersion("2.2.0.0")]
37 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: build
2 |
3 | # Controls when the action will run. Triggers the workflow on push or pull request
4 | # events but only for the master branch
5 | on:
6 | pull_request:
7 | branches: [ master ]
8 |
9 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
10 | jobs:
11 | # This workflow contains a single job called "build"
12 | build-package:
13 | env:
14 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16 | OAUTH_TOKEN: ${{ secrets.OAUTH_TOKEN }}
17 | # The type of runner that the job will run on
18 | runs-on: ubuntu-latest
19 |
20 | # Steps represent a sequence of tasks that will be executed as part of the job
21 | steps:
22 | # Checkout this repo
23 | - uses: actions/checkout@v2
24 | # Checkout another repo
25 | - uses: actions/checkout@v2
26 | with:
27 | # Repository name with owner.
28 | repository: 'post-kerbin-mining-corporation/build-deploy'
29 | # branch
30 | ref: 'actions'
31 | path: 'build-deploy'
32 | - uses: actions/setup-python@v2
33 | with:
34 | python-version: '3.8'
35 | architecture: 'x64'
36 | - name: Installing dependencies
37 | run: |
38 | python -m pip install --upgrade pip
39 | pip install flake8 pytest awscli boto3 requests
40 | #- name: Running deploy tests
41 | # run: pytest -s --testpath "GameData/" build-deploy/src/tests/ # run the deploy tests
42 | - name: Building package
43 | run: python build-deploy/src/package.py --f ".mod_data.yml"
--------------------------------------------------------------------------------
/Source/DeployableEngines/obj/Debug/DeployableEngines.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | G:\KSP Modding\repositories\DeployableEngines\GameData\Plugins\DeployableEngines.dll
2 | G:\KSP Modding\repositories\DeployableEngines\GameData\Plugins\DeployableEngines.pdb
3 | G:\KSP Modding\repositories\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.dll
4 | G:\KSP Modding\repositories\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.pdb
5 | G:\KSP Modding\repositories\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.csprojResolveAssemblyReference.cache
6 | G:\KSP Modding\repositories\DeployableEngines\DeployableEngines\GameData\Plugins\DeployableEngines.dll
7 | G:\KSP Modding\repositories\DeployableEngines\DeployableEngines\GameData\Plugins\DeployableEngines.pdb
8 | G:\KSP Modding\repositories\DeployableEngines\GameData\DeployableEngines\Plugins\DeployableEngines.dll
9 | G:\KSP Modding\repositories\DeployableEngines\GameData\DeployableEngines\Plugins\DeployableEngines.pdb
10 | C:\Users\Chris\KSP\Repos\DeployableEngines\GameData\DeployableEngines\Plugins\DeployableEngines.dll
11 | C:\Users\Chris\KSP\Repos\DeployableEngines\GameData\DeployableEngines\Plugins\DeployableEngines.pdb
12 | C:\Users\Chris\KSP\Repos\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.csprojAssemblyReference.cache
13 | C:\Users\Chris\KSP\Repos\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.csproj.CoreCompileInputs.cache
14 | C:\Users\Chris\KSP\Repos\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.csproj.CopyComplete
15 | C:\Users\Chris\KSP\Repos\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.dll
16 | C:\Users\Chris\KSP\Repos\DeployableEngines\Source\DeployableEngines\obj\Debug\DeployableEngines.pdb
17 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | =========================
2 | Deployable Engines v1.3.1
3 | =========================
4 |
5 | This is a plugin for Kerbal Space Program which provides small modules useful for animating engine deployment. It does nothing by itself.
6 |
7 | ============
8 | INSTALLATION
9 | ============
10 |
11 | To install, place the GameData folder inside your Kerbal Space Program folder. If asked to overwrite files, please do so.
12 |
13 | =======
14 | KSP-AVC
15 | =======
16 |
17 | This mod is compatible with KSP-AVC version checking. For a comprehensive version checking experience, please download the appropriate plugin (http://forum.kerbalspaceprogram.com/threads/79745).
18 |
19 | =========
20 | LICENSING
21 | =========
22 |
23 | This software is distributed under the MIT license.
24 |
25 | Copyright (c) 2019 Chris Adderley
26 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: deploy
2 |
3 | # Controls when the action will run. Triggers the workflow on push or pull request
4 | # events but only for the master branch
5 | on:
6 | push:
7 | branches: [ master ]
8 |
9 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
10 | jobs:
11 | # This workflow contains a single job called "build"
12 | deploy-package:
13 | env:
14 | AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
15 | AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
16 | OAUTH_TOKEN: ${{ secrets.OAUTH_TOKEN }}
17 | # The type of runner that the job will run on
18 | runs-on: ubuntu-latest
19 |
20 | # Steps represent a sequence of tasks that will be executed as part of the job
21 | steps:
22 | # Checkout this repo
23 | - uses: actions/checkout@v2
24 | # Checkout another repo
25 | - uses: actions/checkout@v2
26 | with:
27 | # Repository name with owner.
28 | repository: 'post-kerbin-mining-corporation/build-deploy'
29 | # branch
30 | ref: 'actions'
31 | path: 'build-deploy'
32 | - uses: actions/setup-python@v2
33 | with:
34 | python-version: '3.8'
35 | architecture: 'x64'
36 | - name: Installing dependencies
37 | run: |
38 | python -m pip install --upgrade pip
39 | pip install flake8 pytest awscli boto3 requests
40 | #- name: Running deploy tests
41 | # run: pytest -s --testpath "GameData/" build-deploy/src/tests/ # run the deploy tests
42 | - name: Building package
43 | run: python build-deploy/src/package.py --f ".mod_data.yml"
44 | - name: Staging package
45 | run: python build-deploy/src/stage.py --f ".mod_data.yml" # Run the staging script
46 | - name: Deploying package
47 | run: python build-deploy/src/deploy.py --f ".mod_data.yml" # Deploy package to spacedock, curse, github
--------------------------------------------------------------------------------
/Source/DeployableEngines/ModuleMultiStateEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 |
7 | namespace DeployableEngines
8 | {
9 | class ModuleMultiStateEngine : PartModule
10 | {
11 | [KSPField(isPersistant = false)]
12 | public string EngineAnimationName;
13 |
14 | [KSPField(isPersistant = false)]
15 | public float WaitForAnimation = 0f;
16 |
17 | [KSPField(isPersistant = false)]
18 | public float SpeedMultiplier = 0f;
19 |
20 | [KSPField(isPersistant = false)]
21 | public int Layer = 1;
22 |
23 | [KSPField(isPersistant = false)]
24 | public string EngineIDAtTimeZero = "";
25 |
26 | private List engines = new List();
27 | private MultiModeEngine multiController;
28 |
29 | private string activeEngineName = "";
30 |
31 | private AnimationState[] engineStates;
32 |
33 | public void Start()
34 | {
35 | engineStates = SetUpAnimation(EngineAnimationName, this.part);
36 |
37 | if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
38 | {
39 | //engines = this.GetComponents().ToList();
40 | multiController = this.GetComponent();
41 | if (multiController != null)
42 | {
43 |
44 | foreach (AnimationState anim in engineStates)
45 | {
46 | anim.enabled = true;
47 | if (multiController.runningPrimary)
48 | {
49 | anim.normalizedTime = 0f;
50 | }
51 | else
52 | {
53 | anim.normalizedTime = 1f;
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
60 | public void Update()
61 | {
62 | if (HighLogic.LoadedSceneIsFlight)
63 | {
64 | if (multiController != null)
65 | {
66 | foreach (AnimationState anim in engineStates)
67 | {
68 | if (anim.normalizedTime >= 1.0f)
69 | anim.normalizedTime = 1.0f;
70 | if (anim.normalizedTime <= -1.0f)
71 | anim.normalizedTime = -1.0f;
72 |
73 | anim.enabled = true;
74 | if (multiController.runningPrimary)
75 | {
76 | anim.speed = -1f * SpeedMultiplier;
77 | }
78 | else
79 | {
80 | anim.speed = 1f * SpeedMultiplier;
81 | }
82 | }
83 | }
84 | }
85 | if (HighLogic.LoadedSceneIsEditor)
86 | {
87 | if (multiController != null)
88 | {
89 | foreach (AnimationState anim in engineStates)
90 | {
91 |
92 | anim.enabled = true;
93 | if (multiController.runningPrimary)
94 | {
95 |
96 | anim.speed = -2f * SpeedMultiplier;
97 | }
98 | else
99 | {
100 | anim.speed = 2f * SpeedMultiplier;
101 | }
102 | }
103 | }
104 | }
105 | }
106 |
107 | public AnimationState[] SetUpAnimation(string animationName, Part part) //Thanks Majiir!
108 | {
109 | var states = new List();
110 | foreach (var animation in part.FindModelAnimators(animationName))
111 | {
112 | var animationState = animation[animationName];
113 | animationState.speed = 0f;
114 | animationState.enabled = true;
115 | animationState.layer = Layer;
116 | animationState.wrapMode = WrapMode.ClampForever;
117 | animationState.blendMode = AnimationBlendMode.Blend;
118 | animation.Blend(animationName);
119 | states.Add(animationState);
120 |
121 | }
122 | return states.ToArray();
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/ModuleAdvancedLookAtConstraint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 | using KSP.Localization;
7 |
8 | namespace DeployableEngines
9 | {
10 |
11 | public class ModuleAdvancedLookAtConstraint : PartModule
12 | {
13 |
14 | [System.Serializable]
15 | public class LookConstraint
16 | {
17 | string rotatorsName;
18 | string targetName;
19 |
20 | // Cached components
21 | Transform target;
22 | Transform rotator;
23 | bool constrained = false;
24 | Vector3 constraintScale;
25 | Part part;
26 |
27 | public LookConstraint(ConfigNode node, Part p)
28 | {
29 | node.TryGetValue("rotatorsName", ref rotatorsName);
30 | node.TryGetValue("targetName", ref targetName);
31 | node.TryGetValue("axisConstrained", ref constrained);
32 | node.TryGetValue("axisScales", ref constraintScale);
33 |
34 | part = p;
35 | rotator = p.FindModelTransform(rotatorsName);
36 | target = p.FindModelTransform(targetName);
37 | }
38 |
39 | public void UpdateRotators()
40 | {
41 | if (rotator != null && target != null)
42 | {
43 | if (!constrained)
44 | {
45 | Vector3 targetPostition = new Vector3(target.position.x,
46 | target.position.y,
47 | target.position.z);
48 |
49 | Vector3 lookPos = target.position - rotator.position;
50 | var rotation = Quaternion.LookRotation(lookPos, target.up);
51 | rotator.rotation = rotation;
52 | }
53 | if (constrained)
54 | {
55 | Vector3 targetPostition = rotator.parent.InverseTransformPoint(target.position);
56 |
57 | Vector3 rotation = Quaternion.LookRotation(targetPostition - rotator.localPosition).eulerAngles;
58 | rotator.localRotation = Quaternion.Euler(
59 | constraintScale.x * rotator.localRotation.eulerAngles.x + (1 - constraintScale.x) * rotation.x,
60 | constraintScale.y * rotator.localRotation.eulerAngles.y + (1 - constraintScale.y) * rotation.y,
61 | constraintScale.z * rotator.localRotation.eulerAngles.z + (1 - constraintScale.z) * rotation.z);
62 | }
63 | }
64 | }
65 | }
66 |
67 |
68 | public List constraints;
69 |
70 | public override void OnLoad(ConfigNode node)
71 | {
72 | base.OnLoad(node);
73 | constraints = new List();
74 | ConfigNode[] cnodes = node.GetNodes("CONSTRAINLOOKFX");
75 | Debug.Log(String.Format("[ModuleAdvancedLookAtConstraint]: Loading {0} constraints", cnodes.Length));
76 |
77 | for (int i = 0; i < cnodes.Length; i++)
78 | {
79 | constraints.Add(new LookConstraint(cnodes[i], this.part));
80 | }
81 |
82 | Debug.Log(String.Format("[ModuleAdvancedLookAtConstraint]: Loaded {0} constraints", constraints.Count));
83 | }
84 | public override void OnStart(StartState state)
85 | {
86 | if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
87 | {
88 | if (constraints == null || constraints.Count == 0)
89 | {
90 | ConfigNode cfg;
91 | foreach (UrlDir.UrlConfig pNode in GameDatabase.Instance.GetConfigs("PART"))
92 | {
93 | if (pNode.name.Replace("_", ".") == part.partInfo.name)
94 | {
95 | cfg = pNode.config;
96 | ConfigNode node = cfg.GetNodes("MODULE").Single(n => n.GetValue("name") == moduleName);
97 | OnLoad(node);
98 | }
99 | }
100 | }
101 | }
102 | }
103 |
104 | void LateUpdate()
105 | {
106 | if (constraints != null)
107 | {
108 | for (int i = 0; i < constraints.Count; i++)
109 | {
110 | constraints[i].UpdateRotators();
111 | }
112 | }
113 | }
114 |
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/DeployableEngines.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {63037415-6C26-47C4-A8E5-4BE51E1CE838}
9 | Library
10 | Properties
11 | DeployableEngines
12 | DeployableEngines
13 | v4.5
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\..\GameData\DeployableEngines\Plugins\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | false
35 |
36 |
37 |
38 | ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp.dll
39 |
40 |
41 | ..\..\..\..\..\..\..\Games\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\KSPAssets.dll
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | ..\..\..\..\..\..\..\Games\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll
51 |
52 |
53 | ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.AnimationModule.dll
54 |
55 |
56 | ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.ClusterRendererModule.dll
57 |
58 |
59 | ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll
60 |
61 |
62 | ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UI.dll
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/Source/DeployableEngines/ModuleDeployableEngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using UnityEngine;
6 | using KSP.Localization;
7 |
8 | // The concepts behind this code are credited to BahamutoD's AnimatedEngine module
9 | // can be found https://github.com/BahamutoD/BDAnimationModules/blob/master/BDAnimationModules/AnimatedEngine.cs
10 |
11 | namespace DeployableEngines
12 | {
13 | public class ModuleDeployableEngine : PartModule
14 | {
15 | [KSPField(isPersistant = false)]
16 | public string EngineAnimationName;
17 |
18 | [KSPField(isPersistant = false)]
19 | public float WaitForAnimation = 0f;
20 |
21 | [KSPField(isPersistant = false)]
22 | public bool OneAnimationForAll = false;
23 |
24 | [KSPField(isPersistant = false)]
25 | public int Layer = 1;
26 |
27 | private bool engineIsOn = false;
28 | private bool hasMultiEngine = false;
29 |
30 | private List engines = new List();
31 | private MultiModeEngine multiController;
32 | private string activeEngineName = "";
33 | private AnimationState[] engineStates;
34 |
35 | [KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "Toggle Animation")]
36 | public void ToggleAnimationEditor()
37 | {
38 | engineIsOn = !engineIsOn;
39 | }
40 |
41 |
42 | public void Start()
43 | {
44 | Events["ToggleAnimationEditor"].guiName = Localizer.Format("#autoLOC_502068");
45 | engineStates = SetUpAnimation(EngineAnimationName, this.part);
46 |
47 | if (HighLogic.LoadedSceneIsFlight)
48 | {
49 | engines = this.GetComponents().ToList();
50 | engineIsOn = QueryEngineOn();
51 |
52 | multiController = this.GetComponent();
53 | if (multiController != null)
54 | hasMultiEngine = true;
55 | }
56 |
57 |
58 | foreach (AnimationState anim in engineStates)
59 | {
60 | if (engineIsOn)
61 | {
62 | anim.normalizedTime = 1f;
63 | }
64 | else
65 | {
66 | anim.normalizedTime = 0f;
67 | }
68 | }
69 |
70 | }
71 |
72 |
73 |
74 | public void Update()
75 | {
76 | if (HighLogic.LoadedSceneIsFlight)
77 | {
78 | engineIsOn = QueryEngineOn();
79 | if (hasMultiEngine)
80 | activeEngineName = multiController.mode;
81 | }
82 |
83 | foreach (var anim in engineStates)
84 | {
85 | if (engineIsOn && anim.normalizedTime < WaitForAnimation)
86 | {
87 | anim.speed = 1;
88 | if (HighLogic.LoadedSceneIsFlight)
89 | {
90 | if (hasMultiEngine)
91 | {
92 | foreach (ModuleEnginesFX fx in engines)
93 | {
94 | if (fx.engineID == activeEngineName)
95 | fx.Shutdown();
96 | }
97 | }
98 | else
99 | {
100 | foreach (ModuleEnginesFX fx in engines)
101 | {
102 | fx.Shutdown();
103 | }
104 | }
105 | }
106 | }
107 |
108 |
109 | if (HighLogic.LoadedSceneIsFlight && anim.normalizedTime >= WaitForAnimation && anim.speed > 0)
110 | {
111 | if (hasMultiEngine)
112 | {
113 | foreach (ModuleEnginesFX fx in engines)
114 | {
115 | if (fx.engineID == activeEngineName)
116 | fx.Activate();
117 | }
118 | }
119 | else
120 | {
121 | foreach (ModuleEnginesFX fx in engines)
122 | {
123 | fx.Activate();
124 | }
125 | }
126 | }
127 |
128 | if (anim.normalizedTime >= 1)
129 | {
130 | anim.speed = 0;
131 | anim.normalizedTime = 1;
132 | }
133 |
134 | if (anim.normalizedTime >= 1 && !engineIsOn)
135 | {
136 | anim.speed = -1;
137 |
138 | }
139 |
140 | if (anim.normalizedTime < 0)
141 | {
142 | anim.speed = 0;
143 | anim.normalizedTime = 0;
144 | }
145 |
146 | }
147 |
148 | }
149 |
150 | private bool QueryEngineOn()
151 | {
152 | foreach (ModuleEnginesFX e in engines)
153 | {
154 | if (e.EngineIgnited)
155 | return true;
156 | }
157 | return false;
158 | }
159 | private bool QueryEngineOn(ModuleEnginesFX fxEng)
160 | {
161 | return false;
162 | }
163 |
164 |
165 |
166 | public AnimationState[] SetUpAnimation(string animationName, Part part) //Thanks Majiir!
167 | {
168 | var states = new List();
169 | foreach (var animation in part.FindModelAnimators(animationName))
170 | {
171 | var animationState = animation[animationName];
172 | animationState.speed = 0;
173 | animationState.enabled = true;
174 | animationState.layer = Layer;
175 | animationState.wrapMode = WrapMode.ClampForever;
176 | animation.Blend(animationName);
177 | states.Add(animationState);
178 |
179 | }
180 | return states.ToArray();
181 | }
182 | }
183 | }
184 |
--------------------------------------------------------------------------------