diff --git a/Subsurface/Content/Orders.xml b/Subsurface/Content/Orders.xml index 225e02a97..83f90fc74 100644 --- a/Subsurface/Content/Orders.xml +++ b/Subsurface/Content/Orders.xml @@ -17,7 +17,7 @@ - + diff --git a/Subsurface/Source/Characters/AI/CrewCommander.cs b/Subsurface/Source/Characters/AI/CrewCommander.cs index 446a2ac6e..47870e5d3 100644 --- a/Subsurface/Source/Characters/AI/CrewCommander.cs +++ b/Subsurface/Source/Characters/AI/CrewCommander.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Linq; using System.Collections.Generic; namespace Barotrauma @@ -71,8 +72,8 @@ namespace Barotrauma for (int n = 0; n<2; n++) { List orders = (n==0) ? - Order.PrefabList.FindAll(o => o.ItemComponentType == null) : - Order.PrefabList.FindAll(o=> o.ItemComponentType != null); + Order.PrefabList.FindAll(o => o.ItemComponentType == null && string.IsNullOrEmpty(o.ItemName)) : + Order.PrefabList.FindAll(o => o.ItemComponentType != null || !string.IsNullOrEmpty(o.ItemName)); int startX = -(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2; @@ -81,9 +82,12 @@ namespace Barotrauma { int x = startX + (buttonWidth + spacing) * (i % orders.Count); - if (order.ItemComponentType!=null) + if (order.ItemComponentType!=null || !string.IsNullOrEmpty(order.ItemName)) { - var matchingItems = Item.ItemList.FindAll(it => it.components.Find(ic => ic.GetType() == order.ItemComponentType) != null); + List matchingItems = !string.IsNullOrEmpty(order.ItemName) ? + Item.ItemList.FindAll(it => it.Name == order.ItemName) : + Item.ItemList.FindAll(it => it.components.Any(ic => ic.GetType() == order.ItemComponentType)); + int y2 = y; foreach (Item it in matchingItems) { diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs index 534b811d8..ded80c299 100644 --- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -63,6 +63,12 @@ namespace Barotrauma if (equip) { var pickable = targetItem.GetComponent(); + if (pickable == null) + { + canBeCompleted = false; + return; + } + //check if all the slots required by the item are free foreach (InvSlotType slots in pickable.AllowedSlots) { @@ -112,8 +118,14 @@ namespace Barotrauma /// private void FindTargetItem() { - float currDist = moveToTarget == null ? 0.0f : Vector2.DistanceSquared(moveToTarget.Position, character.Position); + if (itemName == null) + { + if (targetItem == null) canBeCompleted = false; + return; + } + float currDist = moveToTarget == null ? 0.0f : Vector2.DistanceSquared(moveToTarget.Position, character.Position); + for (int i = 0; i < 10 && currSearchIndex < Item.ItemList.Count - 2; i++) { currSearchIndex++; diff --git a/Subsurface/Source/Characters/AI/Order.cs b/Subsurface/Source/Characters/AI/Order.cs index f8b9bab3f..58efac592 100644 --- a/Subsurface/Source/Characters/AI/Order.cs +++ b/Subsurface/Source/Characters/AI/Order.cs @@ -21,6 +21,7 @@ namespace Barotrauma public readonly Sprite SymbolSprite; public readonly Type ItemComponentType; + public readonly string ItemName; public readonly Color Color; @@ -76,6 +77,8 @@ namespace Barotrauma } } + ItemName = ToolBox.GetAttributeString(orderElement, "targetitemname", ""); + Color = new Color(ToolBox.GetAttributeVector4(orderElement, "color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f))); UseController = ToolBox.GetAttributeBool(orderElement, "usecontroller", false);