commit cd504791ebda32f7e9d79ec2ac726058e83b5bf1 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 20:03:46 2019 +0200 Additional server logging for steam auth & desync kicks commit 6efece5e42502c1cdba89d4f4cc91398402f2b25 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 19:46:51 2019 +0200 Fixed server failing to sync clients who join the server after a character has been removed during the round (e.g. eaten, turned into a husk). commit 482c9f87ec715119ad9ad420f25003ac92e666b9 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 19:37:00 2019 +0200 Fixed server-side error messages when clients attempt to use a fabricator. Happened because the server tried to set the required time -text on the fabricator interface based on the controlled character instead of the character using the fabricator. commit 0a21304ee43935364de131d8aba09da8f51e6a47 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 17:30:39 2019 +0200 Fixed AI crew occasionally going outside to fix leaks commit 78fa9382490f3b8d63c2ced9b31551fddf937703 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 16:47:09 2019 +0200 Changed coilgun ammo box category from Machine to Equipment (no machine tab in the store menu, caused errors when trying to find a tab button style) commit 73f4374938a69bbeb9e5c0177bcd2b632fc33c8f Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 16:14:56 2019 +0200 Fixed humanhusk not spawning when a husk-infected human dies. commit 080b04d6d046a3c7659942a0a72a3f1a0aa33f4d Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 15:57:18 2019 +0200 Made coilgun ammo boxes fabricable and purchaseable, coilgun bolts can't be crafted, alien flares can't be purchased. Closes #1027 commit edd46655a853880e03c2f9a32abd92b6429a6c8e Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 15:48:39 2019 +0200 Removed auxiliorizine from the chemical shipment mission (auxiliorizine doesn't exist anymore). commit c19620e1f507b2bda398ab4b8ab8cd7d3ea5af23 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Feb 3 15:46:26 2019 +0200 Removed duplicate line from loading screen tips. Closes #1032 commit e7df25130bfc76c16a08e86d3d42b16eab7cb21d Author: ezjamsen <ezjames.fi@gmail.com> Date: Sun Feb 3 13:01:19 2019 +0200 Halved moloch speeds temporarily until a full balance of enemies is done.
203 lines
7.3 KiB
C#
203 lines
7.3 KiB
C#
using Barotrauma.Items.Components;
|
|
using FarseerPhysics;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
|
|
namespace Barotrauma
|
|
{
|
|
class AIObjectiveGoTo : AIObjective
|
|
{
|
|
private Vector2 targetPos;
|
|
|
|
private bool repeat;
|
|
|
|
//how long until the path to the target is declared unreachable
|
|
private float waitUntilPathUnreachable;
|
|
|
|
private bool getDivingGearIfNeeded;
|
|
|
|
public float CloseEnough = 0.5f;
|
|
|
|
public bool IgnoreIfTargetDead;
|
|
|
|
public bool AllowGoingOutside = false;
|
|
|
|
public override float GetPriority(AIObjectiveManager objectiveManager)
|
|
{
|
|
if (Target != null && Target.Removed) return 0.0f;
|
|
if (IgnoreIfTargetDead && Target is Character character && character.IsDead) return 0.0f;
|
|
|
|
if (objectiveManager.CurrentOrder == this)
|
|
{
|
|
return AIObjectiveManager.OrderPriority;
|
|
}
|
|
|
|
return 1.0f;
|
|
}
|
|
|
|
public override bool CanBeCompleted
|
|
{
|
|
get
|
|
{
|
|
if (Target != null && Target.Removed) return false;
|
|
|
|
if (repeat || waitUntilPathUnreachable > 0.0f) return true;
|
|
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
|
|
|
//path doesn't exist (= hasn't been searched for yet), assume for now that the target is reachable
|
|
if (pathSteering?.CurrentPath == null) return true;
|
|
|
|
if (!AllowGoingOutside && pathSteering.CurrentPath.HasOutdoorsNodes) return false;
|
|
|
|
return !pathSteering.CurrentPath.Unreachable;
|
|
}
|
|
}
|
|
|
|
public Entity Target { get; private set; }
|
|
|
|
public AIObjectiveGoTo(Entity target, Character character, bool repeat = false, bool getDivingGearIfNeeded = true)
|
|
: base (character, "")
|
|
{
|
|
this.Target = target;
|
|
this.repeat = repeat;
|
|
|
|
waitUntilPathUnreachable = 1.0f;
|
|
this.getDivingGearIfNeeded = getDivingGearIfNeeded;
|
|
}
|
|
|
|
|
|
public AIObjectiveGoTo(Vector2 simPos, Character character, bool repeat = false, bool getDivingGearIfNeeded = true)
|
|
: base(character, "")
|
|
{
|
|
this.targetPos = simPos;
|
|
this.repeat = repeat;
|
|
|
|
waitUntilPathUnreachable = 5.0f;
|
|
this.getDivingGearIfNeeded = getDivingGearIfNeeded;
|
|
}
|
|
|
|
protected override void Act(float deltaTime)
|
|
{
|
|
if (Target == character)
|
|
{
|
|
character.AIController.SteeringManager.Reset();
|
|
return;
|
|
}
|
|
|
|
waitUntilPathUnreachable -= deltaTime;
|
|
|
|
if (character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Ladder>() == null)
|
|
{
|
|
character.SelectedConstruction = null;
|
|
}
|
|
|
|
if (Target != null) { character.AIController.SelectTarget(Target.AiTarget); }
|
|
|
|
Vector2 currTargetPos = Vector2.Zero;
|
|
|
|
if (Target == null)
|
|
{
|
|
currTargetPos = targetPos;
|
|
}
|
|
else
|
|
{
|
|
currTargetPos = Target.SimPosition;
|
|
|
|
//if character is inside the sub and target isn't, transform the position
|
|
if (character.Submarine != null && Target.Submarine == null)
|
|
{
|
|
currTargetPos -= character.Submarine.SimPosition;
|
|
}
|
|
}
|
|
|
|
if (Vector2.DistanceSquared(currTargetPos, character.SimPosition) < CloseEnough * CloseEnough)
|
|
{
|
|
character.AIController.SteeringManager.Reset();
|
|
character.AnimController.TargetDir = currTargetPos.X > character.SimPosition.X ? Direction.Right : Direction.Left;
|
|
}
|
|
else
|
|
{
|
|
if (!AllowGoingOutside)
|
|
{
|
|
//if path is up-to-date and contains outdoors nodes, this path is unreachable
|
|
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
|
if (pathSteering.CurrentPath != null &&
|
|
Vector2.Distance(pathSteering.CurrentTarget, currTargetPos) < 1.0f &&
|
|
pathSteering.CurrentPath.HasOutdoorsNodes)
|
|
{
|
|
waitUntilPathUnreachable = 0.0f;
|
|
character.AIController.SteeringManager.Reset();
|
|
return;
|
|
}
|
|
}
|
|
|
|
float normalSpeed = character.AnimController.GetCurrentSpeed(false);
|
|
character.AIController.SteeringManager.SteeringSeek(currTargetPos, normalSpeed);
|
|
if (getDivingGearIfNeeded && Target?.Submarine == null && AllowGoingOutside)
|
|
{
|
|
if (indoorsSteering.CurrentPath == null || indoorsSteering.CurrentPath.Unreachable)
|
|
{
|
|
indoorsSteering.SteeringWander(normalSpeed);
|
|
}
|
|
else if (AllowGoingOutside &&
|
|
getDivingGearIfNeeded &&
|
|
indoorsSteering.CurrentPath != null &&
|
|
indoorsSteering.CurrentPath.HasOutdoorsNodes)
|
|
{
|
|
AddSubObjective(new AIObjectiveFindDivingGear(character, true));
|
|
}
|
|
}
|
|
else if (character.AIController.SteeringManager is IndoorsSteeringManager indoorsSteering)
|
|
{
|
|
if (indoorsSteering.CurrentPath == null || indoorsSteering.CurrentPath.Unreachable)
|
|
{
|
|
indoorsSteering.SteeringWander(normalSpeed);
|
|
}
|
|
else if (AllowGoingOutside &&
|
|
getDivingGearIfNeeded &&
|
|
indoorsSteering.CurrentPath != null &&
|
|
indoorsSteering.CurrentPath.HasOutdoorsNodes)
|
|
{
|
|
AddSubObjective(new AIObjectiveFindDivingGear(character, true));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool IsCompleted()
|
|
{
|
|
if (repeat) return false;
|
|
|
|
bool completed = false;
|
|
|
|
float allowedDistance = 0.5f;
|
|
|
|
if (Target is Item item)
|
|
{
|
|
allowedDistance = Math.Max(ConvertUnits.ToSimUnits(item.InteractDistance), allowedDistance);
|
|
if (item.IsInsideTrigger(character.WorldPosition)) completed = true;
|
|
}
|
|
else if (Target is Character targetCharacter)
|
|
{
|
|
if (character.CanInteractWith(targetCharacter)) completed = true;
|
|
}
|
|
|
|
completed = completed || Vector2.DistanceSquared(Target != null ? Target.SimPosition : targetPos, character.SimPosition) < allowedDistance * allowedDistance;
|
|
|
|
if (completed) character.AIController.SteeringManager.Reset();
|
|
|
|
return completed;
|
|
}
|
|
|
|
public override bool IsDuplicate(AIObjective otherObjective)
|
|
{
|
|
AIObjectiveGoTo objective = otherObjective as AIObjectiveGoTo;
|
|
if (objective == null) return false;
|
|
|
|
if (objective.Target == Target) return true;
|
|
|
|
return (objective.targetPos == targetPos);
|
|
}
|
|
}
|
|
}
|