diff --git a/Subsurface/Characters/HumanoidAnimController.cs b/Subsurface/Characters/HumanoidAnimController.cs
index 13f22e6db..00524c9a9 100644
--- a/Subsurface/Characters/HumanoidAnimController.cs
+++ b/Subsurface/Characters/HumanoidAnimController.cs
@@ -164,10 +164,19 @@ namespace Subsurface
float walkCycleSpeed = head.LinearVelocity.X * 0.08f;
if (stairs != null)
{
- if (TargetMovement!=Vector2.Zero && TargetMovement.Length()>3.0f)
+ TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -2.0f, 2.0f), TargetMovement.Y) ;
+
+ if ((TargetMovement.X>0.0f && stairs.StairDirection == Direction.Right) ||
+ TargetMovement.X < 0.0f && stairs.StairDirection == Direction.Left)
{
- TargetMovement /= TargetMovement.Length() / 3.0f;
+ TargetMovement *= 1.35f;
}
+ else
+ {
+
+ TargetMovement /= 1.2f;
+ }
+
walkCycleSpeed *= 1.5f;
}
@@ -211,12 +220,12 @@ namespace Subsurface
torso.pullJoint.Enabled = true;
torso.pullJoint.WorldAnchorB =
MathUtils.SmoothStep(torso.SimPosition,
- new Vector2(footMid + movement.X * 0.35f, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f)), getUpSpeed);
+ new Vector2(footMid + movement.X * 0.35f, colliderPos.Y + TorsoPosition), getUpSpeed);
head.pullJoint.Enabled = true;
head.pullJoint.WorldAnchorB =
MathUtils.SmoothStep(head.SimPosition,
- new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f)), getUpSpeed);
+ new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed);
}
@@ -224,46 +233,47 @@ namespace Subsurface
if (TargetMovement.X != 0.0f)
{
//progress the walking animation
- walkPos -= (walkCycleSpeed / runningModifier);
+ walkPos -= (walkCycleSpeed / runningModifier)*0.8f;
MoveLimb(leftFoot,
colliderPos + new Vector2(
stepSize.X,
(stepSize.Y > 0.0f) ? stepSize.Y : -0.15f),
- 10.0f, true);
+ 15.0f, true);
MoveLimb(rightFoot,
colliderPos + new Vector2(
-stepSize.X,
(-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f),
- 10.0f, true);
+ 15.0f, true);
if (Math.Sign(stepSize.X) == Math.Sign(Dir))
{
- leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.3f, 20.0f * runningModifier);
+ leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
}
else if (Math.Sign(-stepSize.X) == Math.Sign(Dir))
{
- rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.3f, 20 * runningModifier);
+ rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20 * runningModifier);
}
if (walkPosY > 0.0f)
{
- GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * -2.0f);
+ GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * -5.0f);
}
else
{
- GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * -2.0f);
+ GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * -5.0f);
}
//calculate the positions of hands
handPos = torso.SimPosition;
- handPos.X = -walkPosX * 0.25f;
+ handPos.X = -walkPosX * 0.1f * runningModifier;
- float lowerY = -0.4f / runningModifier;
- handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.1)) * runningModifier;
+ float lowerY = -0.6f + runningModifier/3.5f;
+
+ handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.1)) / runningModifier;
- Vector2 posAdditon = new Vector2(movement.X*0.05f, 0.0f);
+ Vector2 posAdditon = new Vector2(movement.X*0.07f, 0.0f);
if (stairs!=null)
{
if ((stairs.StairDirection == Direction.Right && movement.X < 0.0f) ||
@@ -273,7 +283,7 @@ namespace Subsurface
}
else
{
- posAdditon.Y += 0.1f;
+ posAdditon.Y += 0.1f;
}
}
@@ -318,17 +328,30 @@ namespace Subsurface
leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
- handPos = torso.SimPosition;
- handPos.X += movement.X;
- handPos.Y -= 0.4f;
+
+
+
+ //handPos = torso.SimPosition;
+ //handPos.X += movement.X;
+ //handPos.Y -= 0.4f;
if (!rightHand.Disabled)
{
- MoveLimb(rightHand, handPos, 1.5f, true);
+ // MoveLimb(rightHand, handPos, 0.05f, true);
+ //rightHand.body.ApplyLinearImpulse((handPos - rightHand.Position));
+ rightHand.body.SmoothRotate(0.0f, 5.0f);
+
+ var rightArm = GetLimb(LimbType.RightArm);
+ rightArm.body.SmoothRotate(0.0f, 20.0f);
}
if (!leftHand.Disabled)
{
- MoveLimb(leftHand, handPos, 1.5f, true);
+ //MoveLimb(leftHand, handPos, 0.05f, true);
+ //leftHand.body.ApplyLinearImpulse((handPos - leftHand.Position));
+ leftHand.body.SmoothRotate(0.0f, 5.0f);
+
+ var leftArm = GetLimb(LimbType.LeftArm);
+ leftArm.body.SmoothRotate(0.0f, 20.0f);
}
}
}
@@ -554,7 +577,7 @@ namespace Subsurface
handPos = new Vector2(
ladderSimPos.X,
- head.SimPosition.Y + 0.3f + movement.Y * 0.1f - ladderSimPos.Y);
+ head.SimPosition.Y + 0.5f + movement.Y * 0.1f - ladderSimPos.Y);
MoveLimb(leftHand,
new Vector2(handPos.X,
@@ -570,32 +593,34 @@ namespace Subsurface
rightHand.body.ApplyTorque(Dir * 2.0f);
footPos = new Vector2(
- handPos.X + Dir*0.1f,
+ handPos.X - Dir*0.05f,
head.SimPosition.Y - stepHeight * 2.7f - ladderSimPos.Y);
+ //if (movement.Y < 0) footPos.Y += 0.05f;
+
MoveLimb(leftFoot,
new Vector2(footPos.X,
MathUtils.Round(footPos.Y + stepHeight, stepHeight * 2.0f) - stepHeight + ladderSimPos.Y),
- 7.5f, true);
+ 15.5f, true);
MoveLimb(rightFoot,
new Vector2(footPos.X,
MathUtils.Round(footPos.Y, stepHeight * 2.0f) + ladderSimPos.Y),
- 7.5f, true);
+ 15.5f, true);
//apply torque to the legs to make the knees bend
Limb leftLeg = GetLimb(LimbType.LeftLeg);
Limb rightLeg = GetLimb(LimbType.RightLeg);
- leftLeg.body.ApplyTorque(Dir * -3.0f);
- rightLeg.body.ApplyTorque(Dir * -3.0f);
+ leftLeg.body.ApplyTorque(Dir * -8.0f);
+ rightLeg.body.ApplyTorque(Dir * -8.0f);
//apply forces to the head and the torso to move the character up/down
float movementFactor = (handPos.Y / stepHeight) * (float)Math.PI;
movementFactor = 0.8f + (float)Math.Abs(Math.Sin(movementFactor));
- Vector2 climbForce = new Vector2(0.0f, movement.Y + 0.5f) * movementFactor;
- torso.body.ApplyForce(climbForce * 65.0f * torso.Mass);
+ Vector2 climbForce = new Vector2(0.0f, movement.Y + 0.4f) * movementFactor;
+ torso.body.ApplyForce(climbForce * 40.0f * torso.Mass);
head.body.SmoothRotate(0.0f);
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.First();
@@ -607,8 +632,8 @@ namespace Subsurface
// - reached the top or bottom of the ladder
if (Math.Abs(torso.LinearVelocity.Y) > 5.0f ||
TargetMovement.X != 0.0f ||
- (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition*2.0f) ||
- (TargetMovement.Y > 0.0f && -handPos.Y < ConvertUnits.ToSimUnits(10.0f)))
+ (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition*1.5f) ||
+ (TargetMovement.Y > 0.0f && handPos.Y > 0.3f))
{
Anim = Animation.None;
character.SelectedConstruction = null;
diff --git a/Subsurface/Content/Characters/Human/fhead1.png b/Subsurface/Content/Characters/Human/fhead1.png
index f3312bfd1..9947e1b54 100644
Binary files a/Subsurface/Content/Characters/Human/fhead1.png and b/Subsurface/Content/Characters/Human/fhead1.png differ
diff --git a/Subsurface/Content/Characters/Human/fhead2.png b/Subsurface/Content/Characters/Human/fhead2.png
index caac6f99a..1e606927b 100644
Binary files a/Subsurface/Content/Characters/Human/fhead2.png and b/Subsurface/Content/Characters/Human/fhead2.png differ
diff --git a/Subsurface/Content/Characters/Human/fhead3.png b/Subsurface/Content/Characters/Human/fhead3.png
new file mode 100644
index 000000000..6b8f30207
Binary files /dev/null and b/Subsurface/Content/Characters/Human/fhead3.png differ
diff --git a/Subsurface/Content/Characters/Human/fhead4.png b/Subsurface/Content/Characters/Human/fhead4.png
new file mode 100644
index 000000000..7f49d0193
Binary files /dev/null and b/Subsurface/Content/Characters/Human/fhead4.png differ
diff --git a/Subsurface/Content/Characters/Human/flegs.png b/Subsurface/Content/Characters/Human/flegs.png
index 83d56c70d..a72474b80 100644
Binary files a/Subsurface/Content/Characters/Human/flegs.png and b/Subsurface/Content/Characters/Human/flegs.png differ
diff --git a/Subsurface/Content/Characters/Human/ftorso.png b/Subsurface/Content/Characters/Human/ftorso.png
index 1edfaf0fa..a17890597 100644
Binary files a/Subsurface/Content/Characters/Human/ftorso.png and b/Subsurface/Content/Characters/Human/ftorso.png differ
diff --git a/Subsurface/Content/Characters/Human/head1.png b/Subsurface/Content/Characters/Human/head1.png
index 3c6f7eb54..668334d43 100644
Binary files a/Subsurface/Content/Characters/Human/head1.png and b/Subsurface/Content/Characters/Human/head1.png differ
diff --git a/Subsurface/Content/Characters/Human/head2.png b/Subsurface/Content/Characters/Human/head2.png
index 8056e645a..2c9914d42 100644
Binary files a/Subsurface/Content/Characters/Human/head2.png and b/Subsurface/Content/Characters/Human/head2.png differ
diff --git a/Subsurface/Content/Characters/Human/head3.png b/Subsurface/Content/Characters/Human/head3.png
index 58e8b9c86..b4453d3d8 100644
Binary files a/Subsurface/Content/Characters/Human/head3.png and b/Subsurface/Content/Characters/Human/head3.png differ
diff --git a/Subsurface/Content/Characters/Human/head4.png b/Subsurface/Content/Characters/Human/head4.png
index 65e524fed..00fc9aef1 100644
Binary files a/Subsurface/Content/Characters/Human/head4.png and b/Subsurface/Content/Characters/Human/head4.png differ
diff --git a/Subsurface/Content/Characters/Human/human.xml b/Subsurface/Content/Characters/Human/human.xml
index d587c6d68..84842b744 100644
--- a/Subsurface/Content/Characters/Human/human.xml
+++ b/Subsurface/Content/Characters/Human/human.xml
@@ -1,87 +1,87 @@
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/Subsurface/Content/Characters/Human/legs.png b/Subsurface/Content/Characters/Human/legs.png
index 83d56c70d..16368722d 100644
Binary files a/Subsurface/Content/Characters/Human/legs.png and b/Subsurface/Content/Characters/Human/legs.png differ
diff --git a/Subsurface/Content/Characters/Human/torso.png b/Subsurface/Content/Characters/Human/torso.png
index 2da41f32c..b4befac21 100644
Binary files a/Subsurface/Content/Characters/Human/torso.png and b/Subsurface/Content/Characters/Human/torso.png differ
diff --git a/Subsurface/Content/Items/Electricity/powerOn.ogg b/Subsurface/Content/Items/Electricity/powerOn.ogg
new file mode 100644
index 000000000..8b748ef8e
Binary files /dev/null and b/Subsurface/Content/Items/Electricity/powerOn.ogg differ
diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml
index e82ca9bd6..8ac51db20 100644
--- a/Subsurface/Content/Items/Electricity/signalitems.xml
+++ b/Subsurface/Content/Items/Electricity/signalitems.xml
@@ -31,7 +31,9 @@
-
+
+
+
diff --git a/Subsurface/Content/Items/Electricity/zap1.ogg b/Subsurface/Content/Items/Electricity/zap1.ogg
new file mode 100644
index 000000000..b9df4ee7b
Binary files /dev/null and b/Subsurface/Content/Items/Electricity/zap1.ogg differ
diff --git a/Subsurface/Content/Items/Electricity/zap2.ogg b/Subsurface/Content/Items/Electricity/zap2.ogg
new file mode 100644
index 000000000..0f2ffa0ce
Binary files /dev/null and b/Subsurface/Content/Items/Electricity/zap2.ogg differ
diff --git a/Subsurface/Content/Items/Electricity/zap3.ogg b/Subsurface/Content/Items/Electricity/zap3.ogg
new file mode 100644
index 000000000..0980a898d
Binary files /dev/null and b/Subsurface/Content/Items/Electricity/zap3.ogg differ
diff --git a/Subsurface/Content/Items/Electricity/zap4.ogg b/Subsurface/Content/Items/Electricity/zap4.ogg
new file mode 100644
index 000000000..26cf9e844
Binary files /dev/null and b/Subsurface/Content/Items/Electricity/zap4.ogg differ
diff --git a/Subsurface/Content/Lights/AlphaOne.dds b/Subsurface/Content/Lights/AlphaOne.dds
deleted file mode 100644
index 20997b165..000000000
Binary files a/Subsurface/Content/Lights/AlphaOne.dds and /dev/null differ
diff --git a/Subsurface/Content/Lights/penumbra.png b/Subsurface/Content/Lights/penumbra.png
new file mode 100644
index 000000000..f2d1fa984
Binary files /dev/null and b/Subsurface/Content/Lights/penumbra.png differ
diff --git a/Subsurface/DebugConsole.cs b/Subsurface/DebugConsole.cs
index cc9caae8e..4a643cf67 100644
--- a/Subsurface/DebugConsole.cs
+++ b/Subsurface/DebugConsole.cs
@@ -213,6 +213,12 @@ namespace Subsurface
Game1.Level = new Level("asdf", 50.0f, 500,500, 50);
Game1.Level.Generate(100.0f);
break;
+ case "fixitems":
+ foreach (Item it in Item.itemList)
+ {
+ it.Condition = 100.0f;
+ }
+ break;
case "fowenabled":
case "fow":
case "drawfow":
@@ -221,8 +227,16 @@ namespace Subsurface
case "lighting":
case "lightingenabled":
case "light":
+ case "lights":
Game1.LightManager.LightingEnabled = !Game1.LightManager.LightingEnabled;
break;
+ case "oxygen":
+ case "air":
+ foreach (Hull hull in Hull.hullList)
+ {
+ hull.OxygenPercentage = 100.0f;
+ }
+ break;
case "lobbyscreen":
case "lobby":
Game1.LobbyScreen.Select();
@@ -266,8 +280,9 @@ namespace Subsurface
}
public static void ThrowError(string error, Exception e = null)
- {
- if (e!=null) error += " {"+e.Message+"}";
+ {
+ if (e != null) error += " {" + e.Message + "}";
+ System.Diagnostics.Debug.WriteLine(error);
NewMessage(error, Color.Red);
isOpen = true;
}
diff --git a/Subsurface/Items/Components/Container.cs b/Subsurface/Items/Components/Container.cs
index c9b3f6eca..6d4bd415a 100644
--- a/Subsurface/Items/Components/Container.cs
+++ b/Subsurface/Items/Components/Container.cs
@@ -123,7 +123,7 @@ namespace Subsurface.Items.Components
{
foreach (Item contained in inventory.items)
{
- if (contained == null) continue;
+ if (contained == null || contained.Condition<=0.0f) continue;
if (contained.body!=null) contained.body.Enabled = false;
diff --git a/Subsurface/Items/Components/Holdable/Holdable.cs b/Subsurface/Items/Components/Holdable/Holdable.cs
index cae56f6e0..483c61043 100644
--- a/Subsurface/Items/Components/Holdable/Holdable.cs
+++ b/Subsurface/Items/Components/Holdable/Holdable.cs
@@ -162,7 +162,7 @@ namespace Subsurface.Items.Components
// return false;
//}
- if (attached) return false;
+ //if (attached) return false;
item.body = body;
item.body.Enabled = true;
@@ -172,12 +172,14 @@ namespace Subsurface.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
- if (!attachable || item.body==null) return false;
+ if (!attachable || item.body==null) return true;
item.Drop();
item.body.Enabled = false;
item.body = null;
+ attached = true;
+
return true;
}
diff --git a/Subsurface/Items/Components/ItemComponent.cs b/Subsurface/Items/Components/ItemComponent.cs
index 64e0aaf7a..a568b8b4d 100644
--- a/Subsurface/Items/Components/ItemComponent.cs
+++ b/Subsurface/Items/Components/ItemComponent.cs
@@ -396,18 +396,18 @@ namespace Subsurface
public bool HasRequiredContainedItems(bool addMessage)
{
- if (!requiredItems.Any()) return true;
+ List requiredContained = requiredItems.FindAll(ri=> ri.Type == RelatedItem.RelationType.Contained);
+
+ if (!requiredContained.Any()) return true;
Item[] containedItems = item.ContainedItems;
if (containedItems == null || !containedItems.Any()) return false;
- foreach (RelatedItem ri in requiredItems)
+ foreach (RelatedItem ri in requiredContained)
{
- if (ri.Type != RelatedItem.RelationType.Contained) continue;
Item containedItem = Array.Find(containedItems, x => x != null && x.Condition > 0.0f && ri.MatchesItem(x));
if (containedItem == null)
{
- //if (addMessage && !String.IsNullOrEmpty(ri.Msg)) GUI.AddMessage(ri.Msg, Color.Red);
if (addMessage && !string.IsNullOrEmpty(ri.Msg)) GUI.AddMessage(ri.Msg, Color.Red);
return false;
}
diff --git a/Subsurface/Items/Components/Machines/Radar.cs b/Subsurface/Items/Components/Machines/Radar.cs
index 8de3ead13..23c451f52 100644
--- a/Subsurface/Items/Components/Machines/Radar.cs
+++ b/Subsurface/Items/Components/Machines/Radar.cs
@@ -54,7 +54,7 @@ namespace Subsurface.Items.Components
pingState = (pingState + deltaTime * 0.5f);
if (pingState>1.0f)
{
- item.Use(deltaTime,null);
+ item.Use(deltaTime, null);
pingState = 0.0f;
}
@@ -63,7 +63,7 @@ namespace Subsurface.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
- return true;
+ return (pingState > 1.0f);
}
public override void DrawHUD(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Character character)
@@ -87,7 +87,7 @@ namespace Subsurface.Items.Components
//lineEnd += new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Math.Min(width, height) / 2.0f;
//GUI.DrawLine(spriteBatch, GuiFrame.Center, lineEnd, Color.Green);
- if (!isActive || Level.Loaded == null) return;
+ if (!isActive) return;
if (pingCircle!=null)
{
@@ -97,35 +97,43 @@ namespace Subsurface.Items.Components
float scale = 0.015f;
- List edges = Level.Loaded.GetCellEdges(-Level.Loaded.Position, 7);
- Vector2 offset = Vector2.Zero;
-
- for (int i = 0; i < edges.Count; i++)
+ if (Level.Loaded != null)
{
- GUI.DrawLine(spriteBatch,
- center + (edges[i][0] - offset) * scale,
- center + (edges[i][1] - offset) * scale, Color.White);
- }
+ List edges = Level.Loaded.GetCellEdges(-Level.Loaded.Position, 7);
+ Vector2 offset = Vector2.Zero;
- scale = ConvertUnits.ToDisplayUnits(scale);
- for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
- {
- Vector2 start = Submarine.Loaded.HullVertices[i] * scale;
- start.Y = -start.Y;
- Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * scale;
- end.Y = -end.Y;
+ for (int i = 0; i < edges.Count; i++)
+ {
+ GUI.DrawLine(spriteBatch,
+ center + (edges[i][0] - offset) * scale,
+ center + (edges[i][1] - offset) * scale, Color.White);
+ }
- GUI.DrawLine(spriteBatch, center + start, center + end, Color.White);
+ scale = ConvertUnits.ToDisplayUnits(scale);
+ for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
+ {
+ Vector2 start = Submarine.Loaded.HullVertices[i] * scale;
+ start.Y = -start.Y;
+ Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * scale;
+ end.Y = -end.Y;
+
+ GUI.DrawLine(spriteBatch, center + start, center + end, Color.White);
+ }
}
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull != null) continue;
- if (c.SimPosition!=Vector2.Zero && c.SimPosition.Length() < 7*Level.GridCellWidth)
+ if (c.SimPosition != Vector2.Zero && c.SimPosition.Length() < 7 * Level.GridCellWidth)
{
- int width = (int)c.Mass/5;
- GUI.DrawRectangle(spriteBatch, new Rectangle((int)c.Position.X - width / 2, (int)c.Position.Y - width / 2, width, width), Color.White);
+ int width = (int)Math.Min(c.Mass / 5, 30);
+
+ Vector2 pos = c.Position * scale;
+ pos.Y = -pos.Y;
+ pos += center;
+
+ GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - width / 2, (int)pos.Y - width / 2, width, width), Color.White, true);
}
}
diff --git a/Subsurface/Items/Components/Machines/Reactor.cs b/Subsurface/Items/Components/Machines/Reactor.cs
index cb7c5496d..a35c87e20 100644
--- a/Subsurface/Items/Components/Machines/Reactor.cs
+++ b/Subsurface/Items/Components/Machines/Reactor.cs
@@ -112,7 +112,7 @@ namespace Subsurface.Items.Components
fissionRate = Math.Min(fissionRate, AvailableFuel);
- float heat = 100 * fissionRate;
+ float heat = 100 * fissionRate * (AvailableFuel/2000.0f);
float heatDissipation = 50 * coolingRate + ExtraCooling;
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 1000.0f;
@@ -125,14 +125,14 @@ namespace Subsurface.Items.Components
}
else if (temperature==0.0f)
{
- if (powerUpTask==null || powerUpTask.IsFinished)
+ if (powerUpTask == null || powerUpTask.IsFinished)
{
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor");
- }
+ }
}
- item.Condition -= temperature*deltaTime*0.00005f;
+ item.Condition -= temperature * deltaTime * 0.00005f;
if (temperature > shutDownTemp)
{
@@ -360,13 +360,13 @@ namespace Subsurface.Items.Components
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.White);
- Vector2 prevPoint = new Vector2(x, y + height - (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 + ((xOffset - 1.0f) * lineWidth);
+ float currX = x + width - ((xOffset - 1.0f) * lineWidth);
for (int i = 1; i < graph.Count - 1; i++)
{
- currX += lineWidth;
+ currX -= lineWidth;
Vector2 newPoint = new Vector2(currX, y + height - graph[i] * yScale);
@@ -375,7 +375,7 @@ namespace Subsurface.Items.Components
prevPoint = newPoint;
}
- Vector2 lastPoint = new Vector2(x + width,
+ Vector2 lastPoint = new Vector2(x,
y + height - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.Red);
diff --git a/Subsurface/Items/Components/Power/PowerContainer.cs b/Subsurface/Items/Components/Power/PowerContainer.cs
index ffde43589..e85e7b515 100644
--- a/Subsurface/Items/Components/Power/PowerContainer.cs
+++ b/Subsurface/Items/Components/Power/PowerContainer.cs
@@ -138,7 +138,7 @@ namespace Subsurface.Items.Components
return;
}
- currPowerConsumption = MathHelper.Lerp(currPowerConsumption, maxRechargeSpeed*rechargeSpeed, 0.05f);
+ currPowerConsumption = MathHelper.Lerp(currPowerConsumption, rechargeSpeed, 0.05f);
charge += currPowerConsumption*voltage / 3600.0f;
}
//provide power to the grid
diff --git a/Subsurface/Items/Components/Signal/LightComponent.cs b/Subsurface/Items/Components/Signal/LightComponent.cs
index 1776d3ee4..dd9c66a7d 100644
--- a/Subsurface/Items/Components/Signal/LightComponent.cs
+++ b/Subsurface/Items/Components/Signal/LightComponent.cs
@@ -3,12 +3,15 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Lights;
using System;
+using System.IO;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class LightComponent : Powered
{
+ static Sound[] sparkSounds;
+
private Color lightColor;
//private Sprite sprite;
@@ -19,7 +22,7 @@ namespace Subsurface.Items.Components
float lightBrightness;
- [HasDefaultValue(100.0f, true)]
+ [Editable, HasDefaultValue(100.0f, true)]
public float Range
{
get { return range; }
@@ -47,6 +50,16 @@ 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(dir+"zap"+(i+1)+".ogg");
+ }
+ }
+
//foreach (XElement subElement in element.Elements())
//{
// if (subElement.Name.ToString().ToLower() != "sprite") continue;
@@ -79,8 +92,9 @@ namespace Subsurface.Items.Components
currPowerConsumption = powerConsumption;
}
- if (voltage < Rand.Range(0.0f, minVoltage))
+ if (Rand.Range(0.0f, 1.0f)<0.05f && voltage < Rand.Range(0.0f, minVoltage))
{
+ if (voltage>0.1f) sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 400.0f, item.Position);
lightBrightness = 0.0f;
}
else
diff --git a/Subsurface/Map/Lights/ConvexHull.cs b/Subsurface/Map/Lights/ConvexHull.cs
index 7c9409dd4..58667dcdb 100644
--- a/Subsurface/Map/Lights/ConvexHull.cs
+++ b/Subsurface/Map/Lights/ConvexHull.cs
@@ -8,7 +8,8 @@ namespace Subsurface.Lights
class ConvexHull
{
public static List list = new List();
- static BasicEffect drawingEffect;
+ static BasicEffect fowEffect;
+ static BasicEffect shadowEffect;
private VertexPositionColor[] vertices;
private short[] indices;
@@ -86,14 +87,22 @@ namespace Subsurface.Lights
// }
//}
- public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos)
+ public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool fow = true)
{
if (!Enabled) return;
- if (drawingEffect == null)
+ if (fowEffect == null)
{
- drawingEffect = new BasicEffect(graphicsDevice);
- drawingEffect.VertexColorEnabled = true;
+ fowEffect = new BasicEffect(graphicsDevice);
+ fowEffect.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
@@ -129,6 +138,59 @@ namespace Subsurface.Lights
startingIndex = nextEdge;
}
+ VertexPositionTexture[] penumbraVertices = new VertexPositionTexture[6];
+
+ if (fow)
+ {
+ for (int n = 0; n < 4; n+=3)
+ {
+ Vector3 penumbraStart = (n == 0) ? vertices[startingIndex].Position : vertices[endingIndex].Position;
+
+ penumbraVertices[n] = new VertexPositionTexture();
+ penumbraVertices[n].Position = penumbraStart;
+ penumbraVertices[n].TextureCoordinate = new Vector2(0.0f, 1.0f);
+ //penumbraVertices[0].te = fow ? Color.Black : Color.Transparent;
+
+ for (int i = 0; i < 2; i++ )
+ {
+ penumbraVertices[n + i + 1] = new VertexPositionTexture();
+ Vector3 vertexDir = penumbraStart - new Vector3(lightSourcePos, 0);
+ vertexDir.Normalize();
+
+ Vector3 normal = (i == 0) ? new Vector3(-vertexDir.Y, vertexDir.X, 0.0f) : new Vector3(vertexDir.Y, -vertexDir.X, 0.0f)*0.05f;
+ if (n > 0) normal = -normal;
+ vertexDir = penumbraStart - (new Vector3(lightSourcePos, 0) - normal * 20.0f);
+ vertexDir.Normalize();
+ penumbraVertices[n + i + 1].Position = new Vector3(lightSourcePos, 0) + vertexDir * 9000;
+
+ if (i==0)
+ {
+ //penumbraVertices[n].Position -= normal*2.0f;
+ }
+
+ if (fow)
+ {
+ penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(0.05f, 0.0f) : new Vector2(1.0f, 0.0f);
+ }
+ else
+ {
+ penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(1.0f, 0.0f):Vector2.Zero;
+ }
+
+
+ //penumbraVertices[i+1].Color = Color.Black;
+ }
+
+ if (n>0)
+ {
+ var temp = penumbraVertices[4];
+ penumbraVertices[4] = penumbraVertices[5];
+ penumbraVertices[5] = temp;
+ }
+ }
+ }
+
+
int shadowVertexCount;
//nr of vertices that are in the shadow
@@ -148,12 +210,12 @@ namespace Subsurface.Lights
//one vertex on the hull
shadowVertices[svCount] = new VertexPositionColor();
- shadowVertices[svCount].Color = Color.Black;
+ shadowVertices[svCount].Color = fow ? Color.Black : Color.Transparent;
shadowVertices[svCount].Position = vertexPos;
//one extruded by the light direction
shadowVertices[svCount + 1] = new VertexPositionColor();
- shadowVertices[svCount + 1].Color = Color.Black;
+ shadowVertices[svCount + 1].Color = fow ? Color.Black : Color.Transparent;
Vector3 L2P = vertexPos - new Vector3(lightSourcePos, 0);
L2P.Normalize();
shadowVertices[svCount + 1].Position = new Vector3(lightSourcePos, 0) + L2P * 9000;
@@ -162,12 +224,20 @@ namespace Subsurface.Lights
currentIndex = (currentIndex + 1) % primitiveCount;
}
- drawingEffect.World = cam.ShaderTransform
+ fowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
- drawingEffect.CurrentTechnique.Passes[0].Apply();
+ fowEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
+ if (fow)
+ {
+ shadowEffect.World = cam.ShaderTransform
+ * Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
+ shadowEffect.CurrentTechnique.Passes[0].Apply();
+
+ graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration);
+ }
}
public void Remove()
diff --git a/Subsurface/Map/Lights/LightManager.cs b/Subsurface/Map/Lights/LightManager.cs
index b8eb9c6a7..05b141d32 100644
--- a/Subsurface/Map/Lights/LightManager.cs
+++ b/Subsurface/Map/Lights/LightManager.cs
@@ -67,24 +67,32 @@ namespace Subsurface.Lights
{
graphics.SetRenderTarget(lightMap);
+ Rectangle viewRect = cam.WorldView;
+ viewRect.Y -= cam.WorldView.Height;
+
//clear to some small ambient light
graphics.Clear(AmbientLight);
foreach (LightSource light in lights)
{
+ if (light.Color.A < 0.01f || light.Range < 0.01f) continue;
+
+
+ if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
+
//clear alpha to 1
ClearAlphaToOne(graphics, spriteBatch);
//draw all shadows
//write only to the alpha channel, which sets alpha to 0
- //graphics.RasterizerState = RasterizerState.CullNone;
- //graphics.BlendState = CustomBlendStates.WriteToAlpha;
+ graphics.RasterizerState = RasterizerState.CullNone;
+ graphics.BlendState = CustomBlendStates.WriteToAlpha;
- //foreach (ConvexHull ch in ConvexHull.list)
- //{
- // //draw shadow
- // ch.DrawShadows(graphics, cam, light.Position);
- //}
+ foreach (ConvexHull ch in ConvexHull.list)
+ {
+ //draw shadow
+ ch.DrawShadows(graphics, cam, light.Position, false);
+ }
//draw the light shape
//where Alpha is 0, nothing will be written
diff --git a/Subsurface/Screens/GameScreen.cs b/Subsurface/Screens/GameScreen.cs
index 6b6b58c43..5783725bf 100644
--- a/Subsurface/Screens/GameScreen.cs
+++ b/Subsurface/Screens/GameScreen.cs
@@ -148,21 +148,17 @@ namespace Subsurface
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
{
+ System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
+ sw.Start();
Game1.LightManager.DrawLightmap(graphics, spriteBatch, cam);
-
-
-
-
+ sw.Stop();
+ System.Diagnostics.Debug.WriteLine(sw.ElapsedMilliseconds+" - "+sw.ElapsedTicks);
//----------------------------------------------------------------------------------------
- //1. draw the characters and the parts of the map that are behind them
+ //1. draw the background, characters and the parts of the submarine that are behind them
//----------------------------------------------------------------------------------------
- //cam.UpdateTransform();
-
- //----------------------------------------------------------------------------------------
- //draw the map and characters to a rendertarget
graphics.SetRenderTarget(renderTarget);
graphics.Clear(new Color(11, 18, 26, 255));
@@ -263,10 +259,18 @@ namespace Subsurface
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
+ if (Game1.LightManager.LightingEnabled)
+ {
+ //multiply scene with lightmap
+ spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
+ spriteBatch.Draw(Game1.LightManager.LightMap, Vector2.Zero, Color.White);
+ spriteBatch.End();
+ }
+
//----------------------------------------------------------------------------------------
//3. draw the sections of the map that are on top of the water
//----------------------------------------------------------------------------------------
-
+
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, SamplerState.LinearWrap,
null, null, null,
@@ -287,18 +291,11 @@ namespace Subsurface
Game1.GameSession.Level.Render(graphics, cam);
Game1.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
-
- if (Game1.Level != null) Game1.Level.Render(graphics, cam);
-
- if (Game1.LightManager.LightingEnabled)
+ else if (Game1.Level != null)
{
- //multiply scene with lightmap
- spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
- spriteBatch.Draw(Game1.LightManager.LightMap, Vector2.Zero, Color.White);
- spriteBatch.End();
+ Game1.Level.Render(graphics, cam);
}
-
Game1.LightManager.DrawFow(graphics,cam,LightManager.ViewPos);
}
diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj
index 8c8b60537..417b836b4 100644
--- a/Subsurface/Subsurface.csproj
+++ b/Subsurface/Subsurface.csproj
@@ -243,6 +243,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
@@ -394,6 +400,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
@@ -675,6 +684,21 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
@@ -693,7 +717,6 @@
PreserveNewest
-
PreserveNewest
diff --git a/Subsurface/Utils/MathUtils.cs b/Subsurface/Utils/MathUtils.cs
index d1c9e67c4..cafd3178d 100644
--- a/Subsurface/Utils/MathUtils.cs
+++ b/Subsurface/Utils/MathUtils.cs
@@ -152,6 +152,26 @@ namespace Subsurface
return (r >= 0 && r <= 1) && (s >= 0 && s <= 1);
}
+ public static bool CircleIntersectsRectangle(Vector2 circlePos, float radius, Rectangle rect)
+ {
+ Vector2 circleDistance = new Vector2(Math.Abs(circlePos.X - rect.Center.X), Math.Abs(circlePos.Y -rect.Center.Y));
+
+
+
+ if (circleDistance.X > (rect.Width / 2 + radius)) { return false; }
+ if (circleDistance.Y > (rect.Height / 2 + radius)) { return false; }
+
+ if (circleDistance.X <= (rect.Width / 2)) { return true; }
+ if (circleDistance.Y <= (rect.Height / 2)) { return true; }
+
+ float distSqX = circleDistance.X - rect.Width / 2;
+ float distSqY = circleDistance.Y - rect.Height / 2;
+
+ float cornerDistanceSq = distSqX * distSqX + distSqY * distSqY;
+
+ return (cornerDistanceSq <= (radius * radius));
+ }
+
///
/// divide a convex hull into triangles
///
diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo
index fb768adb0..ea8fe93b2 100644
Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ