NPCs don't try to use depth charge tubes when given the "operate railgun" command

This commit is contained in:
Regalis
2016-08-16 17:37:08 +03:00
parent cce3b32a82
commit 8a2ad8eb64
4 changed files with 25 additions and 6 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
<Sprite texture="Content/UI/uiIcons.png" sourcerect="192,0,64,64"/> <Sprite texture="Content/UI/uiIcons.png" sourcerect="192,0,64,64"/>
</Order> </Order>
<Order name="Operate Railgun" doingtext="Operating Railgun" targetitemtype="Turret" usecontroller="true" options="Fire at will, Hold fire" color="0.12,0.3,0.5,1.0"> <Order name="Operate Railgun" doingtext="Operating Railgun" targetitemname="Railgun" targetitemtype="Turret" usecontroller="true" options="Fire at will, Hold fire" color="0.12,0.3,0.5,1.0">
<Sprite texture="Content/UI/uiIcons.png" sourcerect="0,64,64,64"/> <Sprite texture="Content/UI/uiIcons.png" sourcerect="0,64,64,64"/>
</Order> </Order>
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
namespace Barotrauma namespace Barotrauma
@@ -71,8 +72,8 @@ namespace Barotrauma
for (int n = 0; n<2; n++) for (int n = 0; n<2; n++)
{ {
List<Order> orders = (n==0) ? List<Order> orders = (n==0) ?
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); Order.PrefabList.FindAll(o => o.ItemComponentType != null || !string.IsNullOrEmpty(o.ItemName));
int startX = -(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2; int startX = -(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
@@ -81,9 +82,12 @@ namespace Barotrauma
{ {
int x = startX + (buttonWidth + spacing) * (i % orders.Count); 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<Item> 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; int y2 = y;
foreach (Item it in matchingItems) foreach (Item it in matchingItems)
{ {
@@ -63,6 +63,12 @@ namespace Barotrauma
if (equip) if (equip)
{ {
var pickable = targetItem.GetComponent<Pickable>(); var pickable = targetItem.GetComponent<Pickable>();
if (pickable == null)
{
canBeCompleted = false;
return;
}
//check if all the slots required by the item are free //check if all the slots required by the item are free
foreach (InvSlotType slots in pickable.AllowedSlots) foreach (InvSlotType slots in pickable.AllowedSlots)
{ {
@@ -112,8 +118,14 @@ namespace Barotrauma
/// </summary> /// </summary>
private void FindTargetItem() 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++) for (int i = 0; i < 10 && currSearchIndex < Item.ItemList.Count - 2; i++)
{ {
currSearchIndex++; currSearchIndex++;
+3
View File
@@ -21,6 +21,7 @@ namespace Barotrauma
public readonly Sprite SymbolSprite; public readonly Sprite SymbolSprite;
public readonly Type ItemComponentType; public readonly Type ItemComponentType;
public readonly string ItemName;
public readonly Color Color; 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))); Color = new Color(ToolBox.GetAttributeVector4(orderElement, "color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)));
UseController = ToolBox.GetAttributeBool(orderElement, "usecontroller", false); UseController = ToolBox.GetAttributeBool(orderElement, "usecontroller", false);