(0e668e083) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev (squashed together 20290af96..0e668e083 because the merge script shit itself due to the merges in between)

This commit is contained in:
Joonas Rikkonen
2019-05-20 20:25:12 +03:00
parent d43b3737c8
commit 97b095bd10
32 changed files with 169 additions and 27 deletions
@@ -128,7 +128,7 @@ namespace Barotrauma
if (seekAmmunition == null || !subObjectives.Contains(seekAmmunition))
{
Move();
if (Weapon != null)
if (WeaponComponent != null)
{
OperateWeapon(deltaTime);
}
@@ -320,7 +320,10 @@ namespace Barotrauma
{
retreatTarget = findSafety.FindBestHull(HumanAIController.VisibleHulls);
}
TryAddSubObjective(ref retreatObjective, () => new AIObjectiveGoTo(retreatTarget, character, objectiveManager, false, true));
if (character.CurrentHull != retreatTarget)
{
TryAddSubObjective(ref retreatObjective, () => new AIObjectiveGoTo(retreatTarget, character, objectiveManager, false, true));
}
}
private void Engage()
@@ -336,8 +339,7 @@ namespace Barotrauma
constructor: () => new AIObjectiveGoTo(Enemy, character, objectiveManager, repeat: true, getDivingGearIfNeeded: true)
{
AllowGoingOutside = true,
IgnoreIfTargetDead = true,
CheckVisibility = true
IgnoreIfTargetDead = true
},
onAbandon: () =>
{
@@ -347,7 +349,7 @@ namespace Barotrauma
if (followTargetObjective != null && subObjectives.Contains(followTargetObjective))
{
followTargetObjective.CloseEnough =
WeaponComponent is RangedWeapon ? 3 :
WeaponComponent is RangedWeapon ? 300 :
WeaponComponent is MeleeWeapon mw ? mw.Range :
WeaponComponent is RepairTool rt ? rt.Range : 50;
}
@@ -437,7 +439,7 @@ namespace Barotrauma
float squaredDistance = Vector2.DistanceSquared(character.Position, Enemy.Position);
character.CursorPosition = Enemy.Position;
float engageDistance = 500;
if (squaredDistance > engageDistance * engageDistance) { return; }
if (character.CurrentHull != Enemy.CurrentHull && squaredDistance > engageDistance * engageDistance) { return; }
if (!character.CanSeeCharacter(Enemy)) { return; }
if (Weapon.RequireAimToUse)
{
@@ -450,7 +452,7 @@ namespace Barotrauma
isOperatingButtons = door.HasIntegratedButtons || door.Item.GetConnectedComponents<Controller>(true).Any();
}
}
if (!isOperatingButtons && character.SelectedConstruction == null)
if (!isOperatingButtons)
{
character.SetInput(InputType.Aim, false, true);
}
@@ -25,7 +25,6 @@ namespace Barotrauma
public float CloseEnough { get; set; } = 50;
public bool IgnoreIfTargetDead { get; set; }
public bool AllowGoingOutside { get; set; }
public bool CheckVisibility { get; set; }
public ISpatialEntity Target { get; private set; }
@@ -92,11 +91,18 @@ namespace Barotrauma
{
abandon = true;
}
else if (!repeat && waitUntilPathUnreachable < 0)
else if (waitUntilPathUnreachable < 0)
{
if (SteeringManager == PathSteering && PathSteering.CurrentPath != null)
if (SteeringManager == PathSteering && PathSteering.CurrentPath != null && PathSteering.CurrentPath.Unreachable)
{
abandon = PathSteering.CurrentPath.Unreachable;
if (repeat)
{
SteeringManager.Reset();
}
else
{
abandon = true;
}
}
}
if (abandon)
@@ -68,6 +68,12 @@ namespace Barotrauma
{
if (character.CanInteractWith(target.Item, out _, checkLinked: false))
{
// Don't allow to operate an item that someone already operates, unless this objective is an order
if (objectiveManager.CurrentOrder != this && Character.CharacterList.Any(c => c.SelectedConstruction == target.Item && c != character && HumanAIController.IsFriendly(c)))
{
abandon = true;
return;
}
if (character.SelectedConstruction != target.Item)
{
target.Item.TryInteract(character, false, true);
@@ -16,8 +16,8 @@ namespace Barotrauma
private readonly Character targetCharacter;
private AIObjectiveGoTo goToObjective;
private float treatmentTimer;
private Hull safeHull;
public AIObjectiveRescue(Character character, Character targetCharacter, AIObjectiveManager objectiveManager, float priorityModifier = 1)
: base(character, objectiveManager, priorityModifier)
@@ -84,15 +84,21 @@ namespace Barotrauma
{
goToObjective = null;
}
var findSafety = objectiveManager.GetObjective<AIObjectiveFindSafety>();
if (findSafety == null)
if (safeHull == null)
{
// Ensure that we have the find safety objective (should always be the case)
objectiveManager.AddObjective(new AIObjectiveFindSafety(character, objectiveManager));
var findSafety = objectiveManager.GetObjective<AIObjectiveFindSafety>();
if (findSafety == null)
{
// Ensure that we have the find safety objective (should always be the case)
objectiveManager.AddObjective(new AIObjectiveFindSafety(character, objectiveManager));
}
safeHull = findSafety.FindBestHull(HumanAIController.VisibleHulls);
}
if (character.CurrentHull != safeHull)
{
TryAddSubObjective(ref goToObjective, () => new AIObjectiveGoTo(safeHull, character, objectiveManager));
}
TryAddSubObjective(ref goToObjective, () => new AIObjectiveGoTo(findSafety.FindBestHull(HumanAIController.VisibleHulls), character, objectiveManager));
}
return;
}
if (subObjectives.Any()) { return; }