From 860e5204ab5767b58172681671f10be8cc6012e7 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 4 Apr 2019 11:07:29 +0300 Subject: [PATCH] (cad2b1306) Fix the camera issue on turrets. --- .../Items/Components/Machines/Fabricator.cs | 25 +++++++++++++++++++ .../Source/Characters/Character.cs | 4 +-- .../Source/Items/Components/ItemComponent.cs | 2 +- .../Items/Components/Machines/Controller.cs | 5 ---- .../BarotraumaShared/Source/Items/Item.cs | 11 +++++++- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs index f3b542df7..2887ca22e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs @@ -318,6 +318,8 @@ namespace Barotrauma.Items.Components return true; } + Rectangle slotRect = inputContainer.Inventory.slots[slotIndex].Rect; + itemIcon.Draw( spriteBatch, slotRect.Center.ToVector2(), @@ -359,7 +361,30 @@ namespace Barotrauma.Items.Components } } + private bool SelectItem(Character user, FabricationRecipe selectedItem) + { + selectedItemFrame.ClearChildren(); + + var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), selectedItemFrame.RectTransform, Anchor.Center)) { RelativeSpacing = 0.03f, Stretch = true }; + + /*var itemIcon = selectedItem.TargetItem.InventoryIcon ?? selectedItem.TargetItem.sprite; + if (itemIcon != null) + { + GUIImage img = new GUIImage(new RectTransform(new Point(40, 40), paddedFrame.RectTransform), + itemIcon, scaleToFit: true) + { + Color = selectedItem.TargetItem.InventoryIconColor + }; + }*/ + var nameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform), + selectedItem.TargetItem.Name, textAlignment: Alignment.CenterLeft); + if (GameMain.Client != null) + { + inadequateSkills = selectedItem.RequiredSkills.FindAll(skill => user.GetSkillLevel(skill.Identifier) < skill.Level); + } + + if (selectedItem.RequiredSkills.Any()) { string text = TextManager.Get("FabricatorRequiredSkills") + ":\n"; foreach (Skill skill in selectedItem.RequiredSkills) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index e986a8341..09cb6ab3b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1276,7 +1276,7 @@ namespace Barotrauma if (i == 1 && selectedItems[0] == selectedItems[1]) { continue; } var item = selectedItems[i]; if (item == null) { continue; } - if (IsKeyDown(InputType.Aim)) + if (IsKeyDown(InputType.Aim) || !item.RequireAimToSecondaryUse) { item.SecondaryUse(deltaTime, this); } @@ -1299,7 +1299,7 @@ namespace Barotrauma if (SelectedConstruction != null) { - if (IsKeyDown(InputType.Aim)) + if (IsKeyDown(InputType.Aim) || !SelectedConstruction.RequireAimToSecondaryUse) { SelectedConstruction.SecondaryUse(deltaTime, this); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs index 808337a05..d5490c63d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs @@ -355,7 +355,7 @@ namespace Barotrauma.Items.Components return characterUsable || character == null; } - //called when the item is equipped and the "aim" key is pressed + //called when the item is equipped and the "aim" key is pressed or when the item is selected if it doesn't require aiming. public virtual bool SecondaryUse(float deltaTime, Character character = null) { return false; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs index 6a24898c0..20f9540b7 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs @@ -147,11 +147,6 @@ namespace Barotrauma.Items.Components limb.PullJointEnabled = true; limb.PullJointWorldAnchorB = limb.SimPosition + ConvertUnits.ToSimUnits(diff); } - - if (!item.RequireAimToUse) - { - Control(deltaTime, character); - } } public override bool Use(float deltaTime, Character activator = null) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 26d896afb..af9ba2ec3 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -242,7 +242,7 @@ namespace Barotrauma public bool IsShootable { get; set; } /// - /// If true, the user has to hold the "aim" key before use is registered. + /// If true, the user has to hold the "aim" key before use is registered. False by default. /// [Serialize(false, false)] public bool RequireAimToUse @@ -250,6 +250,15 @@ namespace Barotrauma get; set; } + /// + /// If true, the user has to hold the "aim" key before secondary use is registered. True by default. + /// + [Serialize(true, false)] + public bool RequireAimToSecondaryUse + { + get; set; + } + public Color Color { get { return spriteColor; }