public void Lock(bool isNetworkMessage, bool applyEffects = true) { #if CLIENT if (GameMain.Client != null && !isNetworkMessage) { return; } #endif if (DockingTarget == null) { DebugConsole.ThrowError("Error - attempted to lock a docking port that's not connected to anything"); return; } if (!(joint is WeldJoint)) { DockingDir = GetDir(DockingTarget); DockingTarget.DockingDir = -DockingDir; if (applyEffects) { ApplyStatusEffects(ActionType.OnUse, 1.0f); } Vector2 jointDiff = joint.WorldAnchorB - joint.WorldAnchorA; if (item.Submarine.PhysicsBody.Mass < DockingTarget.item.Submarine.PhysicsBody.Mass || DockingTarget.item.Submarine.Info.IsOutpost) { item.Submarine.SubBody.SetPosition(item.Submarine.SubBody.Position + ConvertUnits.ToDisplayUnits(jointDiff)); } else if (DockingTarget.item.Submarine.PhysicsBody.Mass < item.Submarine.PhysicsBody.Mass || item.Submarine.Info.IsOutpost) { DockingTarget.item.Submarine.SubBody.SetPosition(DockingTarget.item.Submarine.SubBody.Position - ConvertUnits.ToDisplayUnits(jointDiff)); } ConnectWireBetweenPorts(); CreateJoint(true); #if SERVER if (GameMain.Server != null && (!item.Submarine?.Loading ?? true)) { item.CreateServerEvent(this); } #else if (GameMain.Client != null && GameMain.Client.MidRoundSyncing && (item.Submarine == Submarine.MainSub || DockingTarget.item.Submarine == Submarine.MainSub)) { Screen.Selected.Cam.Position = Submarine.MainSub.WorldPosition; } #endif } List <MapEntity> removedEntities = item.linkedTo.Where(e => e.Removed).ToList(); foreach (MapEntity removed in removedEntities) { item.linkedTo.Remove(removed); } if (!item.linkedTo.Any(e => e is Hull) && !DockingTarget.item.linkedTo.Any(e => e is Hull)) { CreateHulls(); } 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(); targetWayPoint.FindHull(); myWayPoint.ConnectTo(targetWayPoint); } } }