diff --git a/Farseer Physics Engine 3.5/Collision/Collision.cs b/Farseer Physics Engine 3.5/Collision/Collision.cs
index 287d58687..27d429a7c 100644
--- a/Farseer Physics Engine 3.5/Collision/Collision.cs
+++ b/Farseer Physics Engine 3.5/Collision/Collision.cs
@@ -434,16 +434,13 @@ namespace FarseerPhysics.Collision
/// The first AABB.
/// The second AABB.
/// True if they are overlapping.
+
public static bool TestOverlap(ref AABB a, ref AABB b)
{
- Vector2 d1 = b.LowerBound - a.UpperBound;
- Vector2 d2 = a.LowerBound - b.UpperBound;
-
- if (d1.X > 0.0f || d1.Y > 0.0f)
- return false;
-
- if (d2.X > 0.0f || d2.Y > 0.0f)
- return false;
+ if (b.LowerBound.X - a.UpperBound.X > 0.0f ||
+ b.LowerBound.Y - a.UpperBound.Y > 0.0f ||
+ a.LowerBound.X - b.UpperBound.X > 0.0f ||
+ a.LowerBound.Y - b.UpperBound.Y > 0.0f) return false;
return true;
}
diff --git a/Farseer Physics Engine 3.5/Common/Math.cs b/Farseer Physics Engine 3.5/Common/Math.cs
index 766212f19..56df666a1 100644
--- a/Farseer Physics Engine 3.5/Common/Math.cs
+++ b/Farseer Physics Engine 3.5/Common/Math.cs
@@ -77,10 +77,9 @@ namespace FarseerPhysics.Common
public static Vector2 Mul(ref Transform T, ref Vector2 v)
{
- float x = (T.q.c * v.X - T.q.s * v.Y) + T.p.X;
- float y = (T.q.s * v.X + T.q.c * v.Y) + T.p.Y;
-
- return new Vector2(x, y);
+ return new Vector2(
+ (T.q.c * v.X - T.q.s * v.Y) + T.p.X,
+ (T.q.s * v.X + T.q.c * v.Y) + T.p.Y);
}
public static Vector2 MulT(ref Mat22 A, Vector2 v)
@@ -102,10 +101,8 @@ namespace FarseerPhysics.Common
{
float px = v.X - T.p.X;
float py = v.Y - T.p.Y;
- float x = (T.q.c * px + T.q.s * py);
- float y = (-T.q.s * px + T.q.c * py);
- return new Vector2(x, y);
+ return new Vector2(T.q.c * px + T.q.s * py, -T.q.s * px + T.q.c * py);
}
// A^T * B
diff --git a/Farseer Physics Engine 3.5/Settings.cs b/Farseer Physics Engine 3.5/Settings.cs
index 6968d46ee..51a3dd7f5 100644
--- a/Farseer Physics Engine 3.5/Settings.cs
+++ b/Farseer Physics Engine 3.5/Settings.cs
@@ -47,7 +47,7 @@ namespace FarseerPhysics
/// NOTE: If you are using a debug view that shows performance counters,
/// you might want to enable this.
///
- public const bool EnableDiagnostics = true;
+ public const bool EnableDiagnostics = false;
///
/// Set this to true to skip sanity checks in the engine. This will speed up the
diff --git a/Subsurface/Content/Characters/Crawler/crawler.xml b/Subsurface/Content/Characters/Crawler/crawler.xml
index 4c07bf290..38b7e8b3a 100644
--- a/Subsurface/Content/Characters/Crawler/crawler.xml
+++ b/Subsurface/Content/Characters/Crawler/crawler.xml
@@ -9,8 +9,7 @@
@@ -37,7 +36,7 @@
-
+
@@ -45,7 +44,7 @@
-
+
@@ -53,7 +52,7 @@
-
+
diff --git a/Subsurface/Content/Characters/Mantis/mantis.xml b/Subsurface/Content/Characters/Mantis/mantis.xml
index ec41ab048..e6101c656 100644
--- a/Subsurface/Content/Characters/Mantis/mantis.xml
+++ b/Subsurface/Content/Characters/Mantis/mantis.xml
@@ -1,20 +1,23 @@
-
+
+
+
+
+
-
-
+
+
@@ -41,43 +44,43 @@
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml
index fe9db5a6a..06e93d84e 100644
--- a/Subsurface/Content/Items/Weapons/railgun.xml
+++ b/Subsurface/Content/Items/Weapons/railgun.xml
@@ -2,7 +2,7 @@
-
@@ -11,7 +11,9 @@
-
+
+
+
diff --git a/Subsurface/Content/Particles/ParticlePrefabs.xml b/Subsurface/Content/Particles/ParticlePrefabs.xml
index 12807219e..ed5624623 100644
--- a/Subsurface/Content/Particles/ParticlePrefabs.xml
+++ b/Subsurface/Content/Particles/ParticlePrefabs.xml
@@ -72,19 +72,45 @@
+
+
+
+
+
+
+
+
-
+
-
+
0)
+ if (cells.Count > 0)
{
-
+
foreach (Voronoi2.VoronoiCell cell in cells)
{
obstacleDiff += cell.Center - position;
}
- obstacleDiff = Vector2.Normalize(obstacleDiff)*prefab.Speed;
+ obstacleDiff = Vector2.Normalize(obstacleDiff) * prefab.Speed;
}
}
@@ -141,7 +141,9 @@ namespace Subsurface
if (velocity.X < 0.0f) rotation -= MathHelper.Pi;
}
- Vector2 drawPos = position + Level.Loaded.Position;
+ Vector2 drawPos = position;
+
+ if (Level.Loaded != null) drawPos += Level.Loaded.Position;
if (depth > 0.0f)
{
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index 7fa3cd14b..0c56b3047 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -866,7 +866,7 @@ namespace Subsurface
for (int i = 0; i < sounds.Count(); i++)
{
if (soundStates[i] != state) continue;
- if (n == selectedSound)
+ if (n == selectedSound && sounds[i]!=null)
{
sounds[i].Play(1.0f, 2000.0f,
AnimController.limbs[0].body.FarseerBody);
diff --git a/Subsurface/Source/Characters/FishAnimController.cs b/Subsurface/Source/Characters/FishAnimController.cs
index 789852c76..322ec1488 100644
--- a/Subsurface/Source/Characters/FishAnimController.cs
+++ b/Subsurface/Source/Characters/FishAnimController.cs
@@ -302,8 +302,8 @@ namespace Subsurface
RevoluteJoint refJoint = limbJoints[limb.RefJointIndex];
footPos.X = refJoint.WorldAnchorA.X;
}
- footPos.X += stepOffset.X * Dir;
- footPos.Y += stepOffset.Y;
+ footPos.X += limb.StepOffset.X * Dir;
+ footPos.Y += limb.StepOffset.Y;
if (limb.type == LimbType.LeftFoot)
{
@@ -373,7 +373,20 @@ namespace Subsurface
foreach (Limb l in limbs)
{
Vector2 newPos = new Vector2(midX - (l.SimPosition.X - midX), l.SimPosition.Y);
- l.body.SetTransform(newPos, l.body.Rotation);
+
+ if (Submarine.CheckVisibility(l.SimPosition, newPos)!=null)
+ {
+ Vector2 diff = newPos - l.SimPosition;
+
+ l.body.SetTransform(
+ l.SimPosition + Submarine.LastPickedFraction * diff * 0.8f, l.body.Rotation);
+ }
+ else
+ {
+ l.body.SetTransform(newPos, l.body.Rotation);
+ }
+
+
}
}
diff --git a/Subsurface/Source/Characters/HumanoidAnimController.cs b/Subsurface/Source/Characters/HumanoidAnimController.cs
index 3941c4aa3..54ba5d3f5 100644
--- a/Subsurface/Source/Characters/HumanoidAnimController.cs
+++ b/Subsurface/Source/Characters/HumanoidAnimController.cs
@@ -786,7 +786,6 @@ namespace Subsurface
arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f);
hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f);
-
}
}
diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs
index dca870265..a633005b7 100644
--- a/Subsurface/Source/Characters/Limb.cs
+++ b/Subsurface/Source/Characters/Limb.cs
@@ -32,6 +32,8 @@ namespace Subsurface
private readonly bool doesFlip;
+ protected readonly Vector2 stepOffset;
+
public Sprite sprite;
public bool inWater;
@@ -128,6 +130,11 @@ namespace Subsurface
get { return refJointIndex; }
}
+ public Vector2 StepOffset
+ {
+ get { return stepOffset; }
+ }
+
//public float Damage
//{
// get { return damage; }
@@ -205,9 +212,11 @@ namespace Subsurface
Vector2 jointPos = ToolBox.GetAttributeVector2(element, "pullpos", Vector2.Zero);
-
jointPos = ConvertUnits.ToSimUnits(jointPos);
+ stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.Zero);
+ stepOffset = ConvertUnits.ToSimUnits(stepOffset);
+
refJointIndex = ToolBox.GetAttributeInt(element, "refjoint", -1);
pullJoint = new FixedMouseJoint(body.FarseerBody, jointPos);
diff --git a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs
index 67dec322a..74c703ccf 100644
--- a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs
+++ b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs
@@ -367,13 +367,13 @@ namespace Subsurface
{
infoBox = CreateInfoFrame("The diving mask will let you breathe underwater, but it won't protect from the water pressure outside the sub. "+
"It should be fine for the situation at hand, but you still need to find an oxygen tank and drag it into the same slot as the mask." +
- "You should grab one or two.");
+ "You should grab one or two from one of the cabinets.");
}
else if (HasItem("Diving Suit"))
{
infoBox = CreateInfoFrame("In addition to letting you breathe underwater, the suit will protect you from the water pressure outside the sub " +
- "(unlike the diving mask). However, you still need to drag an oxygen tank into the same slot as the suit to supply oxygen. "+
- "You should grab one or two.");
+ "(unlike the diving mask). However, you still need to drag an oxygen tank into the same slot as the suit to supply oxygen. "+
+ "You should grab one or two from one of the cabinets.");
}
while (!HasItem("Oxygen Tank"))
@@ -431,7 +431,8 @@ namespace Subsurface
yield return CoroutineStatus.Running;
}
- infoBox = CreateInfoFrame("Use the right mouse button to aim and left to shoot.");
+ infoBox = CreateInfoFrame("Use the right mouse button to aim and wait for the creature to come closer. When you're ready to shoot, "
+ +"press the left mouse button.");
while (!moloch.IsDead)
{
@@ -510,6 +511,7 @@ namespace Subsurface
float secondsLeft = endPreviewLength;
Character.Controlled = null;
+ Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
do
{
diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs
index 288bc759e..0f30697bc 100644
--- a/Subsurface/Source/GameSession/GameSession.cs
+++ b/Subsurface/Source/GameSession/GameSession.cs
@@ -107,7 +107,7 @@ namespace Subsurface
public void StartShift(TimeSpan duration, Level level, bool reloadSub = true)
{
- Game1.LightManager.LosEnabled = (Game1.Server==null && Character.Controlled==null);
+ Game1.LightManager.LosEnabled = (Game1.Server==null || Game1.Server.CharacterInfo!=null);
this.level = level;
diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs
index d705153bb..91fb609f0 100644
--- a/Subsurface/Source/Items/CharacterInventory.cs
+++ b/Subsurface/Source/Items/CharacterInventory.cs
@@ -66,8 +66,13 @@ namespace Subsurface
protected override void DropItem(Item item)
{
+ bool enabled = draggingItem.body.Enabled;
item.Drop(character);
- item.body.SetTransform(character.SimPosition, 0.0f);
+
+ if (!enabled)
+ {
+ draggingItem.body.SetTransform(character.SimPosition, 0.0f);
+ }
}
public int FindLimbSlot(LimbSlot limbSlot)
@@ -202,8 +207,8 @@ namespace Subsurface
if (items[rightHandSlot] != null) return false;
if (items[leftHandSlot] != null) return false;
- PutItem(item, rightHandSlot, true, true);
- PutItem(item, leftHandSlot, true, false);
+ PutItem(item, rightHandSlot, createNetworkEvent, true);
+ PutItem(item, leftHandSlot, createNetworkEvent, false);
item.Equip(character);
return true;
}
@@ -269,8 +274,7 @@ namespace Subsurface
DrawSlot(spriteBatch, slotRect, draggingItem, false, false);
}
else
- {
- draggingItem.body.SetTransform(character.SimPosition, 0.0f);
+ {
DropItem(draggingItem);
//draggingItem = null;
}
diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs
index 520f7f074..7420c9342 100644
--- a/Subsurface/Source/Items/Components/Machines/Reactor.cs
+++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs
@@ -12,36 +12,39 @@ namespace Subsurface.Items.Components
{
//the rate at which the reactor is being run un
//higher rates generate more power (and heat)
- float fissionRate;
+ private float fissionRate;
//the rate at which the heat is being dissipated
- float coolingRate;
+ private float coolingRate;
- float temperature;
+ private float temperature;
//is automatic temperature control on
//(adjusts the cooling rate automatically to keep the
//amount of power generated balanced with the load)
- bool autoTemp;
+ private bool autoTemp;
//the temperature after which fissionrate is automatically
//turned down and cooling increased
- float shutDownTemp;
+ private float shutDownTemp;
- float meltDownTemp;
+ private float meltDownTemp;
//how much power is provided to the grid per 1 temperature unit
- float powerPerTemp;
+ private float powerPerTemp;
- int graphSize = 25;
+ private int graphSize = 25;
- float graphTimer;
+ private float graphTimer;
- int updateGraphInterval = 500;
+ private int updateGraphInterval = 500;
- float[] fissionRateGraph;
- float[] coolingRateGraph;
- float[] tempGraph;
+ private float[] fissionRateGraph;
+ private float[] coolingRateGraph;
+ private float[] tempGraph;
+ private float[] loadGraph;
+
+ private float load;
private PropertyTask powerUpTask;
@@ -118,9 +121,10 @@ namespace Subsurface.Items.Components
public Reactor(Item item, XElement element)
: base(item, element)
{
- fissionRateGraph = new float[graphSize];
- coolingRateGraph = new float[graphSize];
- tempGraph = new float[graphSize];
+ fissionRateGraph = new float[graphSize];
+ coolingRateGraph = new float[graphSize];
+ tempGraph = new float[graphSize];
+ loadGraph = new float[graphSize];
meltDownTemp = 9000.0f;
@@ -155,6 +159,24 @@ namespace Subsurface.Items.Components
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor");
}
}
+
+ load = 0.0f;
+
+ List connections = item.Connections;
+ if (connections != null && connections.Count > 0)
+ {
+ foreach (Connection connection in connections)
+ {
+ foreach (Connection recipient in connection.Recipients)
+ {
+ Item it = recipient.Item as Item;
+ if (it == null) continue;
+
+ PowerTransfer pt = it.GetComponent();
+ if (pt != null) load += pt.PowerLoad;
+ }
+ }
+ }
//item.Condition -= temperature * deltaTime * 0.00005f;
@@ -165,34 +187,6 @@ namespace Subsurface.Items.Components
}
else if (autoTemp)
{
-
- float load = 0.0f;
-
- List connections = item.Connections;
- if (connections!=null && connections.Count>0)
- {
- foreach (Connection connection in connections)
- {
- foreach (Connection recipient in connection.Recipients)
- {
- Item it = recipient.Item as Item;
- if (it == null) continue;
-
- PowerTransfer pt = it.GetComponent();
- if (pt != null) load += pt.PowerLoad;
- }
- }
- }
-
- //foreach (MapEntity e in item.linkedTo)
- //{
- // Item it = e as Item;
- // if (it == null) continue;
-
- // PowerTransfer pt = it.GetComponent();
- // if (pt != null) load += pt.PowerLoad;
- //}
-
fissionRate = Math.Min(load / 200.0f, shutDownTemp);
//float target = Math.Min(targetTemp, load);
CoolingRate = coolingRate + (temperature - Math.Min(load, shutDownTemp) + deltaTemp)*0.1f;
@@ -247,6 +241,9 @@ namespace Subsurface.Items.Components
UpdateGraph(fissionRateGraph, fissionRate);
UpdateGraph(coolingRateGraph, coolingRate);
UpdateGraph(tempGraph, temperature);
+
+ UpdateGraph(loadGraph, load);
+
graphTimer = 0.0f;
}
}
@@ -304,62 +301,73 @@ namespace Subsurface.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
- spriteBatch.DrawString(GUI.Font, "Temperature: " + (int)temperature + " C", new Vector2(x + 30, y + 30), Color.White);
- DrawGraph(tempGraph, spriteBatch, x + 30, y + 50, 10000.0f, xOffset);
+ spriteBatch.DrawString(GUI.Font, "Temperature: " + (int)temperature + " C",
+ new Vector2(x + 450, y + 30), Color.Red);
+ spriteBatch.DrawString(GUI.Font, "Grid load: " + (int)load + " C",
+ new Vector2(x + 620, y + 30), Color.Yellow);
- y += 130;
+ DrawGraph(tempGraph, spriteBatch,
+ new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Red);
- spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y + 30), Color.White);
- DrawGraph(fissionRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
+ DrawGraph(loadGraph, spriteBatch,
+ new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Yellow);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
+ 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))
{
valueChanged = true;
- FissionRate += 1.0f;
+ ShutDownTemp += 100.0f;
}
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
+ if (GUI.DrawButton(spriteBatch, new Rectangle(x + 500, y + 110, 40, 40), "-", true))
{
valueChanged = true;
- FissionRate -= 1.0f;
+ ShutDownTemp -= 100.0f;
}
- y += 130;
- spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 30, y + 30), Color.White);
- DrawGraph(coolingRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
-
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
- {
- valueChanged = true;
- CoolingRate += 1.0f;
- }
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
- {
- valueChanged = true;
- CoolingRate -= 1.0f;
- }
-
- y = y - 260;
-
- spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
+ 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")))
{
valueChanged = true;
autoTemp = !autoTemp;
}
- spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true))
+
+
+ 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))
{
valueChanged = true;
- ShutDownTemp += 100.0f;
+ FissionRate += 1.0f;
}
- if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true))
+ if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 80, 40, 40), "-", true))
{
valueChanged = true;
- ShutDownTemp -= 100.0f;
+ 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))
+ {
+ valueChanged = true;
+ CoolingRate += 1.0f;
+ }
+ if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 80, 40, 40), "-", true))
+ {
+ valueChanged = true;
+ CoolingRate -= 1.0f;
+ }
+
+ //y = y - 260;
+
if (valueChanged)
{
item.NewComponentEvent(this, true);
@@ -376,35 +384,32 @@ namespace Subsurface.Items.Components
graph[0] = newValue;
}
- static void DrawGraph(IList graph, SpriteBatch spriteBatch, int x, int y, float maxVal, float xOffset)
+ static void DrawGraph(IList graph, SpriteBatch spriteBatch, Rectangle rect, float maxVal, float xOffset, Color color)
{
- int width = 200;
- int height = 100;
+ float lineWidth = (float)rect.Width / (float)(graph.Count - 2);
+ float yScale = (float)rect.Height / maxVal;
- float lineWidth = (float)width / (float)(graph.Count - 2);
- float yScale = (float)height / maxVal;
+ GUI.DrawRectangle(spriteBatch, rect, Color.White);
- GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.White);
+ Vector2 prevPoint = new Vector2(rect.Right, rect.Bottom - (graph[1] + (graph[0] - graph[1]) * xOffset) * yScale);
- Vector2 prevPoint = new Vector2(x + width, y + height - (graph[1] + (graph[0] - graph[1]) * xOffset) * yScale);
-
- float currX = x + width - ((xOffset - 1.0f) * lineWidth);
+ float currX = rect.Right - ((xOffset - 1.0f) * lineWidth);
for (int i = 1; i < graph.Count - 1; i++)
{
currX -= lineWidth;
- Vector2 newPoint = new Vector2(currX, y + height - graph[i] * yScale);
+ Vector2 newPoint = new Vector2(currX, rect.Bottom - graph[i] * yScale);
- GUI.DrawLine(spriteBatch, prevPoint, newPoint, Color.White);
+ GUI.DrawLine(spriteBatch, prevPoint, newPoint - new Vector2(1.0f, 0), color);
prevPoint = newPoint;
}
- Vector2 lastPoint = new Vector2(x,
- y + height - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
+ Vector2 lastPoint = new Vector2(rect.X,
+ rect.Bottom - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
- GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.White);
+ GUI.DrawLine(spriteBatch, prevPoint, lastPoint, color);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs
index 6bb00eefa..e49814559 100644
--- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs
+++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs
@@ -45,13 +45,34 @@ namespace Subsurface.Items.Components
foreach (Powered p in connectedList)
{
PowerTransfer pt = p as PowerTransfer;
- if (pt!=null)
+ if (pt == null) continue;
+
+ pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
+ pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
+ pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f));
+
+ //damage the item if voltage is too high
+ if (-pt.currPowerConsumption > Math.Max(pt.powerLoad * 2.0f, 200.0f))
{
- pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
- pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
- pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f));
- if (-pt.currPowerConsumption > Math.Max(pt.powerLoad * 2.0f, 200.0f)) pt.item.Condition -= deltaTime*10.0f;
+
+ float prevCondition = pt.item.Condition;
+ pt.item.Condition -= deltaTime * 10.0f;
+
+ if (pt.item.Condition<=0.0f && prevCondition > 0.0f)
+ {
+ sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, item.Position);
+
+ Vector2 baseVel = Rand.Vector(3.0f);
+ for (int i = 0; i < 10; i++)
+ {
+ var particle = Game1.ParticleManager.CreateParticle("spark", pt.item.SimPosition,
+ baseVel + Rand.Vector(1.0f), 0.0f);
+
+ if (particle != null) particle.Size *= Rand.Range(0.5f,1.0f);
+ }
+ }
}
+
}
@@ -135,7 +156,7 @@ namespace Subsurface.Items.Components
{
base.ReceiveSignal(signal, connection, sender, power);
- if (connection.Name.Length>5 && connection.Name.Substring(0, 6).ToLower() == "signal")
+ if (connection.Name.Length > 5 && connection.Name.Substring(0, 6).ToLower() == "signal")
{
connection.SendSignal(signal, sender, 0.0f);
}
diff --git a/Subsurface/Source/Items/Components/Power/Powered.cs b/Subsurface/Source/Items/Components/Power/Powered.cs
index 236f82daf..78d841bf8 100644
--- a/Subsurface/Source/Items/Components/Power/Powered.cs
+++ b/Subsurface/Source/Items/Components/Power/Powered.cs
@@ -1,11 +1,15 @@
using System;
using System.Globalization;
+using System.IO;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class Powered : ItemComponent
{
+
+ protected static Sound[] sparkSounds;
+
//the amount of power CURRENTLY consumed by the item
//negative values mean that the item is providing power to connected items
protected float currPowerConsumption;
@@ -63,6 +67,25 @@ namespace Subsurface.Items.Components
set { voltage = Math.Max(0.0f, value); }
}
+ public Powered(Item item, XElement element)
+ : base(item, element)
+ {
+ if (powerOnSound == null)
+ {
+ powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg");
+ }
+
+ if (sparkSounds == null)
+ {
+ sparkSounds = new Sound[4];
+ string dir = Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\";
+ for (int i = 0; i < 4; i++)
+ {
+ sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap" + (i + 1) + ".ogg");
+ }
+ }
+ }
+
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
{
if (currPowerConsumption == 0.0f) voltage = 0.0f;
@@ -87,13 +110,6 @@ namespace Subsurface.Items.Components
}
}
- public Powered(Item item, XElement element)
- : base(item, element)
- {
- if (powerOnSound==null)
- {
- powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg");
- }
- }
+
}
}
diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs
index 8deae4633..2cd947aeb 100644
--- a/Subsurface/Source/Items/Components/Projectile.cs
+++ b/Subsurface/Source/Items/Components/Projectile.cs
@@ -162,9 +162,11 @@ namespace Subsurface.Items.Components
ignoredBodies.Clear();
+ f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
+
if (attackResult.HitArmor)
{
- item.body.LinearVelocity *= 0.5f;
+ item.body.LinearVelocity *= 0.1f;
}
else if (doesStick)
{
@@ -175,7 +177,10 @@ namespace Subsurface.Items.Components
if (Vector2.Dot(f1.Body.LinearVelocity, normal) < 0.0f) return StickToTarget(f2.Body, dir);
}
-
+ else
+ {
+ item.body.LinearVelocity *= 0.5f;
+ }
var containedItems = item.ContainedItems;
if (containedItems == null) return true;
@@ -188,7 +193,7 @@ namespace Subsurface.Items.Components
contained.Condition = 0.0f;
}
- return true;
+ return false;
}
private bool StickToTarget(Body targetBody, Vector2 axis)
diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs
index 09d3174ad..6307cb539 100644
--- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs
+++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs
@@ -10,7 +10,6 @@ namespace Subsurface.Items.Components
{
class LightComponent : Powered
{
- static Sound[] sparkSounds;
private Color lightColor;
@@ -67,16 +66,6 @@ namespace Subsurface.Items.Components
public LightComponent(Item item, XElement element)
: base (item, element)
{
- if (sparkSounds==null)
- {
- sparkSounds = new Sound[4];
- string dir = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\";
- for (int i = 0; i<4; i++)
- {
- sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap"+(i+1)+".ogg");
- }
- }
-
//foreach (XElement subElement in element.Elements())
//{
// if (subElement.Name.ToString().ToLower() != "sprite") continue;
diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs
index b25d9dca1..d8e7252f0 100644
--- a/Subsurface/Source/Items/Components/Turret.cs
+++ b/Subsurface/Source/Items/Components/Turret.cs
@@ -88,17 +88,36 @@ namespace Subsurface.Items.Components
{
this.cam = cam;
- if (reload>0.0f) reload -= deltaTime;
+ if (reload > 0.0f) reload -= deltaTime;
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
- if (targetRotation < minRotation || targetRotation > maxRotation)
+ float targetMidDiff = MathHelper.WrapAngle(targetRotation - (minRotation + maxRotation) / 2.0f);
+
+ float maxDist = (maxRotation - minRotation) / 2.0f;
+
+ if (Math.Abs(targetMidDiff) > maxDist)
{
- float diff = MathUtils.WrapAngleTwoPi(targetRotation - (minRotation + maxRotation) / 2.0f);
- targetRotation = (diff > Math.PI) ? minRotation : maxRotation;
+ targetRotation = (targetMidDiff < 0.0f) ? minRotation : maxRotation;
+ }
+
+ float deltaRotation = MathHelper.WrapAngle(targetRotation-rotation);
+ deltaRotation = MathHelper.Clamp(deltaRotation, -0.5f, 0.5f) * 5.0f;
+
+ rotation += deltaRotation * deltaTime;
+
+ float rotMidDiff = MathHelper.WrapAngle(rotation - (minRotation + maxRotation) / 2.0f);
+
+ if (rotMidDiff < -maxDist)
+ {
+ rotation = minRotation;
+ }
+ else if (rotMidDiff > maxDist)
+ {
+ rotation = maxRotation;
}
- rotation = MathUtils.CurveAngle(rotation, targetRotation, 0.05f);
+
}
public override bool Use(float deltaTime, Character character = null)
diff --git a/Subsurface/Source/Items/FixRequirement.cs b/Subsurface/Source/Items/FixRequirement.cs
index f5cddde2b..e7a5a02a7 100644
--- a/Subsurface/Source/Items/FixRequirement.cs
+++ b/Subsurface/Source/Items/FixRequirement.cs
@@ -173,6 +173,7 @@ namespace Subsurface
if (!unfixedFound)
{
item.Condition = 100.0f;
+ frame = null;
}
}
@@ -184,6 +185,9 @@ namespace Subsurface
}
UpdateGUIFrame(item, character);
+
+ if (frame == null) return;
+
frame.Update((float)Physics.step);
frame.Draw(spriteBatch);
}
diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs
index 75db0a607..1cd93ce46 100644
--- a/Subsurface/Source/Items/Inventory.cs
+++ b/Subsurface/Source/Items/Inventory.cs
@@ -304,6 +304,8 @@ namespace Subsurface
Item item = FindEntityByID(itemId) as Item;
if (item == null) return;
+ System.Diagnostics.Debug.WriteLine("Inventory update: "+itemId+" - "+slotIndex);
+
if (slotIndex==-1)
{
if (item.inventory == this) item.Drop();
diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs
index 416d98842..6b42a2203 100644
--- a/Subsurface/Source/Items/Item.cs
+++ b/Subsurface/Source/Items/Item.cs
@@ -718,8 +718,8 @@ namespace Subsurface
FixRequirement.DrawHud(spriteBatch, this, character);
}
}
-
- public void SendSignal(string signal, string connectionName, float power=0.0f)
+
+ public void SendSignal(string signal, string connectionName, float power = 0.0f)
{
ConnectionPanel panel = GetComponent();
if (panel == null) return;
@@ -729,7 +729,6 @@ namespace Subsurface
c.SendSignal(signal, this, power);
}
-
}
/// Position of the character doing the pick, only items that are close enough to this are checked
diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs
index 7f53ac4a6..5f108c8f7 100644
--- a/Subsurface/Source/Map/Explosion.cs
+++ b/Subsurface/Source/Map/Explosion.cs
@@ -51,13 +51,20 @@ namespace Subsurface
public void Explode(Vector2 simPosition)
{
+ Game1.ParticleManager.CreateParticle("shockwave", simPosition,
+ Vector2.Zero, 0.0f);
+
for (int i = 0; i < range * 10; i++)
{
- Game1.ParticleManager.CreateParticle("explosionfire", simPosition,
- Rand.Vector(Rand.Range(3.0f, 4.0f)), 0.0f);
+ Game1.ParticleManager.CreateParticle("spark", simPosition,
+ Rand.Vector(Rand.Range(5.0f, 8.0f)), 0.0f);
+
+ Game1.ParticleManager.CreateParticle("explosionfire", simPosition + Rand.Vector(0.5f),
+ Rand.Vector(Rand.Range(0.5f, 1.0f)), 0.0f);
}
+
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(simPosition);
float displayRange = ConvertUnits.ToDisplayUnits(range);
@@ -127,7 +134,7 @@ namespace Subsurface
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
light.Range = startRange * currBrightness;
- currBrightness -= 0.1f;
+ currBrightness -= 0.05f;
yield return CoroutineStatus.Running;
}
diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs
index 5a8491391..b77f1f36c 100644
--- a/Subsurface/Source/Map/Lights/ConvexHull.cs
+++ b/Subsurface/Source/Map/Lights/ConvexHull.cs
@@ -8,8 +8,10 @@ namespace Subsurface.Lights
class ConvexHull
{
public static List list = new List();
- static BasicEffect losEffect;
static BasicEffect shadowEffect;
+ static BasicEffect penumbraEffect;
+
+ private static VertexPositionTexture[] penumbraVertices;
private VertexPositionColor[] vertices;
private short[] indices;
@@ -33,6 +35,25 @@ namespace Subsurface.Lights
public ConvexHull(Vector2[] points, Color color)
{
+ if (shadowEffect == null)
+ {
+ shadowEffect = new BasicEffect(Game1.CurrGraphicsDevice);
+ shadowEffect.VertexColorEnabled = true;
+ }
+ if (penumbraEffect == null)
+ {
+ penumbraEffect = new BasicEffect(Game1.CurrGraphicsDevice);
+ penumbraEffect.TextureEnabled = true;
+ //shadowEffect.VertexColorEnabled = true;
+ penumbraEffect.LightingEnabled = false;
+ penumbraEffect.Texture = Game1.TextureLoader.FromFile("Content/Lights/penumbra.png");
+ }
+
+ if (penumbraVertices==null)
+ {
+ penumbraVertices = new VertexPositionTexture[6];
+ }
+
int vertexCount = points.Length;
vertices = new VertexPositionColor[vertexCount + 1];
Vector2 center = Vector2.Zero;
@@ -90,37 +111,9 @@ namespace Subsurface.Lights
}
}
- //public void Draw(GameTime gameTime)
- //{
- // device.RasterizerState = RasterizerState.CullNone;
- // device.BlendState = BlendState.Opaque;
-
- // drawingEffect.World = Matrix.CreateTranslation(position.X, position.Y, 0);
-
- // foreach (EffectPass pass in drawingEffect.CurrentTechnique.Passes)
- // {
- // pass.Apply();
- // device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, primitiveCount);
- // }
- //}
-
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool los = true)
{
if (!Enabled) return;
-
- if (losEffect == null)
- {
- losEffect = new BasicEffect(graphicsDevice);
- losEffect.VertexColorEnabled = true;
- }
- if (shadowEffect==null)
- {
- shadowEffect = new BasicEffect(graphicsDevice);
- shadowEffect.TextureEnabled = true;
- //shadowEffect.VertexColorEnabled = true;
- shadowEffect.LightingEnabled = false;
- shadowEffect.Texture = Game1.TextureLoader.FromFile("Content/Lights/penumbra.png");
- }
//compute facing of each edge, using N*L
for (int i = 0; i < primitiveCount; i++)
@@ -155,8 +148,6 @@ namespace Subsurface.Lights
startingIndex = nextEdge;
}
- VertexPositionTexture[] penumbraVertices = new VertexPositionTexture[6];
-
if (los)
{
for (int n = 0; n < 4; n+=3)
@@ -233,21 +224,19 @@ namespace Subsurface.Lights
currentIndex = (currentIndex + 1) % primitiveCount;
}
- losEffect.World = cam.ShaderTransform
+ shadowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
- losEffect.CurrentTechnique.Passes[0].Apply();
+ shadowEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
if (los)
{
- shadowEffect.World = cam.ShaderTransform
- * Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
- shadowEffect.CurrentTechnique.Passes[0].Apply();
+ penumbraEffect.World = shadowEffect.World;
+ penumbraEffect.CurrentTechnique.Passes[0].Apply();
#if WINDOWS
- graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration);
-
+ graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration);
#endif
}
}
diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs
index bba43ce29..df8d0947b 100644
--- a/Subsurface/Source/Networking/GameServer.cs
+++ b/Subsurface/Source/Networking/GameServer.cs
@@ -648,6 +648,13 @@ namespace Subsurface.Networking
public IEnumerable