Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions DSUtil.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace DockingStrut
Expand Down
Binary file added Docking-Strut.zip
Binary file not shown.
Binary file added Docking-Strut/Parts/DockingStrut/model.mu
Binary file not shown.
Binary file added Docking-Strut/Parts/DockingStrut/model000.mbm
Binary file not shown.
64 changes: 64 additions & 0 deletions Docking-Strut/Parts/DockingStrut/part.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// this is a sample config file, for determining a good file format for defining part parameters
// comment line - ignored by cfg parser
// empty lines, or lines without a '=' sign are also ignored
// all other lines are split at the '=' sign, and the left operand is used to know what parameter we are setting
// diferent parameters require data in different formats (see docs), and each module has it's own parameters (again, see docs)
// each assignment must be in a single line. Lines without assignments will be ignored. (You CAN turn on word wrap, though)
// each keyword here relates to an existing variable in the assigned module. If the keyword isn't found, it is ignored.
// conversely, if a keyword is left unassigned (as in not in the file), it will be initialized with it's default value
// This is done automatically, so any public variable defined in the loaded module can be accessed this way (provided it's value can be parsed)--

PART
{
// --- general parameters ---
name = DockingStrut
module = Part
author = HarvesteR || JDP

// --- asset parameters ---
mesh = model.mu
scale = 0.1

// --- editor parameters ---
cost = 250
category = Structural
subcategory = 0
title = EAS-5 Docking Strut
manufacturer = Kerlington Model Rockets and Paper Products Inc.
description = The Strut Connector is highly regarded by many spacecraft engineers as it helps in constructing more stable spacecraft. This update to the popular EAS-4 Strut is configurable in flight and can thus be used to stabilize docked ships.

// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
attachRules = 0,1,0,0,1

// --- node definitions ---
// definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z
node_attach = 0.0, 0.0, 0.0, -1.0, 0.0, 0.0


// --- standard part parameters ---
mass = 0.05
dragModelType = default
maximum_drag = 0.02
minimum_drag = 0.02
angularDrag = 1
crashTolerance = 12
breakingForce = 200
breakingTorque = 200
maxTemp = 3600
explosionPotential = 0



MODULE
{
name = ModuleDockingStrut
MaxDistance = 10
breakingForce = 200
breakingTorque = 200
}

}


// ----- DO NOT EDIT BELOW THIS POINT ------

Binary file added Docking-Strut/Plugins/DockingStrut.dll
Binary file not shown.
71 changes: 71 additions & 0 deletions DockingStrut.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7A0868B5-18C4-49FC-9587-7ED2170D91F0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DockingStrut</RootNamespace>
<AssemblyName>DockingStrut</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\KSPDLLs\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPUtil">
<HintPath>..\..\KSPDLLs\KSPUtil.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\KSPDLLs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\KSPDLLs\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DSUtil.cs" />
<Compile Include="ModuleDockingStrut.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>cd "$(TargetDir)"
"C:\Program Files (x86)\mono\bin\mono.exe" "C:\Program Files (x86)\mono\lib\mono\4.5\pdb2mdb.exe" "$(TargetFileName)"</PostBuildEvent>
</PropertyGroup>
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
34 changes: 21 additions & 13 deletions ModuleDockingStrut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@ This code is free to use and modify as long as the original author is credited.
- Reworked joint linkage to get rid of phantom forces.
- Added new ID system.
- Reworked the way the visual strut is rescaled.

1.0.2.0
- Updated for KSP 1.0.5 (JPLRepo)

1.0.3.0
- Updated for KSP 1.1 (JPLRepo)
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace DockingStrut {
public class ModuleDockingStrut : PartModule {
float StrutX, StrutY;
float StrutX, StrutY, StrutZ;

[KSPField]
int ticksToCheckForLinkAtStart = 100;

[KSPField]
public float MaxDistance = 10;

[KSPField(isPersistant = true, guiActive = true)]
[KSPField(isPersistant = true, guiActive = false)]
public string TargetIDs = Guid.Empty.ToString(), IDs = Guid.Empty.ToString();

public Guid TargetID {
Expand Down Expand Up @@ -213,17 +216,20 @@ void updateLink() {
}
}

if (jointCreated != Targeted && !part.rigidbody.isKinematic && TargetDS != null && !TargetDS.part.rigidbody.isKinematic) {
if (jointCreated != Targeted && !part.Rigidbody.isKinematic && TargetDS != null && !TargetDS.part.Rigidbody.isKinematic) {
if (Targeted) {
joint = part.rigidbody.gameObject.AddComponent<ConfigurableJoint>();
joint.connectedBody = TargetDS.part.rigidbody;
joint = part.Rigidbody.gameObject.AddComponent<ConfigurableJoint>();
joint.connectedBody = TargetDS.part.Rigidbody;
joint.breakForce = joint.breakTorque = float.PositiveInfinity;
joint.xMotion = ConfigurableJointMotion.Locked;
joint.yMotion = ConfigurableJointMotion.Locked;
joint.zMotion = ConfigurableJointMotion.Locked;
joint.angularXMotion = ConfigurableJointMotion.Locked;
joint.angularYMotion = ConfigurableJointMotion.Locked;
joint.angularZMotion = ConfigurableJointMotion.Locked;
joint.projectionAngle = 0f;
joint.projectionDistance = 0f;
joint.anchor = TargetDS.strutTarget;
} else {
Destroy(joint);
joint = null;
Expand Down Expand Up @@ -254,7 +260,7 @@ public void SetTarget(ModuleDockingStrut PosTarget) {
if (!DSUtil.checkPossibleTarget(this, PosTarget)) {
mode = DSMode.UNLINKED;
Targeted = false;
return;
return;
}

foreach (BaseEvent e in Events)
Expand All @@ -268,10 +274,11 @@ public void SetTarget(ModuleDockingStrut PosTarget) {
SetStrutEnd(TargetDS.strutTarget);
}

void SetStrutEnd(Vector3 position) {
mStrut.LookAt(position);
mStrut.localScale = new Vector3(StrutX, StrutY, 1);
mStrut.localScale = new Vector3(StrutX, StrutY, Vector3.Distance(Vector3.zero, mStrut.InverseTransformPoint(position)));
void SetStrutEnd(Vector3 target) {
mStrut.LookAt(target);
mStrut.localScale = new Vector3(StrutX, StrutY, 1);
var distance = (Vector3.Distance(Vector3.zero, mStrut.InverseTransformPoint(target)));
mStrut.localScale = new Vector3(StrutX, StrutY, distance * StrutZ);
}

bool started = false;
Expand All @@ -280,6 +287,7 @@ public override void OnStart(PartModule.StartState state) {

StrutX = mStrut.localScale.x;
StrutY = mStrut.localScale.y;
StrutZ = mStrut.localScale.z;
mStrut.localScale = Vector3.zero;

if (state == StartState.Editor) return;
Expand Down
35 changes: 35 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
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("DockingStrut")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DockingStrut")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[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("7a0868b5-18c4-49fc-9587-7ed2170d91f0")]

// 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.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]