- CrewCommander key can be changed

- Improved logic for teleporting character in/out the sub
- changed Turret.AIOperate to use the new coordinate system
- neutralballastlevel option in steering
- crewmanager UI works properly with different numbers of crew members
- fixed obstructvision "twitching" when moving in/out the sub
- resetting steering velocity when AI is waiting
- GetItem AIObjective ignores items outside the sub
- crew has the "dismissed" order by default
-
This commit is contained in:
Regalis
2016-01-20 00:26:45 +02:00
parent 4dd48d7bf2
commit 6c57c1270c
24 changed files with 213 additions and 74 deletions
@@ -101,6 +101,9 @@ namespace Barotrauma
{
currSearchIndex++;
//don't try to get items from outside the sub
if (Item.ItemList[currSearchIndex].CurrentHull == null) continue;
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;
@@ -59,7 +59,12 @@ namespace Barotrauma
protected override void Act(float deltaTime)
{
if (target == character) return;
if (target == character)
{
character.AIController.SteeringManager.Reset();
return;
}
waitUntilPathUnreachable -= deltaTime;
@@ -116,7 +121,7 @@ namespace Barotrauma
completed = completed || Vector2.Distance(target != null ? target.SimPosition : targetPos, character.SimPosition) < allowedDistance;
if (completed) character.AIController.SteeringManager.SteeringManual(0.0f, -character.AIController.Steering);
if (completed) character.AIController.SteeringManager.Reset();
return completed;
}
@@ -70,6 +70,8 @@ namespace Barotrauma
public void SetOrder(Order order, string option)
{
if (order == null) return;
currentObjective = null;
switch (order.Name.ToLower())
@@ -9,7 +9,7 @@ namespace Barotrauma
{
class AIObjectiveOperateItem : AIObjective
{
private ItemComponent component;
private ItemComponent component, controller;
private Entity operateTarget;
@@ -33,14 +33,14 @@ namespace Barotrauma
public AIObjectiveOperateItem(ItemComponent item, Character character, string option, Entity operateTarget = null, bool useController = false)
:base (character, option)
{
component = item;
this.component = item;
this.operateTarget = operateTarget;
if (useController)
{
var controllers = item.Item.GetConnectedComponents<Controller>();
if (controllers.Any()) component = controllers[0];
if (controllers.Any()) controller = controllers[0];
}
@@ -49,21 +49,23 @@ namespace Barotrauma
protected override void Act(float deltaTime)
{
if (component.CanBeSelected)
ItemComponent target = controller == null ? component : controller;
if (target.CanBeSelected)
{
if (Vector2.Distance(character.Position, component.Item.Position) < component.Item.PickDistance
|| component.Item.IsInsideTrigger(character.WorldPosition))
if (Vector2.Distance(character.Position, target.Item.Position) < target.Item.PickDistance
|| target.Item.IsInsideTrigger(character.WorldPosition))
{
if (character.SelectedConstruction != component.Item && component.CanBeSelected)
if (character.SelectedConstruction != target.Item && target.CanBeSelected)
{
component.Item.Pick(character, false, true);
target.Item.Pick(character, false, true);
}
if (component.AIOperate(deltaTime, character, this)) isCompleted = true;
return;
}
AddSubObjective(new AIObjectiveGoTo(component.Item, character));
AddSubObjective(new AIObjectiveGoTo(target.Item, character));
}
else
{