public void Undock(bool applyEffects = true) { if (DockingTarget == null || !docked) { return; } forceLockTimer = 0.0f; dockingCooldown = 0.1f; if (applyEffects) { ApplyStatusEffects(ActionType.OnSecondaryUse, 1.0f); } DockingTarget.item.Submarine.ConnectedDockingPorts.Remove(item.Submarine); item.Submarine.ConnectedDockingPorts.Remove(DockingTarget.item.Submarine); if (Door != null && DockingTarget.Door != null) { WayPoint myWayPoint = WayPoint.WayPointList.Find(wp => Door.LinkedGap == wp.ConnectedGap); WayPoint targetWayPoint = WayPoint.WayPointList.Find(wp => DockingTarget.Door.LinkedGap == wp.ConnectedGap); if (myWayPoint != null && targetWayPoint != null) { myWayPoint.FindHull(); myWayPoint.linkedTo.Remove(targetWayPoint); targetWayPoint.FindHull(); targetWayPoint.linkedTo.Remove(myWayPoint); } } item.linkedTo.Clear(); docked = false; Item.Submarine.EnableObstructedWaypoints(DockingTarget.Item.Submarine); obstructedWayPointsDisabled = false; Item.Submarine.RefreshOutdoorNodes(); DockingTarget.Undock(); DockingTarget = null; if (doorBody != null) { GameMain.World.Remove(doorBody); doorBody = null; } var wire = item.GetComponent <Wire>(); wire?.Drop(null); if (joint != null) { GameMain.World.Remove(joint); joint = null; } hulls[0]?.Remove(); hulls[0] = null; hulls[1]?.Remove(); hulls[1] = null; if (gap != null) { gap.Remove(); gap = null; } if (bodies != null) { foreach (Body body in bodies) { if (body == null) { continue; } GameMain.World.Remove(body); } bodies = null; } outsideBlocker?.Body.Remove(outsideBlocker); outsideBlocker = null; #if SERVER if (GameMain.Server != null && (!item.Submarine?.Loading ?? true)) { item.CreateServerEvent(this); } #endif OnUnDocked?.Invoke(); OnUnDocked = null; }
public void Undock() { if (DockingTarget == null || !docked) { return; } forceLockTimer = 0.0f; ApplyStatusEffects(ActionType.OnSecondaryUse, 1.0f); DockingTarget.item.Submarine.DockedTo.Remove(item.Submarine); item.Submarine.DockedTo.Remove(DockingTarget.item.Submarine); if (door != null && DockingTarget.door != null) { WayPoint myWayPoint = WayPoint.WayPointList.Find(wp => door.LinkedGap == wp.ConnectedGap); WayPoint targetWayPoint = WayPoint.WayPointList.Find(wp => DockingTarget.door.LinkedGap == wp.ConnectedGap); if (myWayPoint != null && targetWayPoint != null) { myWayPoint.linkedTo.Remove(targetWayPoint); targetWayPoint.linkedTo.Remove(myWayPoint); } } item.linkedTo.Clear(); docked = false; DockingTarget.Undock(); DockingTarget = null; if (doorBody != null) { GameMain.World.RemoveBody(doorBody); doorBody = null; } var wire = item.GetComponent <Wire>(); if (wire != null) { wire.Drop(null); } if (joint != null) { GameMain.World.RemoveJoint(joint); joint = null; } hulls[0]?.Remove(); hulls[0] = null; hulls[1]?.Remove(); hulls[1] = null; if (gap != null) { gap.Remove(); gap = null; } if (bodies != null) { foreach (Body body in bodies) { if (body == null) { continue; } GameMain.World.RemoveBody(body); } bodies = null; } Item.Submarine.EnableObstructedWaypoints(); obstructedWayPointsDisabled = false; #if SERVER if (GameMain.Server != null) { item.CreateServerEvent(this); } #endif }