Item UI replacements, fabricator bugfix, randomly spawning artifacts, AI can fix leaks, LimbAttacks do damage once (not each frame for the duration of the attack)

This commit is contained in:
Regalis
2016-01-14 21:06:08 +02:00
parent eb20af622d
commit 0fc085c86d
33 changed files with 340 additions and 123 deletions
@@ -149,7 +149,10 @@ namespace Barotrauma
if (divingGearObjective != null)
{
divingGearObjective.TryComplete(deltaTime);
return divingGearObjective.IsCompleted();
bool isCompleted = divingGearObjective.IsCompleted();
if (isCompleted) divingGearObjective = null;
return isCompleted;
}
return false;
@@ -165,6 +168,10 @@ namespace Barotrauma
if (character.AnimController.CurrentHull == null) return 0.0f;
currenthullSafety = GetHullSafety(character.AnimController.CurrentHull);
priority = 100.0f - currenthullSafety;
if (divingGearObjective != null && !divingGearObjective.IsCompleted()) priority += 20.0f;
return priority;
}
@@ -25,10 +25,12 @@ namespace Barotrauma
public override float GetPriority(Character character)
{
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * leak.Open;
if (leak.Open == 0.0f) return 0.0f;
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f);
float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition);
dist = Math.Max(dist/1000.0f, 1.0f);
dist = Math.Max(dist/100.0f, 1.0f);
return Math.Min(leakSize/dist, 40.0f);
}
@@ -69,7 +71,7 @@ namespace Barotrauma
{
var repairTool = weldingTool.GetComponent<RepairTool>();
if (repairTool == null) return;
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, ""));
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, "", leak));
}
}
@@ -46,7 +46,7 @@ namespace Barotrauma
this.equip = equip;
currSearchIndex = 0;
this.itemName = itemName;
}
@@ -136,7 +136,18 @@ namespace Barotrauma
public override bool IsCompleted()
{
return character.Inventory.FindItem(itemName) != null;
if (itemName!=null)
{
return character.Inventory.FindItem(itemName) != null;
}
else if (targetItem!= null)
{
return character.Inventory.Items.Contains(targetItem);
}
else
{
return false;
}
}
}
}
@@ -16,18 +16,18 @@ namespace Barotrauma
bool repeat;
//how long until the path to the target is declared unreachable
private float waitUntilPathUnreachable;
public override bool CanBeCompleted
{
get
{
if (repeat) return true;
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;
//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);
}
@@ -43,6 +43,8 @@ namespace Barotrauma
{
this.target = target;
this.repeat = repeat;
waitUntilPathUnreachable = 5.0f;
}
@@ -51,17 +53,20 @@ namespace Barotrauma
{
this.targetPos = simPos;
this.repeat = repeat;
waitUntilPathUnreachable = 5.0f;
}
protected override void Act(float deltaTime)
{
{
waitUntilPathUnreachable -= deltaTime;
if (character.SelectedConstruction!=null && character.SelectedConstruction.GetComponent<Ladder>()==null)
{
character.SelectedConstruction = null;
}
if (target!=null) character.AIController.SelectTarget(target.AiTarget);
if (target != null) character.AIController.SelectTarget(target.AiTarget);
Vector2 currTargetPos = Vector2.Zero;
@@ -71,8 +71,15 @@ namespace Barotrauma
}
}
if (character.AnimController.InWater)
{
character.AIController.SteeringManager.SteeringManual(deltaTime, new Vector2(0.0f, 0.5f));
}
else
{
character.AIController.SteeringManager.SteeringWander();
}
character.AIController.SteeringManager.SteeringWander(1.0f);
return;
}
@@ -57,7 +57,7 @@ namespace Barotrauma
foreach (Gap gap in Gap.GapList)
{
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.1f) continue;
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.01f) continue;
AddObjective(new AIObjectiveFixLeak(gap, character));
}