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:
Binary file not shown.
@@ -42,12 +42,14 @@
|
|||||||
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="704,0,320,400" depth="0.07" origin="0.5,0.5"/>
|
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="704,0,320,400" depth="0.07" origin="0.5,0.5"/>
|
||||||
</limb>
|
</limb>
|
||||||
|
|
||||||
<limb id = "8" width="100" height="450">
|
<limb id = "8" width="100" height="450" impacttolerance="100.0">
|
||||||
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="755,552,137,470" depth="0.08" origin="0.5,0.5"/>
|
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="755,552,137,470" depth="0.08" origin="0.5,0.5"/>
|
||||||
|
<attack type="PinchCW" range="500" duration="0.5" damage="30" stun="0.1" bleedingdamage="3" structuredamage="500" damagetype="slash"/>
|
||||||
</limb>
|
</limb>
|
||||||
|
|
||||||
<limb id = "9" width="100" height="450">
|
<limb id = "9" width="100" height="450" impacttolerance="100.0">
|
||||||
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="892,552,137,470" depth="0.08" origin="0.6,0.5"/>
|
<sprite texture="Content/Characters/Endworm/endworm.png" sourcerect="892,552,137,470" depth="0.08" origin="0.6,0.5"/>
|
||||||
|
<attack type="PinchCCW" range="500" duration="0.5" damage="300" stun="0.1" bleedingdamage="30" structuredamage="500" damagetype="slash"/>
|
||||||
</limb>
|
</limb>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Diving Mask"
|
name="Diving Mask"
|
||||||
Tags="smallitem"
|
Tags="smallitem,diving"
|
||||||
pickdistance="200"
|
pickdistance="200"
|
||||||
price="50">
|
price="50">
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Diving Suit"
|
name="Diving Suit"
|
||||||
|
tags="diving"
|
||||||
pickdistance="200"
|
pickdistance="200"
|
||||||
price="200"
|
price="200"
|
||||||
fireproof="true">
|
fireproof="true">
|
||||||
|
|||||||
@@ -117,9 +117,7 @@ namespace Barotrauma
|
|||||||
public Vector2 TargetPos
|
public Vector2 TargetPos
|
||||||
{
|
{
|
||||||
get { return targetPos; }
|
get { return targetPos; }
|
||||||
set {
|
set { targetPos = value; }
|
||||||
targetPos = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auxiliary function to move the camera
|
// Auxiliary function to move the camera
|
||||||
@@ -150,9 +148,6 @@ namespace Barotrauma
|
|||||||
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
Matrix.CreateScale(new Vector3(interpolatedZoom, interpolatedZoom, 1)) *
|
||||||
viewMatrix;
|
viewMatrix;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sound.CameraPos = new Vector3(WorldViewCenter.X, WorldViewCenter.Y, 0.0f);
|
Sound.CameraPos = new Vector3(WorldViewCenter.X, WorldViewCenter.Y, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +161,7 @@ namespace Barotrauma
|
|||||||
Vector2 moveCam = Vector2.Zero;
|
Vector2 moveCam = Vector2.Zero;
|
||||||
if (targetPos == Vector2.Zero)
|
if (targetPos == Vector2.Zero)
|
||||||
{
|
{
|
||||||
if (GUITextBox.KeyboardDispatcher.Subscriber == null)
|
if (GUIComponent.KeyboardDispatcher.Subscriber == null)
|
||||||
{
|
{
|
||||||
if (PlayerInput.KeyDown(Keys.LeftShift)) moveSpeed *= 2.0f;
|
if (PlayerInput.KeyDown(Keys.LeftShift)) moveSpeed *= 2.0f;
|
||||||
if (PlayerInput.KeyDown(Keys.LeftControl)) moveSpeed *= 0.5f;
|
if (PlayerInput.KeyDown(Keys.LeftControl)) moveSpeed *= 0.5f;
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("updatetargets");
|
|
||||||
UpdateTargets(Character);
|
UpdateTargets(Character);
|
||||||
updateTargetsTimer = UpdateTargetsInterval;
|
updateTargetsTimer = UpdateTargetsInterval;
|
||||||
|
|
||||||
@@ -160,7 +159,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void UpdateAttack(float deltaTime)
|
private void UpdateAttack(float deltaTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (selectedAiTarget == null)
|
if (selectedAiTarget == null)
|
||||||
{
|
{
|
||||||
state = AiState.None;
|
state = AiState.None;
|
||||||
@@ -220,8 +218,6 @@ namespace Barotrauma
|
|||||||
coolDownTimer -= deltaTime;
|
coolDownTimer -= deltaTime;
|
||||||
attackingLimb = null;
|
attackingLimb = null;
|
||||||
|
|
||||||
//System.Diagnostics.Debug.WriteLine("cooldown");
|
|
||||||
|
|
||||||
if (selectedAiTarget.Entity is Hull ||
|
if (selectedAiTarget.Entity is Hull ||
|
||||||
Vector2.Distance(attackPosition, Character.AnimController.Limbs[0].SimPosition) < ConvertUnits.ToSimUnits(500.0f))
|
Vector2.Distance(attackPosition, Character.AnimController.Limbs[0].SimPosition) < ConvertUnits.ToSimUnits(500.0f))
|
||||||
{
|
{
|
||||||
@@ -239,9 +235,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
targetEntity = null;
|
targetEntity = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//check if there's a wall between the target and the Character
|
//check if there's a wall between the target and the Character
|
||||||
Vector2 rayStart = Character.SimPosition;
|
Vector2 rayStart = Character.SimPosition;
|
||||||
Vector2 rayEnd = selectedAiTarget.SimPosition;
|
Vector2 rayEnd = selectedAiTarget.SimPosition;
|
||||||
@@ -329,10 +322,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
limb.soundTimer = Limb.SoundInterval;
|
limb.soundTimer = Limb.SoundInterval;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//limb.body.ApplyTorque(limb.Mass * -20.0f * Character.animController.Dir * dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 diff = attackPosition - limb.SimPosition;
|
Vector2 diff = attackPosition - limb.SimPosition;
|
||||||
if (diff.LengthSquared() > 0.00001f)
|
if (diff.LengthSquared() > 0.00001f)
|
||||||
@@ -363,7 +352,7 @@ namespace Barotrauma
|
|||||||
//sight/hearing range
|
//sight/hearing range
|
||||||
public void UpdateTargets(Character character)
|
public void UpdateTargets(Character character)
|
||||||
{
|
{
|
||||||
if (distanceAccumulator<5.0f && Rand.Range(1,3, false)==1)
|
if (distanceAccumulator<5.0f && Rand.Range(1,3)==1)
|
||||||
{
|
{
|
||||||
selectedAiTarget = null;
|
selectedAiTarget = null;
|
||||||
character.AnimController.TargetMovement = -character.AnimController.TargetMovement;
|
character.AnimController.TargetMovement = -character.AnimController.TargetMovement;
|
||||||
@@ -427,48 +416,29 @@ namespace Barotrauma
|
|||||||
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
|
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
|
||||||
Structure closestStructure = (closestBody == null) ? null : closestBody.UserData as Structure;
|
Structure closestStructure = (closestBody == null) ? null : closestBody.UserData as Structure;
|
||||||
|
|
||||||
//if (targetCharacter != null)
|
if (targetDamageable != null)
|
||||||
//{
|
{
|
||||||
// //if target is a Character that isn't visible, ignore
|
valueModifier = valueModifier / targetDamageable.Health;
|
||||||
// if (closestStructure != null) continue;
|
}
|
||||||
|
else if (closestStructure!=null)
|
||||||
|
{
|
||||||
|
valueModifier = valueModifier / (closestStructure as IDamageable).Health;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
valueModifier = valueModifier / 1000.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// //prefer targets with low health
|
|
||||||
// valueModifier = valueModifier / targetCharacter.Health;
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
if (targetDamageable != null)
|
|
||||||
{
|
|
||||||
valueModifier = valueModifier / targetDamageable.Health;
|
|
||||||
}
|
|
||||||
else if (closestStructure!=null)
|
|
||||||
{
|
|
||||||
valueModifier = valueModifier / (closestStructure as IDamageable).Health;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
valueModifier = valueModifier / 1000.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//float newTargetValue = valueModifier/dist;
|
|
||||||
if (selectedAiTarget == null || Math.Abs(valueModifier) > Math.Abs(targetValue))
|
if (selectedAiTarget == null || Math.Abs(valueModifier) > Math.Abs(targetValue))
|
||||||
{
|
{
|
||||||
selectedAiTarget = target;
|
selectedAiTarget = target;
|
||||||
selectedTargetMemory = targetMemory;
|
selectedTargetMemory = targetMemory;
|
||||||
|
|
||||||
targetValue = valueModifier;
|
targetValue = valueModifier;
|
||||||
Debug.WriteLine(selectedAiTarget.Entity+": "+targetValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//selectedTarget = bestTarget;
|
|
||||||
//selectedTargetMemory = targetMemory;
|
|
||||||
//this.targetValue = bestTargetValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//find the targetMemory that corresponds to some AItarget or create if there isn't one yet
|
//find the targetMemory that corresponds to some AItarget or create if there isn't one yet
|
||||||
|
|||||||
@@ -112,16 +112,16 @@ namespace Barotrauma
|
|||||||
if (pathSteering == null || pathSteering.CurrentPath == null || pathSteering.CurrentPath.CurrentNode==null) return;
|
if (pathSteering == null || pathSteering.CurrentPath == null || pathSteering.CurrentPath.CurrentNode==null) return;
|
||||||
|
|
||||||
GUI.DrawLine(spriteBatch,
|
GUI.DrawLine(spriteBatch,
|
||||||
new Vector2(Character.Position.X, -Character.Position.Y),
|
new Vector2(Character.WorldPosition.X, -Character.WorldPosition.Y),
|
||||||
new Vector2(pathSteering.CurrentPath.CurrentNode.Position.X, -pathSteering.CurrentPath.CurrentNode.Position.Y),
|
new Vector2(pathSteering.CurrentPath.CurrentNode.Position.X+Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.CurrentNode.Position.Y+Submarine.Loaded.Position.Y)),
|
||||||
Color.LightGreen);
|
Color.LightGreen);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 1; i < pathSteering.CurrentPath.Nodes.Count; i++)
|
for (int i = 1; i < pathSteering.CurrentPath.Nodes.Count; i++)
|
||||||
{
|
{
|
||||||
GUI.DrawLine(spriteBatch,
|
GUI.DrawLine(spriteBatch,
|
||||||
new Vector2(pathSteering.CurrentPath.Nodes[i].Position.X, -pathSteering.CurrentPath.Nodes[i].Position.Y),
|
new Vector2(pathSteering.CurrentPath.Nodes[i].Position.X + Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.Nodes[i].Position.Y + Submarine.Loaded.Position.Y)),
|
||||||
new Vector2(pathSteering.CurrentPath.Nodes[i - 1].Position.X, -pathSteering.CurrentPath.Nodes[i-1].Position.Y),
|
new Vector2(pathSteering.CurrentPath.Nodes[i - 1].Position.X + Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.Nodes[i-1].Position.Y + Submarine.Loaded.Position.Y)),
|
||||||
Color.LightGreen);
|
Color.LightGreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ namespace Barotrauma
|
|||||||
protected override Vector2 DoSteeringSeek(Vector2 target, float speed = 1)
|
protected override Vector2 DoSteeringSeek(Vector2 target, float speed = 1)
|
||||||
{
|
{
|
||||||
//find a new path if one hasn't been found yet or the target is different from the current target
|
//find a new path if one hasn't been found yet or the target is different from the current target
|
||||||
if (currentPath == null || Vector2.Distance(target, currentTarget)>1.0f || findPathTimer < -10.0f)
|
if (currentPath == null || Vector2.Distance(target, currentTarget)>1.0f || findPathTimer < -5.0f)
|
||||||
{
|
{
|
||||||
if (findPathTimer > 0.0f) return Vector2.Zero;
|
if (findPathTimer > 0.0f) return Vector2.Zero;
|
||||||
|
|
||||||
currentTarget = target;
|
currentTarget = target;
|
||||||
currentPath = pathFinder.FindPath(host.SimPosition+Rand.Vector(0.2f), target);
|
currentPath = pathFinder.FindPath(host.SimPosition, target);
|
||||||
|
|
||||||
findPathTimer = Rand.Range(1.0f,1.2f);
|
findPathTimer = Rand.Range(1.0f,1.2f);
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual bool CanBeCompleted
|
public virtual bool CanBeCompleted
|
||||||
{
|
{
|
||||||
get { return false; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Option
|
public string Option
|
||||||
@@ -51,7 +51,7 @@ namespace Barotrauma
|
|||||||
/// <param name="character">the character who's trying to achieve the objective</param>
|
/// <param name="character">the character who's trying to achieve the objective</param>
|
||||||
public void TryComplete(float deltaTime)
|
public void TryComplete(float deltaTime)
|
||||||
{
|
{
|
||||||
subObjectives.RemoveAll(s => s.IsCompleted());
|
subObjectives.RemoveAll(s => s.IsCompleted() || !s.CanBeCompleted);
|
||||||
|
|
||||||
foreach (AIObjective objective in subObjectives)
|
foreach (AIObjective objective in subObjectives)
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void AddSubObjective(AIObjective objective)
|
public void AddSubObjective(AIObjective objective)
|
||||||
{
|
{
|
||||||
if (subObjectives.Find(o => o.IsDuplicate(objective)) != null) return;
|
if (subObjectives.Any(o => o.IsDuplicate(objective))) return;
|
||||||
|
|
||||||
subObjectives.Add(objective);
|
subObjectives.Add(objective);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private ItemContainer container;
|
private ItemContainer container;
|
||||||
|
|
||||||
bool canBeCompleted;
|
|
||||||
|
|
||||||
bool isCompleted;
|
bool isCompleted;
|
||||||
|
|
||||||
public bool IgnoreAlreadyContainedItems;
|
public bool IgnoreAlreadyContainedItems;
|
||||||
@@ -26,13 +24,13 @@ namespace Barotrauma
|
|||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
//check if the container has room for more items
|
//check if the container has room for more items
|
||||||
canBeCompleted = false;
|
//canBeCompleted = false;
|
||||||
foreach (Item contained in container.inventory.Items)
|
//foreach (Item contained in container.inventory.Items)
|
||||||
{
|
//{
|
||||||
if (contained != null) continue;
|
// if (contained != null) continue;
|
||||||
canBeCompleted = true;
|
// canBeCompleted = true;
|
||||||
break;
|
// break;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsCompleted()
|
public override bool IsCompleted()
|
||||||
@@ -54,14 +52,28 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vector2.Distance(character.SimPosition, container.Item.SimPosition) > container.Item.PickDistance
|
if (container.Item.inventory == character.Inventory)
|
||||||
&& !container.Item.IsInsideTrigger(character.Position))
|
|
||||||
{
|
{
|
||||||
AddSubObjective(new AIObjectiveGoTo(container.Item, character));
|
var containedItems = container.inventory.Items;
|
||||||
return;
|
//if there's already something in the mask (empty oxygen tank?), drop it
|
||||||
|
var existingItem = containedItems.FirstOrDefault(i => i != null);
|
||||||
|
if (existingItem != null) existingItem.Drop(character);
|
||||||
|
|
||||||
|
character.Inventory.RemoveItem(itemToContain);
|
||||||
|
container.inventory.TryPutItem(itemToContain, null, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Vector2.Distance(character.SimPosition, container.Item.SimPosition) > container.Item.PickDistance
|
||||||
|
&& !container.Item.IsInsideTrigger(character.Position))
|
||||||
|
{
|
||||||
|
AddSubObjective(new AIObjectiveGoTo(container.Item, character));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.Combine(itemToContain);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.Combine(itemToContain);
|
|
||||||
isCompleted = true;
|
isCompleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Barotrauma.Items.Components;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -19,6 +20,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private float searchHullTimer;
|
private float searchHullTimer;
|
||||||
|
|
||||||
|
private AIObjective divingGearObjective;
|
||||||
|
|
||||||
public float? OverrideCurrentHullSafety;
|
public float? OverrideCurrentHullSafety;
|
||||||
|
|
||||||
public AIObjectiveFindSafety(Character character)
|
public AIObjectiveFindSafety(Character character)
|
||||||
@@ -43,6 +46,12 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentHull = character.AnimController.CurrentHull;
|
||||||
|
if (currentHull.Volume / currentHull.FullVolume > 0.5f)
|
||||||
|
{
|
||||||
|
if (!FindDivingGear(deltaTime)) return;
|
||||||
|
}
|
||||||
|
|
||||||
if (searchHullTimer>0.0f)
|
if (searchHullTimer>0.0f)
|
||||||
{
|
{
|
||||||
searchHullTimer -= deltaTime;
|
searchHullTimer -= deltaTime;
|
||||||
@@ -50,6 +59,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
|
||||||
|
|
||||||
Hull bestHull = null;
|
Hull bestHull = null;
|
||||||
@@ -104,6 +115,46 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool FindDivingGear(float deltaTime)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var item = character.Inventory.FindItem("diving");
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
//get a diving mask/suit first
|
||||||
|
if (!(divingGearObjective is AIObjectiveGetItem))
|
||||||
|
{
|
||||||
|
divingGearObjective = new AIObjectiveGetItem(character, "diving", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var containedItems = item.ContainedItems;
|
||||||
|
if (containedItems == null) return true;
|
||||||
|
|
||||||
|
//check if there's an oxygen tank in the mask
|
||||||
|
var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank" && i.Condition > 0.0f);
|
||||||
|
|
||||||
|
if (oxygenTank != null) return true;
|
||||||
|
|
||||||
|
|
||||||
|
if (!(divingGearObjective is AIObjectiveContainItem))
|
||||||
|
{
|
||||||
|
divingGearObjective = new AIObjectiveContainItem(character, "Oxygen Tank", item.GetComponent<ItemContainer>());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (divingGearObjective != null)
|
||||||
|
{
|
||||||
|
divingGearObjective.TryComplete(deltaTime);
|
||||||
|
return divingGearObjective.IsCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool IsDuplicate(AIObjective otherObjective)
|
public override bool IsDuplicate(AIObjective otherObjective)
|
||||||
{
|
{
|
||||||
return (otherObjective is AIObjectiveFindSafety);
|
return (otherObjective is AIObjectiveFindSafety);
|
||||||
@@ -128,7 +179,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
float safety = 100.0f - fireAmount;
|
float safety = 100.0f - fireAmount;
|
||||||
if (waterPercentage > 30.0f) safety -= waterPercentage;
|
|
||||||
|
if (waterPercentage > 30.0f && character.Oxygen<80.0f) safety -= waterPercentage;
|
||||||
if (hull.OxygenPercentage < 30.0f) safety -= (30.0f-hull.OxygenPercentage)*5.0f;
|
if (hull.OxygenPercentage < 30.0f) safety -= (30.0f-hull.OxygenPercentage)*5.0f;
|
||||||
|
|
||||||
return safety;
|
return safety;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Barotrauma.Items.Components;
|
||||||
|
using FarseerPhysics;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -8,17 +10,26 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class AIObjectiveFixLeak : AIObjective
|
class AIObjectiveFixLeak : AIObjective
|
||||||
{
|
{
|
||||||
Gap leak;
|
private Gap leak;
|
||||||
|
|
||||||
|
public Gap Leak
|
||||||
|
{
|
||||||
|
get { return leak; }
|
||||||
|
}
|
||||||
|
|
||||||
public AIObjectiveFixLeak(Gap leak, Character character)
|
public AIObjectiveFixLeak(Gap leak, Character character)
|
||||||
:base (character, "")
|
: base (character, "")
|
||||||
{
|
{
|
||||||
this.leak = leak;
|
this.leak = leak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float GetPriority(Character character)
|
public override float GetPriority(Character character)
|
||||||
{
|
{
|
||||||
return leak.isHorizontal ? leak.Rect.Height * leak.Open : leak.Rect.Width * leak.Open;
|
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * leak.Open;
|
||||||
|
|
||||||
|
float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition);
|
||||||
|
dist = Math.Max(dist/1000.0f, 1.0f);
|
||||||
|
return Math.Min(leakSize/dist, 40.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsDuplicate(AIObjective otherObjective)
|
public override bool IsDuplicate(AIObjective otherObjective)
|
||||||
@@ -34,15 +45,51 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (weldingTool == null)
|
if (weldingTool == null)
|
||||||
{
|
{
|
||||||
subObjectives.Add(new AIObjectiveGetItem(character, "Welding Tool"));
|
subObjectives.Add(new AIObjectiveGetItem(character, "Welding Tool", true));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Vector2.Distance(character.Position, leak.Position)>10.0f)
|
var containedItems = weldingTool.ContainedItems;
|
||||||
|
if (containedItems == null) return;
|
||||||
|
|
||||||
|
var fuelTank = Array.Find(containedItems, i => i.Name == "Welding Fuel Tank" && i.Condition > 0.0f);
|
||||||
|
|
||||||
|
if (fuelTank == null)
|
||||||
{
|
{
|
||||||
subObjectives.Add(new AIObjectiveGoTo(leak.Position,character));
|
AddSubObjective(new AIObjectiveContainItem(character, "Welding Fuel Tank", weldingTool.GetComponent<ItemContainer>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Vector2.Distance(character.Position, leak.Position) > 300.0f)
|
||||||
|
{
|
||||||
|
AddSubObjective(new AIObjectiveGoTo(ConvertUnits.ToSimUnits(GetStandPosition()), character));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var repairTool = weldingTool.GetComponent<RepairTool>();
|
||||||
|
if (repairTool == null) return;
|
||||||
|
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 GetStandPosition()
|
||||||
|
{
|
||||||
|
Vector2 standPos = leak.Position;
|
||||||
|
var hull = leak.linkedTo[0];
|
||||||
|
|
||||||
|
if (hull == null) return standPos;
|
||||||
|
|
||||||
|
if (leak.isHorizontal)
|
||||||
|
{
|
||||||
|
standPos += Vector2.UnitX * Math.Sign(hull.Position.X - leak.Position.X) * leak.Rect.Width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
standPos += Vector2.UnitY * Math.Sign(hull.Position.Y - leak.Position.Y) * leak.Rect.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return standPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Barotrauma.Items.Components;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,17 +19,32 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool IgnoreContainedItems;
|
public bool IgnoreContainedItems;
|
||||||
|
|
||||||
|
private bool equip;
|
||||||
|
|
||||||
public override bool CanBeCompleted
|
public override bool CanBeCompleted
|
||||||
{
|
{
|
||||||
get { return canBeCompleted; }
|
get { return canBeCompleted; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AIObjectiveGetItem(Character character, Item targetItem, bool equip = false)
|
||||||
|
: base(character, "")
|
||||||
|
{
|
||||||
|
canBeCompleted = true;
|
||||||
|
|
||||||
public AIObjectiveGetItem(Character character, string itemName)
|
this.equip = equip;
|
||||||
|
|
||||||
|
currSearchIndex = 0;
|
||||||
|
|
||||||
|
this.targetItem = targetItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AIObjectiveGetItem(Character character, string itemName, bool equip=false)
|
||||||
: base (character, "")
|
: base (character, "")
|
||||||
{
|
{
|
||||||
canBeCompleted = true;
|
canBeCompleted = true;
|
||||||
|
|
||||||
|
this.equip = equip;
|
||||||
|
|
||||||
currSearchIndex = 0;
|
currSearchIndex = 0;
|
||||||
|
|
||||||
this.itemName = itemName;
|
this.itemName = itemName;
|
||||||
@@ -40,32 +56,68 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (Vector2.Distance(character.SimPosition, targetItem.SimPosition) < targetItem.PickDistance)
|
if (Vector2.Distance(character.SimPosition, targetItem.SimPosition) < targetItem.PickDistance)
|
||||||
{
|
{
|
||||||
targetItem.Pick(character, false, true);
|
int targetSlot = -1;
|
||||||
}
|
if (equip)
|
||||||
}
|
{
|
||||||
|
var pickable = targetItem.GetComponent<Pickable>();
|
||||||
|
//check if all the slots required by the item are free
|
||||||
|
foreach (LimbSlot slots in pickable.AllowedSlots)
|
||||||
|
{
|
||||||
|
if (slots.HasFlag(LimbSlot.Any)) continue;
|
||||||
|
|
||||||
|
for (int i = 0; i<character.Inventory.Items.Length; i++)
|
||||||
|
{
|
||||||
|
//slot not needed by the item, continue
|
||||||
|
if (!slots.HasFlag(CharacterInventory.limbSlots[i])) continue;
|
||||||
|
|
||||||
|
targetSlot = i;
|
||||||
|
|
||||||
|
//slot free, continue
|
||||||
|
if (character.Inventory.Items[i] == null) continue;
|
||||||
|
|
||||||
|
//try to move the existing item to LimbSlot.Any and continue if successful
|
||||||
|
if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List<LimbSlot>() { LimbSlot.Any }, false)) continue;
|
||||||
|
|
||||||
|
//if everything else fails, simply drop the existing item
|
||||||
|
character.Inventory.Items[i].Drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetItem.Pick(character, false, true);
|
||||||
|
|
||||||
|
if (targetSlot>-1 && character.Inventory.IsInLimbSlot(targetItem, LimbSlot.Any))
|
||||||
|
{
|
||||||
|
character.Inventory.TryPutItem(targetItem, targetSlot, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (currSearchIndex >= Item.ItemList.Count)
|
|
||||||
{
|
|
||||||
canBeCompleted = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currSearchIndex++;
|
|
||||||
|
|
||||||
if (!Item.ItemList[currSearchIndex].HasTag(itemName) && Item.ItemList[currSearchIndex].Name != itemName) return;
|
for (int i = 0; i<10 && currSearchIndex<Item.ItemList.Count; i++)
|
||||||
if (IgnoreContainedItems && Item.ItemList[currSearchIndex].container != null) return;
|
|
||||||
|
|
||||||
targetItem = Item.ItemList[currSearchIndex];
|
|
||||||
|
|
||||||
Item moveToTarget = targetItem;
|
|
||||||
while (moveToTarget.container != null)
|
|
||||||
{
|
{
|
||||||
moveToTarget = moveToTarget.container;
|
currSearchIndex++;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
targetItem = Item.ItemList[currSearchIndex];
|
||||||
|
|
||||||
|
|
||||||
|
Item moveToTarget = targetItem;
|
||||||
|
while (moveToTarget.container != null)
|
||||||
|
{
|
||||||
|
moveToTarget = moveToTarget.container;
|
||||||
|
}
|
||||||
|
|
||||||
|
subObjectives.Add(new AIObjectiveGoTo(moveToTarget, character));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
subObjectives.Add(new AIObjectiveGoTo(moveToTarget, character));
|
if (currSearchIndex >= Item.ItemList.Count) canBeCompleted = false;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsDuplicate(AIObjective otherObjective)
|
public override bool IsDuplicate(AIObjective otherObjective)
|
||||||
|
|||||||
@@ -49,27 +49,23 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!objectives.Any()) return;
|
if (!objectives.Any()) return;
|
||||||
|
|
||||||
//remove completed objectives
|
//remove completed objectives and ones that can't be completed
|
||||||
objectives = objectives.FindAll(o => !o.IsCompleted());
|
objectives = objectives.FindAll(o => !o.IsCompleted() && o.CanBeCompleted);
|
||||||
|
|
||||||
//sort objectives according to priority
|
//sort objectives according to priority
|
||||||
objectives.Sort((x, y) => y.GetPriority(character).CompareTo(x.GetPriority(character)));
|
objectives.Sort((x, y) => y.GetPriority(character).CompareTo(x.GetPriority(character)));
|
||||||
|
|
||||||
if (character.AnimController.CurrentHull!=null)
|
foreach (Gap gap in Gap.GapList)
|
||||||
{
|
{
|
||||||
var gaps = character.AnimController.CurrentHull.FindGaps();
|
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.1f) continue;
|
||||||
|
|
||||||
foreach (Gap gap in gaps)
|
AddObjective(new AIObjectiveFixLeak(gap, character));
|
||||||
{
|
|
||||||
if (gap.linkedTo.Count > 1) continue;
|
|
||||||
AddObjective(new AIObjectiveFixLeak(gap, character));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoCurrentObjective(float deltaTime)
|
public void DoCurrentObjective(float deltaTime)
|
||||||
{
|
{
|
||||||
if (currentObjective != null && (!objectives.Any() || objectives[0].GetPriority(character)<OrderPriority))
|
if (currentObjective != null && (!objectives.Any() || objectives[0].GetPriority(character) < OrderPriority))
|
||||||
{
|
{
|
||||||
currentObjective.TryComplete(deltaTime);
|
currentObjective.TryComplete(deltaTime);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,39 +9,69 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class AIObjectiveOperateItem : AIObjective
|
class AIObjectiveOperateItem : AIObjective
|
||||||
{
|
{
|
||||||
private ItemComponent targetItem;
|
private ItemComponent component;
|
||||||
private ItemComponent itemController;
|
|
||||||
|
private Entity operateTarget;
|
||||||
|
|
||||||
private bool isCompleted;
|
private bool isCompleted;
|
||||||
|
|
||||||
|
private bool canBeCompleted;
|
||||||
|
|
||||||
|
public override bool CanBeCompleted
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return canBeCompleted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public AIObjectiveOperateItem(ItemComponent item, Character character, string option)
|
public Entity OperateTarget
|
||||||
|
{
|
||||||
|
get { return operateTarget; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public AIObjectiveOperateItem(ItemComponent item, Character character, string option, Entity operateTarget = null)
|
||||||
:base (character, option)
|
:base (character, option)
|
||||||
{
|
{
|
||||||
targetItem = item;
|
component = item;
|
||||||
|
|
||||||
|
this.operateTarget = operateTarget;
|
||||||
|
|
||||||
var controllers = item.Item.GetConnectedComponents<Controller>();
|
var controllers = item.Item.GetConnectedComponents<Controller>();
|
||||||
if (controllers.Any()) itemController = controllers[0];
|
if (controllers.Any()) component = controllers[0];
|
||||||
|
|
||||||
|
canBeCompleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Act(float deltaTime)
|
protected override void Act(float deltaTime)
|
||||||
{
|
{
|
||||||
ItemComponent target = itemController == null ? targetItem: itemController;
|
if (component.CanBeSelected)
|
||||||
|
|
||||||
if (Vector2.Distance(character.SimPosition, target.Item.SimPosition) < target.Item.PickDistance
|
|
||||||
|| target.Item.IsInsideTrigger(character.WorldPosition))
|
|
||||||
{
|
{
|
||||||
if (character.SelectedConstruction != target.Item && target.CanBeSelected)
|
if (Vector2.Distance(character.SimPosition, component.Item.SimPosition) < component.Item.PickDistance
|
||||||
|
|| component.Item.IsInsideTrigger(character.WorldPosition))
|
||||||
{
|
{
|
||||||
target.Item.Pick(character, false, true);
|
if (character.SelectedConstruction != component.Item && component.CanBeSelected)
|
||||||
|
{
|
||||||
|
component.Item.Pick(character, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.AIOperate(deltaTime, character, this)) isCompleted = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetItem.AIOperate(deltaTime, character, this)) isCompleted = true;
|
AddSubObjective(new AIObjectiveGoTo(component.Item, character));
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!character.Inventory.Items.Contains(component.Item))
|
||||||
|
{
|
||||||
|
AddSubObjective(new AIObjectiveGetItem(character, component.Item, true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (component.AIOperate(deltaTime, character, this)) isCompleted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subObjectives.Add(new AIObjectiveGoTo(target.Item, character));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsCompleted()
|
public override bool IsCompleted()
|
||||||
@@ -54,7 +84,7 @@ namespace Barotrauma
|
|||||||
AIObjectiveOperateItem operateItem = otherObjective as AIObjectiveOperateItem;
|
AIObjectiveOperateItem operateItem = otherObjective as AIObjectiveOperateItem;
|
||||||
if (operateItem == null) return false;
|
if (operateItem == null) return false;
|
||||||
|
|
||||||
return (operateItem.targetItem == targetItem);
|
return (operateItem.component == component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,26 +19,6 @@ namespace Barotrauma
|
|||||||
get { return aiController; }
|
get { return aiController; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//public AICharacter(string file) : this(file, Vector2.Zero, null)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public AICharacter(string file, Vector2 position)
|
|
||||||
// : this(file, position, null)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public AICharacter(CharacterInfo characterInfo, WayPoint spawnPoint, bool isNetworkPlayer = false)
|
|
||||||
// : this(characterInfo.File, spawnPoint.SimPosition, characterInfo, isNetworkPlayer)
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public AICharacter(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false)
|
|
||||||
// : this(characterInfo.File, position, characterInfo, isNetworkPlayer)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
public AICharacter(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
public AICharacter(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
||||||
: base(file, position, characterInfo, isNetworkPlayer)
|
: base(file, position, characterInfo, isNetworkPlayer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -562,6 +562,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
CurrentHull = newHull;
|
CurrentHull = newHull;
|
||||||
|
|
||||||
|
character.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||||
|
|
||||||
|
|
||||||
UpdateCollisionCategories();
|
UpdateCollisionCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -866,8 +866,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
||||||
Submarine = AnimController.CurrentHull == null ? null : Submarine.Loaded;
|
|
||||||
|
|
||||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||||
|
|
||||||
float dist = Vector2.Distance(cam.WorldViewCenter, WorldPosition);
|
float dist = Vector2.Distance(cam.WorldViewCenter, WorldPosition);
|
||||||
@@ -1125,13 +1123,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
timer += 1.0f / 60.0f;
|
timer += 1.0f / 60.0f;
|
||||||
|
|
||||||
if (Character.controlled == this)
|
if (controlled == this)
|
||||||
{
|
{
|
||||||
if (cam != null)
|
if (cam != null) cam.OffsetAmount = 0.0f;
|
||||||
{
|
|
||||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
|
||||||
cam.OffsetAmount = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration);
|
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration);
|
||||||
}
|
}
|
||||||
@@ -1139,7 +1133,7 @@ namespace Barotrauma
|
|||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Character.Controlled == this)
|
while (controlled == this)
|
||||||
{
|
{
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
}
|
}
|
||||||
@@ -1381,7 +1375,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
data = causeOfDeath;
|
data = causeOfDeath;
|
||||||
|
|
||||||
if (causeOfDeath==CauseOfDeath.Pressure)
|
if (causeOfDeath == CauseOfDeath.Pressure)
|
||||||
{
|
{
|
||||||
Implode(true);
|
Implode(true);
|
||||||
}
|
}
|
||||||
@@ -1525,13 +1519,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (controlled == this) controlled = null;
|
if (controlled == this) controlled = null;
|
||||||
|
|
||||||
if (GameMain.Client!=null && GameMain.Client.Character == this) GameMain.Client.Character = null;
|
if (GameMain.Client != null && GameMain.Client.Character == this) GameMain.Client.Character = null;
|
||||||
|
|
||||||
if (aiTarget != null)
|
if (aiTarget != null) aiTarget.Remove();
|
||||||
aiTarget.Remove();
|
|
||||||
|
|
||||||
if (AnimController!=null)
|
if (AnimController!=null) AnimController.Remove();
|
||||||
AnimController.Remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private Character character;
|
private Character character;
|
||||||
|
|
||||||
private static LimbSlot[] limbSlots = new LimbSlot[] {
|
public static LimbSlot[] limbSlots = new LimbSlot[] {
|
||||||
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand,
|
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand,
|
||||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any,
|
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any,
|
||||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any};
|
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any};
|
||||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < Items.Length; i++)
|
for (int i = 0; i < Items.Length; i++)
|
||||||
{
|
{
|
||||||
if ( limbSlots[i] == limbSlot) return i;
|
if (limbSlots[i] == limbSlot) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using FarseerPhysics;
|
|||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Barotrauma.Particles;
|
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -200,21 +199,28 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
|
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
|
||||||
}
|
}
|
||||||
//if (Character.SecondaryKeyDown.State)
|
//if (Character.SecondaryKeyDown.State)
|
||||||
//{
|
//{
|
||||||
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
|
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
|
||||||
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
|
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
|
||||||
// //isActive = true;
|
// //isActive = true;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return 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)
|
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
|
|
||||||
/// <returns>true if the operation was completed</returns>
|
/// <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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,16 @@ namespace Barotrauma.Items.Components
|
|||||||
class Controller : ItemComponent
|
class Controller : ItemComponent
|
||||||
{
|
{
|
||||||
//where the limbs of the user should be positioned when using the controller
|
//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
|
//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)]
|
[HasDefaultValue(0.0f, false)]
|
||||||
public float UserPos
|
public float UserPos
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
foreach (Connection connection in connections)
|
foreach (Connection connection in connections)
|
||||||
{
|
{
|
||||||
|
if (!connection.IsPower) continue;
|
||||||
foreach (Connection recipient in connection.Recipients)
|
foreach (Connection recipient in connection.Recipients)
|
||||||
{
|
{
|
||||||
Item it = recipient.Item as Item;
|
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);
|
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())
|
switch (objective.Option.ToLower())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -166,25 +166,25 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
|
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
|
||||||
|
|
||||||
//bool nextVisible = true;
|
bool nextVisible = true;
|
||||||
//for (int x = -1; x < 2; x += 2)
|
for (int x = -1; x < 2; x += 2)
|
||||||
//{
|
{
|
||||||
// for (int y = -1; y < 2; y += 2)
|
for (int y = -1; y < 2; y += 2)
|
||||||
// {
|
{
|
||||||
// Vector2 cornerPos =
|
Vector2 cornerPos =
|
||||||
// new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
|
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;
|
if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue;
|
||||||
|
|
||||||
// nextVisible = false;
|
nextVisible = false;
|
||||||
// x = 2;
|
x = 2;
|
||||||
// y = 2;
|
y = 2;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//if (nextVisible) steeringPath.SkipToNextNode();
|
if (nextVisible) steeringPath.SkipToNextNode();
|
||||||
|
|
||||||
autopilotRayCastTimer = AutopilotRayCastInterval;
|
autopilotRayCastTimer = AutopilotRayCastInterval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace Barotrauma.Items.Components
|
|||||||
voltage = 0.0f;
|
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;
|
RechargeSpeed = maxRechargeSpeed * 0.5f;
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public readonly ushort[] wireId;
|
public readonly ushort[] wireId;
|
||||||
|
|
||||||
private List<Connection> recipients;
|
|
||||||
|
|
||||||
public bool IsPower
|
public bool IsPower
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -40,7 +38,17 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public List<Connection> Recipients
|
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
|
public Item Item
|
||||||
@@ -64,8 +72,6 @@ namespace Barotrauma.Items.Components
|
|||||||
//recipient = new Connection[MaxLinked];
|
//recipient = new Connection[MaxLinked];
|
||||||
Wires = new Wire[MaxLinked];
|
Wires = new Wire[MaxLinked];
|
||||||
|
|
||||||
recipients = new List<Connection>();
|
|
||||||
|
|
||||||
IsOutput = (element.Name.ToString() == "output");
|
IsOutput = (element.Name.ToString() == "output");
|
||||||
Name = ToolBox.GetAttributeString(element, "name", (IsOutput) ? "output" : "input");
|
Name = ToolBox.GetAttributeString(element, "name", (IsOutput) ? "output" : "input");
|
||||||
|
|
||||||
@@ -139,13 +145,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public void UpdateRecipients()
|
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)
|
public void SendSignal(string signal, Item sender, float power)
|
||||||
@@ -181,8 +181,6 @@ namespace Barotrauma.Items.Components
|
|||||||
Wires[i].RemoveConnection(this);
|
Wires[i].RemoveConnection(this);
|
||||||
Wires[i] = null;
|
Wires[i] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
recipients.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -103,16 +103,16 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (!addNode) break;
|
if (!addNode) break;
|
||||||
|
|
||||||
if (Nodes.Count>0&&Nodes[0] == 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) break;
|
if (Nodes.Count > 1 && Nodes[Nodes.Count-1] == newConnection.Item.Position - Submarine.HiddenSubPosition) break;
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
Nodes.Insert(0, newConnection.Item.Position);
|
Nodes.Insert(0, newConnection.Item.Position - Submarine.HiddenSubPosition);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Nodes.Add(newConnection.Item.Position);
|
Nodes.Add(newConnection.Item.Position - Submarine.HiddenSubPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -121,8 +121,6 @@ namespace Barotrauma.Items.Components
|
|||||||
if (connections[0] != null && connections[1] != null)
|
if (connections[0] != null && connections[1] != null)
|
||||||
{
|
{
|
||||||
//List<Vector2> prevNodes = new List<Vector2>(Nodes);
|
//List<Vector2> prevNodes = new List<Vector2>(Nodes);
|
||||||
|
|
||||||
|
|
||||||
foreach (ItemComponent ic in item.components)
|
foreach (ItemComponent ic in item.components)
|
||||||
{
|
{
|
||||||
if (ic == this) continue;
|
if (ic == this) continue;
|
||||||
@@ -130,7 +128,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
if (item.container != null) item.container.RemoveContained(this.item);
|
if (item.container != null) item.container.RemoveContained(this.item);
|
||||||
|
|
||||||
|
|
||||||
item.body.Enabled = false;
|
item.body.Enabled = false;
|
||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
@@ -182,7 +179,7 @@ namespace Barotrauma.Items.Components
|
|||||||
position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
|
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)
|
//if (Vector2.Distance(position, nodes[nodes.Count - 1]) > nodeDistance*10)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
|
|||||||
return true;
|
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();
|
var projectiles = GetLoadedProjectiles();
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (Owner == null) return;
|
if (Owner == null) return;
|
||||||
|
|
||||||
if (item.inventory != null && removeItem)
|
if (removeItem)
|
||||||
{
|
{
|
||||||
item.Drop(null, false);
|
item.Drop(null, false);
|
||||||
if (item.inventory != null) item.inventory.RemoveItem(item);
|
if (item.inventory != null) item.inventory.RemoveItem(item);
|
||||||
@@ -268,7 +268,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!isSubSlot && selectedSlot == -1)
|
if (!isSubSlot && selectedSlot == -1)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("DSFG");
|
|
||||||
selectedSlot = slotIndex;
|
selectedSlot = slotIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +283,7 @@ namespace Barotrauma
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
System.Diagnostics.Debug.Assert(slotIndex >= 0 && slotIndex < Items.Length);
|
System.Diagnostics.Debug.Assert(slotIndex >= 0 && slotIndex < Items.Length);
|
||||||
#else
|
#else
|
||||||
if (slotIndex<0 || slotIndex>=Items.Length) return;
|
if (slotIndex < 0 || slotIndex >= Items.Length) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5,
|
Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5,
|
||||||
@@ -293,9 +292,7 @@ namespace Barotrauma
|
|||||||
Rectangle subRect = rect;
|
Rectangle subRect = rect;
|
||||||
subRect.Height = 40;
|
subRect.Height = 40;
|
||||||
|
|
||||||
|
|
||||||
selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1;
|
selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1;
|
||||||
System.Diagnostics.Debug.WriteLine(selectedSlot);
|
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, containerRect, Color.Black * 0.8f, true);
|
GUI.DrawRectangle(spriteBatch, containerRect, Color.Black * 0.8f, true);
|
||||||
GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
|
GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void RemoveEntity(MapEntity entity)
|
public void RemoveEntity(MapEntity entity)
|
||||||
{
|
{
|
||||||
for (int x = 0; x <= entities.GetLength(0); x++)
|
for (int x = 0; x < entities.GetLength(0); x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y <= entities.GetLength(1); y++)
|
for (int y = 0; y < entities.GetLength(1); y++)
|
||||||
{
|
{
|
||||||
if (entities[x,y].Contains(entity)) entities[x, y].Remove(entity);
|
if (entities[x,y].Contains(entity)) entities[x, y].Remove(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,14 @@ namespace Barotrauma
|
|||||||
get { return flowTargetHull; }
|
get { return flowTargetHull; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRoomToRoom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return linkedTo.Count == 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Gap(Rectangle newRect, Submarine submarine)
|
public Gap(Rectangle newRect, Submarine submarine)
|
||||||
: this(newRect, newRect.Width < newRect.Height, submarine)
|
: this(newRect, newRect.Width < newRect.Height, submarine)
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@@ -503,7 +503,8 @@ namespace Barotrauma
|
|||||||
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess;
|
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = entityGrid.GetEntities(useWorldCoordinates ? position-Submarine.Loaded.Position : position);
|
var entities = entityGrid.GetEntities(
|
||||||
|
useWorldCoordinates && Submarine.Loaded!=null ? position-Submarine.Loaded.Position : position);
|
||||||
|
|
||||||
foreach (Hull hull in entities)
|
foreach (Hull hull in entities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
for (int side = 0; side < 2; side++)
|
for (int side = 0; side < 2; side++)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].BodyVertices);
|
graphicsDevice.SetVertexBuffer(level.WrappingWalls[side, i].BodyVertices);
|
||||||
|
|||||||
@@ -257,8 +257,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static Vector2 VectorToWorldGrid(Vector2 position)
|
public static Vector2 VectorToWorldGrid(Vector2 position)
|
||||||
{
|
{
|
||||||
position.X = (float)Math.Floor(Convert.ToDouble(position.X / GridSize.X)) * GridSize.X;
|
position.X = (float)Math.Floor(position.X / GridSize.X) * GridSize.X;
|
||||||
position.Y = (float)Math.Ceiling(Convert.ToDouble(position.Y / GridSize.Y)) * GridSize.Y;
|
position.Y = (float)Math.Ceiling(position.Y / GridSize.Y) * GridSize.Y;
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
@@ -329,6 +329,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
lastPickedPosition = rayStart + (rayEnd - rayStart) * closestFraction;
|
lastPickedPosition = rayStart + (rayEnd - rayStart) * closestFraction;
|
||||||
lastPickedFraction = closestFraction;
|
lastPickedFraction = closestFraction;
|
||||||
|
|
||||||
return closestBody;
|
return closestBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,15 +330,19 @@ namespace Barotrauma
|
|||||||
if (cell == null)
|
if (cell == null)
|
||||||
{
|
{
|
||||||
Limb limb = f2.Body.UserData as Limb;
|
Limb limb = f2.Body.UserData as Limb;
|
||||||
if (limb!=null && limb.character.Submarine==null)
|
if (limb!=null)
|
||||||
{
|
{
|
||||||
|
if (limb.character.Submarine != null) return false;
|
||||||
|
|
||||||
Vector2 normal2;
|
Vector2 normal2;
|
||||||
FixedArray2<Vector2> points;
|
FixedArray2<Vector2> points;
|
||||||
contact.GetWorldManifold(out normal2, out points);
|
contact.GetWorldManifold(out normal2, out points);
|
||||||
|
|
||||||
if (Submarine.PickBody(
|
var pickedBody = Submarine.PickBody(
|
||||||
points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step) + normal2,
|
points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step),
|
||||||
points[0] - ConvertUnits.ToSimUnits(submarine.Position) - normal2, null, Physics.CollisionWall) != null)
|
points[0] - ConvertUnits.ToSimUnits(submarine.Position), null, Physics.CollisionWall);
|
||||||
|
|
||||||
|
if (pickedBody != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -421,7 +421,6 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (inc.MessageType != NetIncomingMessageType.Data) continue;
|
if (inc.MessageType != NetIncomingMessageType.Data) continue;
|
||||||
|
|
||||||
//todo: exception handling
|
|
||||||
byte packetType = inc.ReadByte();
|
byte packetType = inc.ReadByte();
|
||||||
|
|
||||||
if (packetType == (byte)PacketTypes.ReliableMessage)
|
if (packetType == (byte)PacketTypes.ReliableMessage)
|
||||||
@@ -522,7 +521,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private IEnumerable<object> StartGame(NetIncomingMessage inc)
|
private IEnumerable<object> StartGame(NetIncomingMessage inc)
|
||||||
{
|
{
|
||||||
if (this.Character != null) Character.Remove();
|
if (Character != null) Character.Remove();
|
||||||
|
|
||||||
int seed = inc.ReadInt32();
|
int seed = inc.ReadInt32();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user