From f97493c45e4cd00ec403d2f8140745ed6139bbe7 Mon Sep 17 00:00:00 2001 From: Aleks976 Date: Tue, 31 May 2016 14:32:49 -0400 Subject: [PATCH] Modified the control that copies a ship as a blueprint to only work if the ship belongs to the player, or the ship's owner is in the player's faction. Will work regardless of ownership if the player is in creative mode. --- .../Game/Entities/Cube/MyCubeBuilder.cs | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/Sources/Sandbox.Game/Game/Entities/Cube/MyCubeBuilder.cs b/Sources/Sandbox.Game/Game/Entities/Cube/MyCubeBuilder.cs index 9eed5b5b12..648db4e071 100644 --- a/Sources/Sandbox.Game/Game/Entities/Cube/MyCubeBuilder.cs +++ b/Sources/Sandbox.Game/Game/Entities/Cube/MyCubeBuilder.cs @@ -1742,20 +1742,40 @@ public bool HandleGameInput() { MySessionComponentVoxelHand.Static.Enabled = false; var copiedGrid = MyCubeGrid.GetTargetGrid(); - if (!MyInput.Static.IsAnyShiftKeyPressed()) - m_clipboard.CopyGroup(copiedGrid, MyInput.Static.IsAnyAltKeyPressed() ? GridLinkTypeEnum.Physical : GridLinkTypeEnum.Logical); - else - m_clipboard.CopyGrid(copiedGrid); + Boolean ownerInplayerFaction = false; + var faction = MySession.Static.Factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId); + for (int i = 0; i < copiedGrid.BigOwners.Count; i++ ) + { + if (faction != null) + { + if (MySession.Static.Factions.TryGetPlayerFaction(copiedGrid.BigOwners[i]) == faction) + { + ownerInplayerFaction = true; + break; + } + } + else + { + break; + } + } + if (copiedGrid.BigOwners.Contains(MySession.Static.LocalPlayerId) || ownerInplayerFaction || !MySession.Static.SurvivalMode || copiedGrid.BigOwners.Count == 0) //If player owns ship, or owner is in players faction, or in creative mode or ship is neutral + { + if (!MyInput.Static.IsAnyShiftKeyPressed()) + m_clipboard.CopyGroup(copiedGrid, MyInput.Static.IsAnyAltKeyPressed() ? GridLinkTypeEnum.Physical : GridLinkTypeEnum.Logical); + else + m_clipboard.CopyGrid(copiedGrid); - UpdatePasteNotification(MyCommonTexts.CubeBuilderPasteNotification); + UpdatePasteNotification(MyCommonTexts.CubeBuilderPasteNotification); - var blueprintScreen = new MyGuiBlueprintScreen(m_clipboard); - if (copiedGrid != null) - { - blueprintScreen.CreateFromClipboard(true); + var blueprintScreen = new MyGuiBlueprintScreen(m_clipboard); + if (copiedGrid != null) + { + blueprintScreen.CreateFromClipboard(true); + } + m_clipboard.Deactivate(); + MyGuiSandbox.AddScreen(blueprintScreen); } - m_clipboard.Deactivate(); - MyGuiSandbox.AddScreen(blueprintScreen); } return true; }