Autopilot waypoint skipping, AI finds and equips diving gear when the sub is flooding, progress on AI welding, equipping items in AIObjectiveGetItem, wire node coordinate bugfixes, EntityGrid.RemoveEntity fix

This commit is contained in:
Regalis11
2015-12-23 00:10:02 +02:00
parent 63f5a501e8
commit c7e7b3909f
35 changed files with 402 additions and 257 deletions
@@ -5,7 +5,6 @@ using FarseerPhysics;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Particles;
namespace Barotrauma.Items.Components
{
@@ -200,23 +199,30 @@ namespace Barotrauma.Items.Components
}
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
}
//if (Character.SecondaryKeyDown.State)
//{
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
// //isActive = true;
//}
//if (Character.SecondaryKeyDown.State)
//{
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
// //isActive = true;
//}
return true;
}
public override void Update(float deltaTime, Camera cam)
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
base.Update(deltaTime, cam);
Gap leak = objective.OperateTarget as Gap;
if (leak == null) return true;
character.CursorPosition = leak.Position;
character.SetInput(InputType.Aim, false, true);
Use(deltaTime, character);
return leak.Open <= 0.0f;
//isActive = true;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
{
if (!IsActive) return;
@@ -411,7 +411,7 @@ namespace Barotrauma.Items.Components
/// <returns>true if the operation was completed</returns>
public virtual bool AIOperate(float deltaTime, Character character, AIObjective objective)
public virtual bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
return false;
}
@@ -16,16 +16,16 @@ namespace Barotrauma.Items.Components
class Controller : ItemComponent
{
//where the limbs of the user should be positioned when using the controller
List<LimbPos> limbPositions;
private List<LimbPos> limbPositions;
Direction dir;
private Direction dir;
//the x-position where the user walks to when using the controller
float userPos;
private float userPos;
Camera cam;
private Camera cam;
Character character;
private Character character;
[HasDefaultValue(0.0f, false)]
public float UserPos
@@ -192,6 +192,7 @@ namespace Barotrauma.Items.Components
{
foreach (Connection connection in connections)
{
if (!connection.IsPower) continue;
foreach (Connection recipient in connection.Recipients)
{
Item it = recipient.Item as Item;
@@ -311,7 +312,7 @@ namespace Barotrauma.Items.Components
new Vector2(10, 40 * (temperature / 10000.0f)), new Color(temperature / 10000.0f, 1.0f - (temperature / 10000.0f), 0.0f, 1.0f), true);
}
public override bool AIOperate(float deltaTime, Character character, AIObjective objective)
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
switch (objective.Option.ToLower())
{
@@ -166,25 +166,25 @@ namespace Barotrauma.Items.Components
{
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
//bool nextVisible = true;
//for (int x = -1; x < 2; x += 2)
//{
// for (int y = -1; y < 2; y += 2)
// {
// Vector2 cornerPos =
// new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
bool nextVisible = true;
for (int x = -1; x < 2; x += 2)
{
for (int y = -1; y < 2; y += 2)
{
Vector2 cornerPos =
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
// cornerPos = ConvertUnits.ToSimUnits(cornerPos*1.2f);
cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.Position);
// if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue;
// nextVisible = false;
// x = 2;
// y = 2;
// }
//}
if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue;
//if (nextVisible) steeringPath.SkipToNextNode();
nextVisible = false;
x = 2;
y = 2;
}
}
if (nextVisible) steeringPath.SkipToNextNode();
autopilotRayCastTimer = AutopilotRayCastInterval;
}
@@ -156,7 +156,7 @@ namespace Barotrauma.Items.Components
voltage = 0.0f;
}
public override bool AIOperate(float deltaTime, Character character, AIObjective objective)
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
RechargeSpeed = maxRechargeSpeed * 0.5f;
@@ -29,9 +29,7 @@ namespace Barotrauma.Items.Components
private List<StatusEffect> effects;
public readonly ushort[] wireId;
private List<Connection> recipients;
public bool IsPower
{
get;
@@ -40,7 +38,17 @@ namespace Barotrauma.Items.Components
public List<Connection> Recipients
{
get { return recipients; }
get
{
List<Connection> recipients = new List<Connection>();
for (int i = 0; i < MaxLinked; i++)
{
if (Wires[i] == null) continue;
Connection recipient = Wires[i].OtherConnection(this);
if (recipient != null) recipients.Add(recipient);
}
return recipients;
}
}
public Item Item
@@ -63,9 +71,7 @@ namespace Barotrauma.Items.Components
//recipient = new Connection[MaxLinked];
Wires = new Wire[MaxLinked];
recipients = new List<Connection>();
IsOutput = (element.Name.ToString() == "output");
Name = ToolBox.GetAttributeString(element, "name", (IsOutput) ? "output" : "input");
@@ -139,13 +145,7 @@ namespace Barotrauma.Items.Components
public void UpdateRecipients()
{
recipients.Clear();
for (int i = 0; i < MaxLinked; i++)
{
if (Wires[i] == null) continue;
Connection recipient = Wires[i].OtherConnection(this);
if (recipient != null) recipients.Add(recipient);
}
}
public void SendSignal(string signal, Item sender, float power)
@@ -180,9 +180,7 @@ namespace Barotrauma.Items.Components
Wires[i].RemoveConnection(this);
Wires[i] = null;
}
recipients.Clear();
}
}
@@ -103,16 +103,16 @@ namespace Barotrauma.Items.Components
if (!addNode) break;
if (Nodes.Count>0&&Nodes[0] == newConnection.Item.Position) break;
if (Nodes.Count > 1 && Nodes[Nodes.Count-1] == newConnection.Item.Position) break;
if (Nodes.Count > 0 && Nodes[0] == newConnection.Item.Position - Submarine.HiddenSubPosition) break;
if (Nodes.Count > 1 && Nodes[Nodes.Count-1] == newConnection.Item.Position - Submarine.HiddenSubPosition) break;
if (i == 0)
{
Nodes.Insert(0, newConnection.Item.Position);
Nodes.Insert(0, newConnection.Item.Position - Submarine.HiddenSubPosition);
}
else
{
Nodes.Add(newConnection.Item.Position);
Nodes.Add(newConnection.Item.Position - Submarine.HiddenSubPosition);
}
break;
@@ -121,8 +121,6 @@ namespace Barotrauma.Items.Components
if (connections[0] != null && connections[1] != null)
{
//List<Vector2> prevNodes = new List<Vector2>(Nodes);
foreach (ItemComponent ic in item.components)
{
if (ic == this) continue;
@@ -130,7 +128,6 @@ namespace Barotrauma.Items.Components
}
if (item.container != null) item.container.RemoveContained(this.item);
item.body.Enabled = false;
IsActive = false;
@@ -182,7 +179,7 @@ namespace Barotrauma.Items.Components
position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
}
newNodePos = RoundNode(item.Position, item.CurrentHull);
newNodePos = RoundNode(item.Position, item.CurrentHull)-Submarine.HiddenSubPosition;
//if (Vector2.Distance(position, nodes[nodes.Count - 1]) > nodeDistance*10)
//{
+1 -1
View File
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
return true;
}
public override bool AIOperate(float deltaTime, Character character, AIObjective objective)
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{
var projectiles = GetLoadedProjectiles();