Fixed AIObjectiveGoto terminating if previous path was unreachable, BackGroundSpriteManager won't place a sprite if a suitable position isn't found, StatusEffect fire position fix, UI improvements, door convexhull fix, progress on Fabricators & Deconstructors, mapentities sorted by category in edit mode, item descriptions, TutorialMode refactoring to make it easier to add new types of tutorials
This commit is contained in:
@@ -17,6 +17,10 @@ namespace Barotrauma
|
||||
|
||||
private Character character;
|
||||
|
||||
private Vector2 currentTarget;
|
||||
|
||||
private float findPathTimer;
|
||||
|
||||
public SteeringPath CurrentPath
|
||||
{
|
||||
get { return currentPath; }
|
||||
@@ -27,9 +31,10 @@ namespace Barotrauma
|
||||
get { return pathFinder; }
|
||||
}
|
||||
|
||||
private Vector2 currentTarget;
|
||||
|
||||
private float findPathTimer;
|
||||
public Vector2 CurrentTarget
|
||||
{
|
||||
get { return currentTarget; }
|
||||
}
|
||||
|
||||
public IndoorsSteeringManager(ISteerable host, bool canOpenDoors)
|
||||
: base(host)
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace Barotrauma
|
||||
|
||||
if (container.Item.inventory == character.Inventory)
|
||||
{
|
||||
var containedItems = container.inventory.Items;
|
||||
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, false);
|
||||
container.Inventory.TryPutItem(itemToContain, null, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -90,35 +90,42 @@ namespace Barotrauma
|
||||
{
|
||||
character.Inventory.TryPutItem(targetItem, targetSlot, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i<10 && currSearchIndex<Item.ItemList.Count; i++)
|
||||
for (int i = 0; i<10 && currSearchIndex<Item.ItemList.Count-2; i++)
|
||||
{
|
||||
currSearchIndex++;
|
||||
|
||||
if (!Item.ItemList[currSearchIndex].HasTag(itemName) && Item.ItemList[currSearchIndex].Name != itemName) continue;
|
||||
if (IgnoreContainedItems && Item.ItemList[currSearchIndex].container != null) continue;
|
||||
if (Item.ItemList[currSearchIndex].inventory is CharacterInventory) continue;
|
||||
|
||||
targetItem = Item.ItemList[currSearchIndex];
|
||||
|
||||
targetItem = Item.ItemList[currSearchIndex];
|
||||
|
||||
AddGoToObjective(targetItem);
|
||||
|
||||
Item moveToTarget = targetItem;
|
||||
while (moveToTarget.container != null)
|
||||
{
|
||||
moveToTarget = moveToTarget.container;
|
||||
}
|
||||
|
||||
subObjectives.Add(new AIObjectiveGoTo(moveToTarget, character));
|
||||
return;
|
||||
}
|
||||
|
||||
if (currSearchIndex >= Item.ItemList.Count) canBeCompleted = false;
|
||||
}
|
||||
|
||||
private void AddGoToObjective(Item item)
|
||||
{
|
||||
Item moveToTarget = item;
|
||||
while (moveToTarget.container != null)
|
||||
{
|
||||
moveToTarget = moveToTarget.container;
|
||||
}
|
||||
|
||||
AddSubObjective(new AIObjectiveGoTo(moveToTarget, character));
|
||||
}
|
||||
|
||||
public override bool IsDuplicate(AIObjective otherObjective)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,14 @@ namespace Barotrauma
|
||||
{
|
||||
if (repeat) return true;
|
||||
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
||||
return (pathSteering.CurrentPath == null || !pathSteering.CurrentPath.Unreachable);
|
||||
|
||||
//path doesn't exist (= hasn't been searched for yet), assume for now that the target is reachable
|
||||
if (pathSteering.CurrentPath == null) return true;
|
||||
//steeringmanager is still targeting some other position, assume for now that the target is reachable
|
||||
if ((target != null && Vector2.Distance(target.Position, targetPos) > 5.0f) ||
|
||||
Vector2.Distance(pathSteering.CurrentTarget, targetPos) > 5.0f) return true;
|
||||
|
||||
return (!pathSteering.CurrentPath.Unreachable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,11 @@ namespace Barotrauma
|
||||
for (int i = 0 ; i <amount; i++)
|
||||
{
|
||||
BackgroundSpritePrefab prefab = GetRandomPrefab();
|
||||
Vector2 pos = FindSpritePosition(level, prefab);
|
||||
Vector2? pos = FindSpritePosition(level, prefab);
|
||||
|
||||
var newSprite = new BackgroundSprite(prefab, pos);
|
||||
if (pos == null) continue;
|
||||
|
||||
var newSprite = new BackgroundSprite(prefab, (Vector2)pos);
|
||||
|
||||
int n = 0;
|
||||
|
||||
@@ -62,16 +64,16 @@ namespace Barotrauma
|
||||
if (existingSprite.Texture == newSprite.Prefab.Sprite.Texture) break;
|
||||
}
|
||||
|
||||
sprites.Insert(i, newSprite);
|
||||
sprites.Insert(n, newSprite);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 FindSpritePosition(Level level, BackgroundSpritePrefab prefab)
|
||||
private Vector2? FindSpritePosition(Level level, BackgroundSpritePrefab prefab)
|
||||
{
|
||||
Vector2 randomPos = new Vector2(Rand.Range(0.0f, level.Size.X), Rand.Range(0.0f, level.Size.Y));
|
||||
var cells = level.GetCells(randomPos);
|
||||
|
||||
if (!cells.Any()) return Vector2.Zero;
|
||||
if (!cells.Any()) return null;
|
||||
|
||||
VoronoiCell cell = cells[Rand.Int(cells.Count)];
|
||||
GraphEdge bestEdge = null;
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Barotrauma
|
||||
textBlock.Font = GUI.SmallFont;
|
||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||
|
||||
new GUIImage(new Rectangle(-10, -5, 0, 0), HeadSprite, Alignment.Left, frame);
|
||||
new GUIImage(new Rectangle(-5, -5, 0, 0), HeadSprite, Alignment.Left, frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,9 @@ namespace Barotrauma
|
||||
protected virtual void Apply(float deltaTime, Entity entity, List<IPropertyObject> targets)
|
||||
{
|
||||
if (explosion != null) explosion.Explode(entity.WorldPosition);
|
||||
if (Fire) new FireSource(ConvertUnits.ToDisplayUnits(entity.SimPosition));
|
||||
|
||||
|
||||
if (Fire) new FireSource(entity.WorldPosition);
|
||||
|
||||
if (sound != null) sound.Play(1.0f, 1000.0f, entity.WorldPosition);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user