public void Detach(AttachType attachType)
{
KAS_Shared.DebugLog("Detach(Base) Attach mode is Docked:" + attachMode.Docked + ",Coupled:" + attachMode.Coupled + ",FixedJoint:" + attachMode.FixedJoint + ",StaticJoint:" + attachMode.StaticJoint);
KAS_Shared.DebugLog("Detach(Base) Attach type is : " + attachType);
// Docked
if (attachType == AttachType.Docked)
{
if (dockedAttachModule.part.parent == this.part)
{
KAS_Shared.DebugLog("Detach(Base) Undocking " + dockedAttachModule.part.partInfo.title + " from " + dockedAttachModule.vessel.vesselName);
dockedAttachModule.UndockVessel();
}
if (this.part.parent == dockedAttachModule.part)
{
KAS_Shared.DebugLog("Detach(Base) Undocking " + this.part.partInfo.title + " from " + this.vessel.vesselName);
this.UndockVessel();
}
if (dockedAttachModule.dockedAttachModule == this)
{
dockedAttachModule.dockedAttachModule = null;
dockedAttachModule.dockedPartID = null;
dockedAttachModule.attachMode.Docked = false;
}
this.dockedAttachModule = null;
this.dockedPartID = null;
attachMode.Docked = false;
}
// Coupled
if (attachType == AttachType.Coupled)
{
// Todo
attachMode.Coupled = false;
}
// FixedJoint
if (attachType == AttachType.FixedJoint)
{
KAS_Shared.DebugLog("Detach(Base) Removing fixed joint on " + this.part.partInfo.title);
if (FixedAttach.fixedJoint)
{
Destroy(FixedAttach.fixedJoint);
}
SetCreateJointOnUnpack(false);
FixedAttach.fixedJoint = null;
FixedAttach.connectedPart = null;
attachMode.FixedJoint = false;
}
// StaticJoint
if (attachType == AttachType.StaticJoint)
{
KAS_Shared.DebugLog("Detach(Base) Removing static rigidbody and fixed joint on " + this.part.partInfo.title);
if (StaticAttach.fixedJoint)
{
Destroy(StaticAttach.fixedJoint);
}
if (StaticAttach.connectedGameObject)
{
Destroy(StaticAttach.connectedGameObject);
}
StaticAttach.fixedJoint = null;
StaticAttach.connectedGameObject = null;
attachMode.StaticJoint = false;
}
}