(457e4ebe5) Fixed: Submarine navigation labels being translated when loading a sub in editor

This commit is contained in:
Joonas Rikkonen
2019-05-16 06:13:49 +03:00
parent fc584c1bc4
commit 5f524ddd3f
42 changed files with 631 additions and 379 deletions
@@ -11,13 +11,12 @@ namespace Barotrauma
public Func<Item, float> GetItemPriority;
public int targetItemCount = 1;
public int MinContainedAmount = 1;
public string[] ignoredContainerIdentifiers;
public bool checkInventory = true;
//can either be a tag or an identifier
public readonly string[] itemIdentifiers;
public readonly ItemContainer container;
private readonly string[] itemIdentifiers;
private readonly ItemContainer container;
private bool isCompleted;
private AIObjectiveGetItem getItemObjective;
@@ -40,6 +39,7 @@ namespace Barotrauma
public override bool IsCompleted()
{
if (isCompleted) { return true; }
int containedItemCount = 0;
foreach (Item item in container.Inventory.Items)
{
@@ -48,7 +48,7 @@ namespace Barotrauma
containedItemCount++;
}
}
return containedItemCount >= targetItemCount;
return containedItemCount >= MinContainedAmount;
}
public override float GetPriority()
@@ -62,6 +62,7 @@ namespace Barotrauma
protected override void Act(float deltaTime)
{
if (isCompleted) { return; }
//get the item that should be contained
Item itemToContain = null;
foreach (string identifier in itemIdentifiers)
@@ -71,13 +72,8 @@ namespace Barotrauma
}
if (itemToContain == null)
{
if (getItemObjective != null && getItemObjective.IsCompleted())
{
getItemObjective = null;
targetItemCount--;
}
TryAddSubObjective(ref getItemObjective, () =>
new AIObjectiveGetItem(character, itemIdentifiers, objectiveManager, checkInventory: checkInventory)
new AIObjectiveGetItem(character, itemIdentifiers, objectiveManager)
{
GetItemPriority = GetItemPriority,
ignoredContainerIdentifiers = ignoredContainerIdentifiers
@@ -85,7 +81,14 @@ namespace Barotrauma
return;
}
if (container.Item.ParentInventory == character.Inventory)
{
{
var containedItems = container.Inventory.Items;
//if there's already something in the mask (empty oxygen tank?), drop it
var existingItem = containedItems.FirstOrDefault(i => i != null);
if (existingItem != null)
{
existingItem.Drop(character);
}
character.Inventory.RemoveItem(itemToContain);
container.Inventory.TryPutItem(itemToContain, null);
}
@@ -99,6 +102,7 @@ namespace Barotrauma
}
container.Combine(itemToContain);
}
isCompleted = true;
}
public override bool IsDuplicate(AIObjective otherObjective)