diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index dfbf37b0e..65b99f715 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -397,6 +397,13 @@
PreserveNewest
+
+ Designer
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
diff --git a/Subsurface/Content/Characters/Watcher/watcher.png b/Subsurface/Content/Characters/Watcher/watcher.png
new file mode 100644
index 000000000..4046c480e
Binary files /dev/null and b/Subsurface/Content/Characters/Watcher/watcher.png differ
diff --git a/Subsurface/Content/Characters/Watcher/watcher.xml b/Subsurface/Content/Characters/Watcher/watcher.xml
new file mode 100644
index 000000000..9101f725a
--- /dev/null
+++ b/Subsurface/Content/Characters/Watcher/watcher.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Subsurface/Content/Items/Fabricators/fabricators.xml b/Subsurface/Content/Items/Fabricators/fabricators.xml
index 88b3c0739..79c7ce3f2 100644
--- a/Subsurface/Content/Items/Fabricators/fabricators.xml
+++ b/Subsurface/Content/Items/Fabricators/fabricators.xml
@@ -15,8 +15,11 @@
-
-
+
+
+
+
+
diff --git a/Subsurface/Content/Items/Fabricators/materials.xml b/Subsurface/Content/Items/Fabricators/materials.xml
index c726c8647..023f9eb70 100644
--- a/Subsurface/Content/Items/Fabricators/materials.xml
+++ b/Subsurface/Content/Items/Fabricators/materials.xml
@@ -6,7 +6,7 @@
Tags="smallitem"
pickdistance="150"
canbepicked="true"
- price="10">
+ price="50">
@@ -22,7 +22,7 @@
pickdistance="150"
spritecolor="0.2,0.35,0.06,1.0"
canbepicked="true"
- price="50">
+ price="100">
@@ -46,6 +46,22 @@
+
+ -
+
+
+
+
+
+
+
-
+ canbepicked="true">
@@ -69,8 +84,7 @@
Tags="smallitem"
pickdistance="150"
spritecolor="1.0,0.7,0.05,1.0"
- canbepicked="true"
- price="50">
+ canbepicked="true">
diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml
index 2601f3a2b..7d0cbfa7f 100644
--- a/Subsurface/Content/Items/Weapons/railgun.xml
+++ b/Subsurface/Content/Items/Weapons/railgun.xml
@@ -68,6 +68,12 @@
pickdistance="200"
price="100">
+
+
+
+
+
+
diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml
index 66b648f1f..3fbace3ac 100644
--- a/Subsurface/Content/Items/Weapons/weapons.xml
+++ b/Subsurface/Content/Items/Weapons/weapons.xml
@@ -29,8 +29,9 @@
price="500"
tags="weapon">
-
+
+
diff --git a/Subsurface/Source/Characters/AI/CrewCommander.cs b/Subsurface/Source/Characters/AI/CrewCommander.cs
index fe7ec86f4..f0c16c399 100644
--- a/Subsurface/Source/Characters/AI/CrewCommander.cs
+++ b/Subsurface/Source/Characters/AI/CrewCommander.cs
@@ -159,18 +159,11 @@ namespace Barotrauma
characterButton.UserData = character;
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
- if (character == Character.Controlled)
- {
- characterButton.CanBeSelected = false;
- characterButton.Color = Color.LightGray * 0.3f;
- }
- else
- {
- characterButton.Color = Color.Black * 0.5f;
- characterButton.HoverColor = Color.LightGray * 0.5f;
- characterButton.SelectedColor = Color.Gold * 0.5f;
- characterButton.OutlineColor = Color.LightGray * 0.8f;
- }
+ characterButton.Color = Character.Controlled == character ? Color.Gold * 0.3f : Color.Black * 0.5f;
+ characterButton.HoverColor = Color.LightGray * 0.5f;
+ characterButton.SelectedColor = Color.Gold * 0.5f;
+ characterButton.OutlineColor = Color.LightGray * 0.8f;
+
string name = character.Info.Name;
if (character.Info.Job != null) name += '\n' + "(" + character.Info.Job.Name + ")";
diff --git a/Subsurface/Source/Characters/AI/EnemyAIController.cs b/Subsurface/Source/Characters/AI/EnemyAIController.cs
index 7460e2c3b..5de5c063b 100644
--- a/Subsurface/Source/Characters/AI/EnemyAIController.cs
+++ b/Subsurface/Source/Characters/AI/EnemyAIController.cs
@@ -16,6 +16,8 @@ namespace Barotrauma
private const float UpdateTargetsInterval = 5.0f;
private const float RaycastInterval = 1.0f;
+
+ private bool attackWhenProvoked;
//the preference to attack a specific type of target (-1.0 - 1.0)
//0.0 = doesn't attack targets of the type
@@ -84,6 +86,8 @@ namespace Barotrauma
sight = ToolBox.GetAttributeFloat(aiElement, "sight", 0.0f);
hearing = ToolBox.GetAttributeFloat(aiElement, "hearing", 0.0f);
+ attackWhenProvoked = ToolBox.GetAttributeBool(aiElement, "attackwhenprovoked", false);
+
steeringManager = new SteeringManager(this);
state = AiState.None;
@@ -286,6 +290,12 @@ namespace Barotrauma
updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f);
coolDownTimer *= 0.1f;
+ if (amount > 1.0f && attackWhenProvoked)
+ {
+ attackHumans = 100.0f;
+ attackRooms = 100.0f;
+ }
+
if (attacker==null || attacker.AiTarget==null) return;
AITargetMemory targetMemory = FindTargetMemory(attacker.AiTarget);
targetMemory.Priority += amount;
@@ -508,11 +518,13 @@ namespace Barotrauma
message.Write(wallAttack);
- if (wallAttack)
- {
- message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10);
- message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10);
- }
+ //if (wallAttack)
+ //{
+ // Vector2 relativeWallAttackPos = wallAttackPos - Submarine.Loaded.SimPosition;
+
+ // message.WriteRangedSingle(MathHelper.Clamp(relativeWallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10);
+ // message.WriteRangedSingle(MathHelper.Clamp(relativeWallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10);
+ //}
//message.Write(Velocity.X);
//message.Write(Velocity.Y);
@@ -542,14 +554,16 @@ namespace Barotrauma
newState = (AiState)(message.ReadByte());
- bool wallAttack = message.ReadBoolean();
+ //bool wallAttack = message.ReadBoolean();
- if (wallAttack)
- {
- newWallAttackPos = new Vector2(
- message.ReadRangedSingle(-50.0f, 50.0f, 10),
- message.ReadRangedSingle(-50.0f, 50.0f, 10));
- }
+ //if (wallAttack)
+ //{
+ // newWallAttackPos = new Vector2(
+ // message.ReadRangedSingle(-50.0f, 50.0f, 10),
+ // message.ReadRangedSingle(-50.0f, 50.0f, 10));
+
+ // newWallAttackPos += Submarine.Loaded.SimPosition;
+ //}
//newVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
@@ -565,7 +579,7 @@ namespace Barotrauma
catch { return; }
- wallAttackPos = newWallAttackPos;
+ //wallAttackPos = newWallAttackPos;
steeringManager.WanderAngle = wanderAngle;
//this.updateTargetsTimer = updateTargetsTimer;
diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs
index 18e4a4a18..e97c1efb8 100644
--- a/Subsurface/Source/Characters/AICharacter.cs
+++ b/Subsurface/Source/Characters/AICharacter.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using FarseerPhysics;
namespace Barotrauma
{
@@ -108,7 +109,9 @@ namespace Barotrauma
message.Write(AnimController.TargetDir == Direction.Right);
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
-
+
+ message.Write(Submarine != null);
+
message.Write(AnimController.RefLimb.SimPosition.X);
message.Write(AnimController.RefLimb.SimPosition.Y);
@@ -177,6 +180,8 @@ namespace Barotrauma
if (sendingTime <= LastNetworkUpdate) return;
+ bool inSub = false;
+
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
try
@@ -185,6 +190,8 @@ namespace Barotrauma
targetMovement.X = message.ReadRangedSingle(-1.0f, 1.0f, 8);
targetMovement.Y = message.ReadRangedSingle(-1.0f, 1.0f, 8);
+ inSub = message.ReadBoolean();
+
pos.X = message.ReadFloat();
pos.Y = message.ReadFloat();
@@ -199,9 +206,19 @@ namespace Barotrauma
AnimController.TargetDir = (targetDir) ? Direction.Right : Direction.Left;
AnimController.TargetMovement = targetMovement;
-
- AnimController.RefLimb.body.TargetPosition = pos;
- AnimController.RefLimb.body.TargetVelocity = vel;
+
+ AnimController.TargetMovement = AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
+
+
+ if (inSub)
+ {
+ Hull newHull = Hull.FindHull(ConvertUnits.ToDisplayUnits(pos), AnimController.CurrentHull, false);
+ if (newHull != null)
+ {
+ AnimController.CurrentHull = newHull;
+ Submarine = newHull.Submarine;
+ }
+ }
LastNetworkUpdate = sendingTime;
return;
diff --git a/Subsurface/Source/Characters/Animation/FishAnimController.cs b/Subsurface/Source/Characters/Animation/FishAnimController.cs
index 333c27fb3..91162eaf5 100644
--- a/Subsurface/Source/Characters/Animation/FishAnimController.cs
+++ b/Subsurface/Source/Characters/Animation/FishAnimController.cs
@@ -88,11 +88,11 @@ namespace Barotrauma
if (flip)
{
//targetDir = (movement.X > 0.0f) ? Direction.Right : Direction.Left;
- if (movement.X > 0.1f && movement.X > Math.Abs(movement.Y)*0.5f)
+ if (targetMovement.X > 0.1f && targetMovement.X > Math.Abs(targetMovement.Y) * 0.5f)
{
TargetDir = Direction.Right;
}
- else if (movement.X < -0.1f && movement.X < -Math.Abs(movement.Y)*0.5f)
+ else if (targetMovement.X < -0.1f && targetMovement.X < -Math.Abs(targetMovement.Y) * 0.5f)
{
TargetDir = Direction.Left;
}
@@ -191,7 +191,7 @@ namespace Barotrauma
for (int i = 0; i < Limbs.Count(); i++)
{
- if (steerForce!=Vector2.Zero)
+ if (steerForce != Vector2.Zero)
Limbs[i].body.ApplyForce(steerForce * Limbs[i].SteerForce * Limbs[i].Mass);
if (Limbs[i].type != LimbType.Torso) continue;
@@ -369,7 +369,7 @@ namespace Barotrauma
}
}
}
-
+
void UpdateDying(float deltaTime)
{
Limb head = GetLimb(LimbType.Head);
@@ -403,20 +403,29 @@ namespace Barotrauma
}
}
+ public override Vector2 EstimateCurrPosition(Vector2 prevPosition, float timePassed)
+ {
+ timePassed = MathHelper.Clamp(timePassed, 0.0f, 1.0f);
+
+ Vector2 currPosition = prevPosition + targetMovement * timePassed;
+
+ return currPosition;
+ }
+
private void Mirror()
{
- float leftX = Limbs[0].SimPosition.X, rightX = Limbs[0].SimPosition.X;
- for (int i = 1; i < Limbs.Count(); i++ )
- {
- if (Limbs[i].SimPosition.X < leftX)
- {
- leftX = Limbs[i].SimPosition.X;
- }
- else if (Limbs[i].SimPosition.X > rightX)
- {
- rightX = Limbs[i].SimPosition.X;
- }
- }
+ //float leftX = Limbs[0].SimPosition.X, rightX = Limbs[0].SimPosition.X;
+ //for (int i = 1; i < Limbs.Count(); i++ )
+ //{
+ // if (Limbs[i].SimPosition.X < leftX)
+ // {
+ // leftX = Limbs[i].SimPosition.X;
+ // }
+ // else if (Limbs[i].SimPosition.X > rightX)
+ // {
+ // rightX = Limbs[i].SimPosition.X;
+ // }
+ //}
float midX = GetCenterOfMass().X;
@@ -424,7 +433,7 @@ namespace Barotrauma
{
Vector2 newPos = new Vector2(midX - (l.SimPosition.X - midX), l.SimPosition.Y);
- if (Submarine.CheckVisibility(l.SimPosition, newPos)!=null)
+ if (Submarine.CheckVisibility(l.SimPosition, newPos) != null)
{
Vector2 diff = newPos - l.SimPosition;
diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs
index 3f79eead1..1ff0a31d0 100644
--- a/Subsurface/Source/Characters/Animation/Ragdoll.cs
+++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs
@@ -38,7 +38,7 @@ namespace Barotrauma
//the movement speed of the ragdoll
public Vector2 movement;
//the target speed towards which movement is interpolated
- private Vector2 targetMovement;
+ protected Vector2 targetMovement;
//a movement vector that overrides targetmovement if trying to steer
//a Character to the position sent by server in multiplayer mode
@@ -782,15 +782,24 @@ namespace Barotrauma
{
if (inWater)
{
- //foreach (Limb limb in Limbs)
- //{
- // //if (limb.body.TargetPosition == Vector2.Zero) continue;
- // limb.body.SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation);
- //}
- correctionMovement =
- Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 8.0f, 0.1f, 8.0f), 0.2f);
+ if (character is AICharacter)
+ {
+ correctionMovement =
+ Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 8.0f, 0.1f, 8.0f), 0.5f);
+ }
+ else
+ {
+ foreach (Limb limb in Limbs)
+ {
+ //if (limb.body.TargetPosition == Vector2.Zero) continue;
+
+ limb.body.SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation);
+ }
+ }
+
+
}
else
{
@@ -809,7 +818,7 @@ namespace Barotrauma
SetPosition(refLimb.body.TargetPosition);
- if (character is AICharacter) SetRotation(refLimb.body.TargetRotation);
+ //if (character is AICharacter) SetRotation(refLimb.body.TargetRotation);
//foreach (Limb limb in Limbs)
//{
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index aaa99fade..0e4a1fe1b 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -32,10 +32,23 @@ namespace Barotrauma
set { controlled = value; }
}
+ private bool enabled;
+
public bool Enabled
{
- get;
- set;
+ get
+ {
+ return enabled;
+ }
+ set
+ {
+ enabled = value;
+
+ foreach (Limb limb in AnimController.Limbs)
+ {
+ limb.body.Enabled = enabled;
+ }
+ }
}
public readonly bool IsNetworkPlayer;
@@ -239,6 +252,13 @@ namespace Barotrauma
}
}
+
+ public float PressureTimer
+ {
+ get;
+ private set;
+ }
+
public float SpeedMultiplier
{
get;
@@ -652,6 +672,9 @@ namespace Barotrauma
private Item FindClosestItem(Vector2 mouseSimPos)
{
Limb torso = AnimController.GetLimb(LimbType.Torso);
+
+ if (torso == null) return null;
+
Vector2 pos = (torso.body.TargetPosition != Vector2.Zero) ? torso.body.TargetPosition : torso.SimPosition;
return Item.FindPickable(pos, selectedConstruction == null ? mouseSimPos : selectedConstruction.SimPosition, AnimController.CurrentHull, selectedItems);
@@ -885,8 +908,19 @@ namespace Barotrauma
if (!protectedFromPressure &&
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 100.0f))
{
- Implode();
- return;
+
+ PressureTimer += ((AnimController.CurrentHull == null) ?
+ 100.0f : AnimController.CurrentHull.LethalPressure) * deltaTime;
+
+ if (PressureTimer >= 100.0f)
+ {
+ Implode();
+ return;
+ }
+ }
+ else
+ {
+ PressureTimer = 0.0f;
}
}
@@ -1503,10 +1537,12 @@ namespace Barotrauma
else
{
cursorPosition = Position + new Vector2(1000.0f, 0.0f) * dir;
+
+ AnimController.TargetDir = dir < 0 ? Direction.Left : Direction.Right;
}
AnimController.RefLimb.body.TargetPosition =
- AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now + message.SenderConnection.RemoteTimeOffset) - sendingTime);
+ AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
LastNetworkUpdate = sendingTime;
diff --git a/Subsurface/Source/Characters/CharacterHUD.cs b/Subsurface/Source/Characters/CharacterHUD.cs
index ce05b96c6..8a29e24b9 100644
--- a/Subsurface/Source/Characters/CharacterHUD.cs
+++ b/Subsurface/Source/Characters/CharacterHUD.cs
@@ -14,8 +14,6 @@ namespace Barotrauma
private static GUIProgressBar drowningBar, healthBar;
- private static float pressureTimer;
-
public static void TakeDamage()
{
healthBar.Flash();
@@ -29,9 +27,6 @@ namespace Barotrauma
if (character.Oxygen < 10.0f) drowningBar.Flash();
}
if (healthBar != null) healthBar.Update(deltaTime);
-
- pressureTimer += ((character.AnimController.CurrentHull == null) ?
- 100.0f : character.AnimController.CurrentHull.LethalPressure)*deltaTime;
}
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam)
@@ -134,7 +129,7 @@ namespace Barotrauma
if (pressureFactor>0.0f)
{
- float indicatorAlpha = ((float)Math.Sin(pressureTimer * 0.1f) + 1.0f) * 0.5f;
+ float indicatorAlpha = ((float)Math.Sin(character.PressureTimer * 0.1f) + 1.0f) * 0.5f;
indicatorAlpha = MathHelper.Clamp(indicatorAlpha, 0.1f, pressureFactor/100.0f);
diff --git a/Subsurface/Source/Items/Components/Machines/Fabricator.cs b/Subsurface/Source/Items/Components/Machines/Fabricator.cs
index b1abfe6a8..d4dfb6855 100644
--- a/Subsurface/Source/Items/Components/Machines/Fabricator.cs
+++ b/Subsurface/Source/Items/Components/Machines/Fabricator.cs
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
{
public readonly ItemPrefab TargetItem;
- public readonly List RequiredItems;
+ public readonly List> RequiredItems;
public readonly float RequiredTime;
@@ -29,14 +29,27 @@ namespace Barotrauma.Items.Components
return;
}
- RequiredItems = new List();
+ RequiredItems = new List>();
string[] requiredItemNames = ToolBox.GetAttributeString(element, "requireditems", "").Split(',');
foreach (string requiredItemName in requiredItemNames)
{
ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLower() == requiredItemName.Trim().ToLower()) as ItemPrefab;
if (requiredItem == null) continue;
- RequiredItems.Add(requiredItem);
+
+ var existing = RequiredItems.Find(r => r.Item1 == requiredItem);
+
+ if (existing == null)
+ {
+
+ RequiredItems.Add(new Tuple(requiredItem, 1));
+ }
+ else
+ {
+ RequiredItems.Remove(existing);
+ RequiredItems.Add(new Tuple(requiredItem, existing.Item2+1));
+ }
+
}
RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f);
@@ -123,9 +136,9 @@ namespace Barotrauma.Items.Components
selectedItemFrame, true);
string text = "Required items:\n";
- foreach (ItemPrefab ip in targetItem.RequiredItems)
+ foreach (Tuple ip in targetItem.RequiredItems)
{
- text += " - " + ip.Name + "\n";
+ text += " - " + ip.Item1.Name + " x"+ip.Item2+"\n";
}
text += "Required time: " + targetItem.RequiredTime + " s";
@@ -234,9 +247,9 @@ namespace Barotrauma.Items.Components
return;
}
- foreach (ItemPrefab ip in fabricatedItem.RequiredItems)
+ foreach (Tuple ip in fabricatedItem.RequiredItems)
{
- var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip);
+ var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip.Item1);
containers[0].Inventory.RemoveItem(requiredItem);
}
@@ -253,9 +266,9 @@ namespace Barotrauma.Items.Components
activateButton.Enabled = true;
ItemContainer container = item.GetComponent();
- foreach (ItemPrefab ip in targetItem.RequiredItems)
+ foreach (Tuple ip in targetItem.RequiredItems)
{
- if (Array.Find(container.Inventory.Items, it => it != null && it.Prefab == ip) != null) continue;
+ if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) continue;
activateButton.Enabled = false;
break;
}
diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs
index 2a6798ae7..f7862c71e 100644
--- a/Subsurface/Source/Items/Components/Machines/Radar.cs
+++ b/Subsurface/Source/Items/Components/Machines/Radar.cs
@@ -45,7 +45,15 @@ namespace Barotrauma.Items.Components
}
}
- //renderTarget = new RenderTarget2D(Game1.CurrGraphicsDevice, GuiFrame.Rect.Width, GuiFrame.Rect.Height);
+ var tickBox = new GUITickBox(new Rectangle(0,0,20,20), "Sonar", Alignment.TopLeft, GuiFrame);
+ tickBox.OnSelected = (GUITickBox box) =>
+ {
+ IsActive = box.Selected;
+ item.NewComponentEvent(this, true, false);
+
+ return true;
+ };
+
}
public override void Update(float deltaTime, Camera cam)
@@ -86,16 +94,12 @@ namespace Barotrauma.Items.Components
{
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
-
+
+ GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return;
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 0, y + 0, 150, 30), "Activate Sonar"))
- {
- IsActive = !IsActive;
- item.NewComponentEvent(this, true, false);
- }
int radius = GuiFrame.Rect.Height / 2 - 30;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs
index 030f0579d..2ac5a2b3b 100644
--- a/Subsurface/Source/Items/Components/Machines/Reactor.cs
+++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs
@@ -154,6 +154,63 @@ namespace Barotrauma.Items.Components
powerPerTemp = 1.0f;
IsActive = true;
+
+ var button = new GUIButton(new Rectangle(410, 70, 40,40), "+", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ ShutDownTemp += 100.0f;
+
+ return true;
+ };
+
+ button = new GUIButton(new Rectangle(460, 70, 40, 40), "-", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ ShutDownTemp -= 100.0f;
+
+ return true;
+ };
+
+ button = new GUIButton(new Rectangle(410, 170, 100, 40), "TURN ON", GUI.Style, GuiFrame);
+ button.OnClicked = ToggleAutoTemp;
+
+ button = new GUIButton(new Rectangle(210, 290, 40, 40), "+", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ FissionRate += 1.0f;
+
+ return true;
+ };
+
+ button = new GUIButton(new Rectangle(210, 340, 40, 40), "-", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ FissionRate -= 1.0f;
+
+ return true;
+ };
+
+ button = new GUIButton(new Rectangle(500, 290, 40, 40), "+", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ CoolingRate += 1.0f;
+
+ return true;
+ };
+
+ button = new GUIButton(new Rectangle(500, 340, 40, 40), "-", GUI.Style, GuiFrame);
+ button.OnPressed = () =>
+ {
+ unsentChanges = true;
+ CoolingRate -= 1.0f;
+
+ return true;
+ };
}
public override void Update(float deltaTime, Camera cam)
@@ -231,7 +288,7 @@ namespace Barotrauma.Items.Components
}
//fission rate can't be lowered below a certain amount if the core is too hot
- FissionRate = Math.Max(fissionRate, heat / 200.0f);
+ //FissionRate = Math.Max(fissionRate, heat / 200.0f);
//the power generated by the reactor is equal to the temperature
currPowerConsumption = -temperature*powerPerTemp;
@@ -372,6 +429,7 @@ namespace Barotrauma.Items.Components
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
+ GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
float xOffset = (graphTimer / (float)updateGraphInterval);
@@ -390,61 +448,32 @@ namespace Barotrauma.Items.Components
new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Yellow);
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 450, y + 80), Color.White);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 110, 40, 40), "+", true))
- {
- unsentChanges = true;
- ShutDownTemp += 100.0f;
- }
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 500, y + 110, 40, 40), "-", true))
- {
- unsentChanges = true;
- ShutDownTemp -= 100.0f;
- }
-
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 210, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
- {
- unsentChanges = true;
- autoTemp = !autoTemp;
- }
-
-
-
+
y += 300;
spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y), Color.White);
DrawGraph(fissionRateGraph, spriteBatch,
new Rectangle(x + 30, y + 30, 200, 100), 100.0f, xOffset, Color.Orange);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 30, 40, 40), "+", true))
- {
- unsentChanges = true;
- FissionRate += 1.0f;
- }
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 80, 40, 40), "-", true))
- {
- unsentChanges = true;
- FissionRate -= 1.0f;
- }
spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 320, y), Color.White);
DrawGraph(coolingRateGraph, spriteBatch,
new Rectangle(x + 320, y + 30, 200, 100), 100.0f, xOffset, Color.LightBlue);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 30, 40, 40), "+", true))
- {
- unsentChanges = true;
- CoolingRate += 1.0f;
- }
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 80, 40, 40), "-", true))
- {
- unsentChanges = true;
- CoolingRate -= 1.0f;
- }
//y = y - 260;
+ }
+ private bool ToggleAutoTemp(GUIButton button, object userdata)
+ {
+ unsentChanges = true;
+ autoTemp = !autoTemp;
+
+ button.Text = autoTemp ? "TURN OFF" : "TURN ON";
+
+ return true;
}
static void UpdateGraph(IList graph, T newValue)
diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs
index 02a5d1bca..c0d43603f 100644
--- a/Subsurface/Source/Items/Components/Machines/Steering.cs
+++ b/Subsurface/Source/Items/Components/Machines/Steering.cs
@@ -72,6 +72,16 @@ namespace Barotrauma.Items.Components
: base(item, element)
{
IsActive = true;
+
+ var tickBox = new GUITickBox(new Rectangle(0,25,20,20), "Autopilot", Alignment.TopLeft, GuiFrame);
+
+ tickBox.OnSelected = (GUITickBox box) =>
+ {
+ AutoPilot = box.Selected;
+ item.NewComponentEvent(this, true, true);
+
+ return true;
+ };
}
public override void Update(float deltaTime, Camera cam)
@@ -116,18 +126,12 @@ namespace Barotrauma.Items.Components
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
+ GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
//GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
-
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
- {
- AutoPilot = !AutoPilot;
-
- item.NewComponentEvent(this, true, true);
- }
-
+
GUI.DrawLine(spriteBatch,
new Vector2(velRect.Center.X,velRect.Center.Y),
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),
diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs
index b5efdea99..3597a90fe 100644
--- a/Subsurface/Source/Map/Gap.cs
+++ b/Subsurface/Source/Map/Gap.cs
@@ -187,7 +187,7 @@ namespace Barotrauma
{
for (int i = 0; i < linkedTo.Count; i++)
{
- if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > WorldRect.Y)
+ if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > rect.Y-rect.Height/2.0f)
{
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y - 10, rect.Width, 10), Color.Green * 0.3f, true);
}
diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs
index eb360136e..0083c1369 100644
--- a/Subsurface/Source/Map/SubmarineBody.cs
+++ b/Subsurface/Source/Map/SubmarineBody.cs
@@ -343,85 +343,97 @@ namespace Barotrauma
if (cell == null)
{
Limb limb = f2.Body.UserData as Limb;
- if (limb!=null)
+ if (limb != null)
{
- if (limb.character.Submarine != null) return false;
+ bool collision = HandleLimbCollision(contact, limb);
- Vector2 normal2;
- FixedArray2 points;
- contact.GetWorldManifold(out normal2, out points);
-
- Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
-
- Hull newHull = Hull.FindHull(targetPos, null);
-
- if (newHull == null) return true;
-
- var gaps = newHull.FindGaps();
-
- bool gapFound = false;
- foreach (Gap gap in gaps)
+ if (collision)
{
- if (gap.isHorizontal)
- {
- if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
- {
- gapFound = true;
- break;
- }
- }
- else
- {
- if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
- {
- gapFound = true;
- break;
- }
- }
+ Vector2 normal = Vector2.Normalize(body.Position - limb.SimPosition);
- //if (Submarine.RectContains(gap.WorldRect, targetPos))
- //{
- // gapFound = true;
- // break;
- //}
+ normal *= limb.Mass/100.0f;
+
+ ApplyImpact(normal, contact);
}
- //var pickedBody = Submarine.PickBody(
- // points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step),
- // points[0] - ConvertUnits.ToSimUnits(submarine.Position), null, Physics.CollisionWall);
-
- if (!gapFound)
- {
-
- return true;
- }
-
- var ragdoll = limb.character.AnimController;
- ragdoll.FindHull();
-
- return false;
-
+ return collision;
}
return true;
}
- Vector2 normal;
- FarseerPhysics.Common.FixedArray2 worldPoints;
- contact.GetWorldManifold(out normal, out worldPoints);
-
- Vector2 lastContactPoint = worldPoints[0];
-
- normal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
-
- float impact = Vector2.Dot(Velocity, -normal);
+ var collisionNormal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
+ ApplyImpact(collisionNormal, contact);
+
//Vector2 u = Vector2.Dot(Velocity, -normal) * normal;
//Vector2 w = (Velocity + u);
//speed = ConvertUnits.ToDisplayUnits(w * (1.0f - Friction) + u * Restitution);
- if (impact < 3.0f) return true;
+ return true;
+ }
+
+ private bool HandleLimbCollision(Contact contact, Limb limb)
+ {
+ if (limb.character.Submarine != null) return false;
+
+ Vector2 normal2;
+ FixedArray2 points;
+ contact.GetWorldManifold(out normal2, out points);
+
+ Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
+
+ Hull newHull = Hull.FindHull(targetPos, null);
+
+ if (newHull == null) return true;
+
+ var gaps = newHull.FindGaps();
+
+ bool gapFound = false;
+ foreach (Gap gap in gaps)
+ {
+ if (gap.isHorizontal)
+ {
+ if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
+ {
+ gapFound = true;
+ break;
+ }
+ }
+ else
+ {
+ if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
+ {
+ gapFound = true;
+ break;
+ }
+ }
+ }
+
+ if (!gapFound) return true;
+
+ var ragdoll = limb.character.AnimController;
+ ragdoll.FindHull();
+
+ return false;
+ }
+
+ private void ApplyImpact(Vector2 normal,Contact contact)
+ {
+ Vector2 tempNormal;
+
+ FarseerPhysics.Common.FixedArray2 worldPoints;
+ contact.GetWorldManifold(out tempNormal, out worldPoints);
+
+
+
+ Vector2 lastContactPoint = worldPoints[0];
+
+ float impact = Vector2.Dot(Velocity, -normal);
+
+ if (impact < 3.0f) return;
+
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, ConvertUnits.ToDisplayUnits(lastContactPoint));
GameMain.GameScreen.Cam.Shake = impact * 2.0f;
@@ -446,7 +458,6 @@ namespace Barotrauma
Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
- return true;
}
}
diff --git a/Subsurface/Source/Map/TransitionCinematic.cs b/Subsurface/Source/Map/TransitionCinematic.cs
index b7af7ef3e..d38c580ca 100644
--- a/Subsurface/Source/Map/TransitionCinematic.cs
+++ b/Subsurface/Source/Map/TransitionCinematic.cs
@@ -73,6 +73,8 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
}
+ GUI.ScreenOverlayColor = Color.TransparentBlack;
+
Running = false;
yield return CoroutineStatus.Success;
diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs
index b26167c47..33f4f05c8 100644
--- a/Subsurface/Source/Networking/GameClient.cs
+++ b/Subsurface/Source/Networking/GameClient.cs
@@ -501,7 +501,7 @@ namespace Barotrauma.Networking
break;
case (byte)PacketTypes.UpdateNetLobby:
- if (gameStarted) continue;
+ //if (gameStarted) continue;
GameMain.NetLobbyScreen.ReadData(inc);
break;
case (byte)PacketTypes.Traitor:
diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo
index 0d40d1604..4179b31a9 100644
Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ