This commit is contained in:
Regalis
2015-06-07 19:30:42 +03:00
64 changed files with 104 additions and 203 deletions
+8 -13
View File
@@ -331,7 +331,7 @@ namespace Subsurface
selectedTarget = null; selectedTarget = null;
selectedTargetMemory = null; selectedTargetMemory = null;
this.targetValue = 0.0f; targetValue = 0.0f;
UpdateTargetMemories(); UpdateTargetMemories();
@@ -372,7 +372,7 @@ namespace Subsurface
valueModifier = valueModifier * targetMemory.Priority / dist; valueModifier = valueModifier * targetMemory.Priority / dist;
//dist -= targetMemory.Priority; //dist -= targetMemory.Priority;
if (Math.Abs(valueModifier) > Math.Abs(this.targetValue) && (dist < target.SightRange * sight || dist < target.SoundRange * hearing)) if (Math.Abs(valueModifier) > Math.Abs(targetValue) && (dist < target.SightRange * sight || dist < target.SoundRange * hearing))
{ {
Vector2 rayStart = character.animController.limbs[0].SimPosition; Vector2 rayStart = character.animController.limbs[0].SimPosition;
Vector2 rayEnd = target.Position; Vector2 rayEnd = target.Position;
@@ -408,12 +408,12 @@ namespace Subsurface
//float newTargetValue = valueModifier/dist; //float newTargetValue = valueModifier/dist;
if (selectedTarget == null || Math.Abs(valueModifier) > Math.Abs(this.targetValue)) if (selectedTarget == null || Math.Abs(valueModifier) > Math.Abs(targetValue))
{ {
selectedTarget = target; selectedTarget = target;
selectedTargetMemory = targetMemory; selectedTargetMemory = targetMemory;
this.targetValue = valueModifier; targetValue = valueModifier;
Debug.WriteLine(selectedTarget.entity+": "+targetValue); Debug.WriteLine(selectedTarget.entity+": "+targetValue);
} }
} }
@@ -479,18 +479,13 @@ namespace Subsurface
wallAttackPos.X = message.ReadFloat(); wallAttackPos.X = message.ReadFloat();
wallAttackPos.Y = message.ReadFloat(); wallAttackPos.Y = message.ReadFloat();
float wanderAngle = message.ReadFloat(); steeringManager.WanderAngle = message.ReadFloat();
float updateTargetsTimer = message.ReadFloat(); updateTargetsTimer = message.ReadFloat();
float raycastTimer = message.ReadFloat(); raycastTimer = message.ReadFloat();
float coolDownTimer = message.ReadFloat(); coolDownTimer = message.ReadFloat();
int targetID = message.ReadInt32(); int targetID = message.ReadInt32();
steeringManager.WanderAngle = wanderAngle;
this.updateTargetsTimer = updateTargetsTimer;
this.raycastTimer = raycastTimer;
this.coolDownTimer = coolDownTimer;
if (targetID>-1) if (targetID>-1)
targetEntity = Entity.FindEntityByID(targetID) as IDamageable; targetEntity = Entity.FindEntityByID(targetID) as IDamageable;
+1 -1
View File
@@ -30,7 +30,7 @@ namespace Subsurface
public Vector2 GetNode(Vector2 pos) public Vector2 GetNode(Vector2 pos)
{ {
if (nodes.Count == 0) return Vector2.Zero; if (nodes.Count == 0) return Vector2.Zero;
if (currentNode==null || currentNode==Vector2.Zero || Vector2.Distance(pos, currentNode)<minDistance) currentNode = nodes.Dequeue(); if (currentNode==Vector2.Zero || Vector2.Distance(pos, currentNode)<minDistance) currentNode = nodes.Dequeue();
return currentNode; return currentNode;
} }
+8 -9
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
@@ -307,8 +306,8 @@ namespace Subsurface
soundInterval = ToolBox.GetAttributeFloat(doc.Root, "soundinterval", 10.0f); soundInterval = ToolBox.GetAttributeFloat(doc.Root, "soundinterval", 10.0f);
var xSounds = doc.Root.Elements("sound"); var xSounds = doc.Root.Elements("sound").ToList();
if (xSounds.Count() > 0) if (xSounds.Any())
{ {
sounds = new Sound[xSounds.Count()]; sounds = new Sound[xSounds.Count()];
soundStates = new AIController.AiState[xSounds.Count()]; soundStates = new AIController.AiState[xSounds.Count()];
@@ -332,9 +331,9 @@ namespace Subsurface
animController.FindHull(); animController.FindHull();
if (this.info.ID >= 0) if (info.ID >= 0)
{ {
ID = this.info.ID; ID = info.ID;
} }
characterList.Add(this); characterList.Add(this);
@@ -597,12 +596,12 @@ namespace Subsurface
drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f); drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f);
} }
drowningBar.BarSize = Character.Controlled.Oxygen / 100.0f; drowningBar.BarSize = Controlled.Oxygen / 100.0f;
if (drowningBar.BarSize < 1.0f) if (drowningBar.BarSize < 1.0f)
drowningBar.Draw(spriteBatch); drowningBar.Draw(spriteBatch);
if (Character.Controlled.Inventory != null) if (Controlled.Inventory != null)
Character.Controlled.Inventory.Draw(spriteBatch); Controlled.Inventory.Draw(spriteBatch);
if (closestItem!=null) if (closestItem!=null)
{ {
@@ -634,7 +633,7 @@ namespace Subsurface
public void PlaySound(AIController.AiState state) public void PlaySound(AIController.AiState state)
{ {
if (sounds == null || sounds.Count()==0) return; if (sounds == null || !sounds.Any()) return;
var matchingSoundStates = soundStates.Where(x => x == state).ToList(); var matchingSoundStates = soundStates.Where(x => x == state).ToList();
int selectedSound = Game1.localRandom.Next(matchingSoundStates.Count()); int selectedSound = Game1.localRandom.Next(matchingSoundStates.Count());
+2 -5
View File
@@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface namespace Subsurface
@@ -39,7 +36,7 @@ namespace Subsurface
this.character = character; this.character = character;
this.limb = limb; this.limb = limb;
this.timer = delay; timer = delay;
list.Add(this); list.Add(this);
} }
@@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
@@ -33,7 +32,7 @@ namespace Subsurface
{ {
case Physics.CollisionStairs: case Physics.CollisionStairs:
Structure structure = fixture.Body.UserData as Structure; Structure structure = fixture.Body.UserData as Structure;
if (stairs == null && (!inWater || TargetMovement.Y>0.0f)) if (stairs == null && (!inWater || TargetMovement.Y>0.0f) && structure!=null)
{ {
if (LowestLimb.SimPosition.Y<structure.SimPosition.Y) if (LowestLimb.SimPosition.Y<structure.SimPosition.Y)
{ {
+2 -4
View File
@@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface namespace Subsurface
@@ -47,6 +44,7 @@ namespace Subsurface
jobList = new List<Job>(); jobList = new List<Job>();
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return;
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
-1
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
-4
View File
@@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
@@ -9,8 +7,6 @@ namespace Subsurface
{ {
class StatusEffect class StatusEffect
{ {
[Flags] [Flags]
public enum Target public enum Target
{ {
+4 -4
View File
@@ -48,13 +48,13 @@ namespace Subsurface
set { lifeTime = value; } set { lifeTime = value; }
} }
public GUIMessage(string text, Color color, Vector2 pos, float lifeTime) public GUIMessage(string text, Color color, Vector2 position, float lifeTime)
{ {
this.coloredText = new ColoredText(text, color); coloredText = new ColoredText(text, color);
this.pos = pos; pos = position;
this.lifeTime = lifeTime; this.lifeTime = lifeTime;
this.size = GUI.font.MeasureString(text); size = GUI.font.MeasureString(text);
} }
} }
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Subsurface
if (parent != null) if (parent != null)
parent.AddChild(this); parent.AddChild(this);
this.textBlock = new GUITextBlock(new Rectangle(0,0,0,0), text, Color.Transparent, Color.Black, (Alignment.CenterX | Alignment.CenterY), this); textBlock = new GUITextBlock(new Rectangle(0,0,0,0), text, Color.Transparent, Color.Black, (Alignment.CenterX | Alignment.CenterY), this);
} }
+1 -3
View File
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface namespace Subsurface
{ {
@@ -31,6 +28,7 @@ namespace Subsurface
if (buttons == null || buttons.Length == 0) if (buttons == null || buttons.Length == 0)
{ {
DebugConsole.ThrowError("Creating a message box with no buttons isn't allowed"); DebugConsole.ThrowError("Creating a message box with no buttons isn't allowed");
return;
} }
new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true); new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true);
+1 -1
View File
@@ -119,7 +119,7 @@ namespace Subsurface
if (wrap && rect.Width>0) if (wrap && rect.Width>0)
{ {
text = text.Replace("\n"," "); text = text.Replace("\n"," ");
this.text = ToolBox.WrapText(this.text, rect.Width); text = ToolBox.WrapText(text, rect.Width);
Vector2 newSize = MeasureText(); Vector2 newSize = MeasureText();
-1
View File
@@ -5,7 +5,6 @@ using FarseerPhysics;
using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Subsurface.Networking; using Subsurface.Networking;
using Subsurface.Particles; using Subsurface.Particles;
+1 -1
View File
@@ -95,7 +95,7 @@ namespace Subsurface
frame); frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
GUIImage face = new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame); new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame);
} }
public void KillCharacter(Character killedCharacter) public void KillCharacter(Character killedCharacter)
-2
View File
@@ -1,6 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Subsurface namespace Subsurface
{ {
@@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface namespace Subsurface
{ {
@@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq; using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
using FarseerPhysics.Dynamics.Joints; using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
+1 -1
View File
@@ -123,7 +123,7 @@ namespace Subsurface.Items.Components
Vector2[] corners = GetConvexHullCorners(doorRect); Vector2[] corners = GetConvexHullCorners(doorRect);
convexHull = new ConvexHull(corners, Color.Black); convexHull = new ConvexHull(corners, Color.Black);
if (window!=null && window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black); if (window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black);
UpdateConvexHulls(); UpdateConvexHulls();
+2 -3
View File
@@ -1,5 +1,4 @@
using System.Diagnostics; using System.Xml.Linq;
using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
@@ -62,7 +61,7 @@ namespace Subsurface.Items.Components
} }
[HasDefaultValue(0.0f, false)] [HasDefaultValue(0.0f, false)]
private float HoldAngle public float HoldAngle
{ {
get { return MathHelper.ToDegrees(holdAngle); } get { return MathHelper.ToDegrees(holdAngle); }
set { holdAngle = MathHelper.ToRadians(value); } set { holdAngle = MathHelper.ToRadians(value); }
+3 -8
View File
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Xml.Linq; using System.Xml.Linq;
@@ -277,10 +276,10 @@ namespace Subsurface
public bool HasRequiredContainedItems(bool addMessage) public bool HasRequiredContainedItems(bool addMessage)
{ {
if (requiredItems.Count() == 0) return true; if (!requiredItems.Any()) return true;
Item[] containedItems = item.ContainedItems; Item[] containedItems = item.ContainedItems;
if (containedItems == null || containedItems.Count() == 0) return false; if (containedItems == null || !containedItems.Any()) return false;
foreach (RelatedItem ri in requiredItems) foreach (RelatedItem ri in requiredItems)
{ {
@@ -298,7 +297,7 @@ namespace Subsurface
public bool HasRequiredEquippedItems(Character character, bool addMessage) public bool HasRequiredEquippedItems(Character character, bool addMessage)
{ {
if (requiredItems.Count() == 0) return true; if (!requiredItems.Any()) return true;
foreach (RelatedItem ri in requiredItems) foreach (RelatedItem ri in requiredItems)
{ {
@@ -325,10 +324,6 @@ namespace Subsurface
return false; return false;
} }
} }
else
{
continue;
}
} }
return true; return true;
@@ -24,10 +24,8 @@ namespace Subsurface.Items.Components
ventList = new List<Vent>(); ventList = new List<Vent>();
item.linkedTo.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler( item.linkedTo.CollectionChanged += delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { GetVents(); };
{ GetVents(); }
);
} }
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
-1
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
+4 -1
View File
@@ -3,6 +3,7 @@ using System.Xml.Linq;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Globalization;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
@@ -48,7 +49,9 @@ namespace Subsurface.Items.Components
{ {
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia; pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia; pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
pt.Item.SendSignal((fullPower / Math.Max(fullLoad,1.0f)).ToString(), "power_out"); pt.Item.SendSignal(
(fullPower / Math.Max(fullLoad,1.0f)).ToString(CultureInfo.InvariantCulture),
"power_out");
} }
else else
+3 -10
View File
@@ -1,9 +1,4 @@
using Microsoft.Xna.Framework; using System.Collections.Specialized;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -29,10 +24,8 @@ namespace Subsurface.Items.Components
{ {
//maxFlow = ToolBox.GetAttributeFloat(element, "maxflow", 100.0f); //maxFlow = ToolBox.GetAttributeFloat(element, "maxflow", 100.0f);
item.linkedTo.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler( item.linkedTo.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { GetHulls(); };
{ GetHulls(); }
);
} }
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
+1 -1
View File
@@ -61,7 +61,7 @@ namespace Subsurface.Items.Components
} }
Item[] containedItems = item.ContainedItems; Item[] containedItems = item.ContainedItems;
if (containedItems == null || containedItems.Count()==0) return false; if (containedItems == null || !containedItems.Any()) return false;
foreach (Item projectile in containedItems) foreach (Item projectile in containedItems)
{ {
-1
View File
@@ -5,7 +5,6 @@ using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Subsurface.Networking; using Subsurface.Networking;
using System.Globalization;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
+6 -3
View File
@@ -19,20 +19,23 @@ namespace Subsurface.Items.Components
float structureFixAmount, limbFixAmount; float structureFixAmount, limbFixAmount;
[HasDefaultValue(100.0f, false)] [HasDefaultValue(100.0f, false)]
private float Range public float Range
{ {
get { return ConvertUnits.ToDisplayUnits(range); }
set { range = ConvertUnits.ToSimUnits(value); } set { range = ConvertUnits.ToSimUnits(value); }
} }
[HasDefaultValue(1.0f, false)] [HasDefaultValue(1.0f, false)]
private float StructureFixAmount public float StructureFixAmount
{ {
get { return structureFixAmount; }
set { structureFixAmount = value; } set { structureFixAmount = value; }
} }
[HasDefaultValue(1.0f, false)] [HasDefaultValue(1.0f, false)]
private float LimbFixAmount public float LimbFixAmount
{ {
get { return limbFixAmount; }
set { limbFixAmount = value; } set { limbFixAmount = value; }
} }
+2 -2
View File
@@ -282,7 +282,7 @@ namespace Subsurface.Items.Components
isActive = true; isActive = true;
this.projectile = projectile; this.projectile = projectile;
Projectile projectileComponent = projectile.GetComponent<Projectile>(); //Projectile projectileComponent = projectile.GetComponent<Projectile>();
foreach (PhysicsBody b in ropeBodies) foreach (PhysicsBody b in ropeBodies)
{ {
@@ -313,7 +313,7 @@ namespace Subsurface.Items.Components
{ {
float rotation = (item.body.Dir == -1.0f) ? item.body.Rotation - MathHelper.Pi : item.body.Rotation; float rotation = (item.body.Dir == -1.0f) ? item.body.Rotation - MathHelper.Pi : item.body.Rotation;
body.SetTransform(TransformedBarrelPos, rotation); body.SetTransform(TransformedBarrelPos, rotation);
Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)); //Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
if (gunJoint != null) Game1.world.RemoveJoint(gunJoint); if (gunJoint != null) Game1.world.RemoveJoint(gunJoint);
gunJoint = new DistanceJoint(item.body.FarseerBody, body, BarrelPos, gunJoint = new DistanceJoint(item.body.FarseerBody, body, BarrelPos,
@@ -1,5 +1,4 @@
using System; using System;
using System.Globalization;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -409,7 +408,7 @@ namespace Subsurface.Items.Components
{ {
if (wires[i] == null) continue; if (wires[i] == null) continue;
Connection recipient = wires[i].OtherConnection(this); //Connection recipient = wires[i].OtherConnection(this);
//int connectionIndex = recipient.item.Connections.FindIndex(x => x == recipient); //int connectionIndex = recipient.item.Connections.FindIndex(x => x == recipient);
newElement.Add(new XElement("link", newElement.Add(new XElement("link",
@@ -1,9 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -1,8 +1,4 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -50,7 +46,7 @@ namespace Subsurface.Items.Components
isActive = !isActive; isActive = !isActive;
break; break;
case "set_state": case "set_state":
isActive = (signal == "0") ? false : true; isActive = (signal != "0");
break; break;
} }
} }
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
@@ -48,14 +48,7 @@ namespace Subsurface.Items.Components
return; return;
} }
if (success) item.SendSignal(success ? output : "0", "signal_out", item);
{
item.SendSignal(output, "signal_out", item);
}
else
{
item.SendSignal("0", "signal_out", item);
}
break; break;
case "set_output": case "set_output":
@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
-6
View File
@@ -1,9 +1,5 @@
using FarseerPhysics; using FarseerPhysics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
@@ -98,8 +94,6 @@ namespace Subsurface.Items.Components
item.Drop(); item.Drop();
item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f); item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f);
} }
return;
} }
} }
} }
+1 -2
View File
@@ -4,7 +4,6 @@ using System.IO;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System.Globalization;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
@@ -152,7 +151,7 @@ namespace Subsurface.Items.Components
currPowerConsumption = powerConsumption; currPowerConsumption = powerConsumption;
float availablePower = 0.0f; float availablePower = 0.0f;
List<PowerContainer> batteries = new List<PowerContainer>(); //List<PowerContainer> batteries = new List<PowerContainer>();
foreach (MapEntity e in item.linkedTo) foreach (MapEntity e in item.linkedTo)
{ {
Item battery = e as Item; Item battery = e as Item;
-2
View File
@@ -2,8 +2,6 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.Xna.Framework;
using System.Diagnostics;
namespace Subsurface.Items.Components namespace Subsurface.Items.Components
{ {
+2 -6
View File
@@ -437,7 +437,7 @@ namespace Subsurface
body.ResetDynamics(); body.ResetDynamics();
if (body.Position.Length() > 1000.0f) if (body.Position.Length() > 1000.0f)
{ {
this.Remove(); Remove();
return; return;
} }
} }
@@ -955,7 +955,7 @@ namespace Subsurface
{ {
int index = components.IndexOf(ic); int index = components.IndexOf(ic);
new NetworkEvent(NetworkEventType.UpdateComponent, this.ID, isClient, index); new NetworkEvent(NetworkEventType.UpdateComponent, ID, isClient, index);
} }
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data) public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
@@ -969,8 +969,6 @@ namespace Subsurface
message.Write((int)data); message.Write((int)data);
components[(int)data].FillNetworkData(type, message); components[(int)data].FillNetworkData(type, message);
break; break;
default:
break;
} }
} }
@@ -987,8 +985,6 @@ namespace Subsurface
if (componentIndex < 0 || componentIndex > components.Count - 1) return; if (componentIndex < 0 || componentIndex > components.Count - 1) return;
components[componentIndex].ReadNetworkData(type, message); components[componentIndex].ReadNetworkData(type, message);
break; break;
default:
break;
} }
} }
+1 -1
View File
@@ -79,7 +79,7 @@ namespace Subsurface
public virtual void Remove() public virtual void Remove()
{ {
dictionary.Remove(this.ID); dictionary.Remove(ID);
} }
} }
} }
-2
View File
@@ -2,8 +2,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface namespace Subsurface
+1 -1
View File
@@ -195,7 +195,7 @@ namespace Subsurface
GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr); GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr);
if (isSelected && editing) if (isSelected)
{ {
GUI.DrawRectangle(sb, GUI.DrawRectangle(sb,
new Vector2(rect.X - 5, -rect.Y - 5), new Vector2(rect.X - 5, -rect.Y - 5),
+4 -4
View File
@@ -121,7 +121,7 @@ namespace Subsurface
OxygenPercentage = (float)(Game1.random.NextDouble() * 100.0); OxygenPercentage = (float)(Game1.random.NextDouble() * 100.0);
properties = TypeDescriptor.GetProperties(this.GetType()) properties = TypeDescriptor.GetProperties(GetType())
.Cast<PropertyDescriptor>() .Cast<PropertyDescriptor>()
.ToDictionary(pr => pr.Name); .ToDictionary(pr => pr.Name);
@@ -193,7 +193,7 @@ namespace Subsurface
{ {
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonDown())
{ {
waveY[(int)(position.X - rect.X) / Hull.WaveWidth] = 100.0f; waveY[(int)(position.X - rect.X) / WaveWidth] = 100.0f;
Volume = Volume + 1500.0f; Volume = Volume + 1500.0f;
} }
else if (PlayerInput.GetMouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) else if (PlayerInput.GetMouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
@@ -290,8 +290,8 @@ namespace Subsurface
spriteBatch.DrawString(GUI.font, "Pressure: " + ((int)pressure - rect.Y).ToString() + spriteBatch.DrawString(GUI.font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
" - Lethality: " + lethalPressure + " - Lethality: " + lethalPressure +
" - Oxygen: "+((int)OxygenPercentage).ToString(), new Vector2(rect.X+10, -rect.Y+10), Color.Black); " - Oxygen: "+((int)OxygenPercentage), new Vector2(rect.X+10, -rect.Y+10), Color.Black);
spriteBatch.DrawString(GUI.font, volume.ToString() +" / "+ FullVolume.ToString(), new Vector2(rect.X+10, -rect.Y+30), Color.Black); spriteBatch.DrawString(GUI.font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black);
if (isSelected && editing) if (isSelected && editing)
{ {
-2
View File
@@ -1,9 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Subsurface.Lights namespace Subsurface.Lights
{ {
-4
View File
@@ -1,9 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface.Lights namespace Subsurface.Lights
{ {
+3 -3
View File
@@ -251,7 +251,7 @@ namespace Subsurface
public static bool InsideWall(Vector2 point) public static bool InsideWall(Vector2 point)
{ {
Body foundBody = Map.PickBody(point); Body foundBody = PickBody(point);
if (foundBody==null) return false; if (foundBody==null) return false;
Structure wall = foundBody.UserData as Structure; Structure wall = foundBody.UserData as Structure;
@@ -286,7 +286,7 @@ namespace Subsurface
try try
{ {
string docString = doc.ToString(); //string docString = doc.ToString();
ToolBox.CompressStringToFile(filePath+".gz", doc.ToString()); ToolBox.CompressStringToFile(filePath+".gz", doc.ToString());
} }
catch catch
@@ -342,7 +342,7 @@ namespace Subsurface
public Map(string filePath, string mapHash="") public Map(string filePath, string mapHash="")
{ {
this.filePath = filePath; this.filePath = filePath;
this.name = Path.GetFileNameWithoutExtension(filePath); name = Path.GetFileNameWithoutExtension(filePath);
if (mapHash != "") if (mapHash != "")
{ {
+1 -1
View File
@@ -393,7 +393,7 @@ namespace Subsurface
public virtual XElement Save(XDocument doc) public virtual XElement Save(XDocument doc)
{ {
DebugConsole.ThrowError("Saving entity " + this.GetType() + " failed."); DebugConsole.ThrowError("Saving entity " + GetType() + " failed.");
return null; return null;
} }
+1 -1
View File
@@ -75,7 +75,7 @@ namespace Subsurface
{ {
Vector2 placeSize = Map.gridSize; Vector2 placeSize = Map.gridSize;
if (placePosition == null || placePosition == Vector2.Zero) if (placePosition == Vector2.Zero)
{ {
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
placePosition = Map.MouseToWorldGrid(cam); placePosition = Map.MouseToWorldGrid(cam);
+1 -1
View File
@@ -32,7 +32,7 @@ namespace Subsurface
public void TransformTexCoord(Matrix transform) public void TransformTexCoord(Matrix transform)
{ {
this.texCoord = Vector2.Transform(this.texCoord, transform); texCoord = Vector2.Transform(texCoord, transform);
} }
} }
+1 -1
View File
@@ -89,7 +89,7 @@ namespace Subsurface
wayPoints.Add(wayPoint); wayPoints.Add(wayPoint);
} }
if (wayPoints.Count() == 0) return null; if (!wayPoints.Any()) return null;
return wayPoints[Game1.random.Next(wayPoints.Count())]; return wayPoints[Game1.random.Next(wayPoints.Count())];
} }
+3 -3
View File
@@ -40,11 +40,11 @@ namespace Subsurface.Networking
} }
} }
public GameClient(string name) public GameClient(string newName)
{ {
this.name = name; name = newName;
this.characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name); characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name);
} }
public bool ConnectToServer(string hostIP) public bool ConnectToServer(string hostIP)
+2 -2
View File
@@ -60,7 +60,7 @@ namespace Subsurface.Networking
if (Game1.server == null) return; if (Game1.server == null) return;
} }
this.eventType = type; eventType = type;
foreach (NetworkEvent e in events) foreach (NetworkEvent e in events)
{ {
@@ -68,7 +68,7 @@ namespace Subsurface.Networking
} }
this.id = id; this.id = id;
this.isClientEvent = isClient; isClientEvent = isClient;
this.data = data; this.data = data;
+2 -3
View File
@@ -1,5 +1,4 @@
using System; using System.Xml.Linq;
using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories; using FarseerPhysics.Factories;
@@ -190,7 +189,7 @@ namespace Subsurface
else if (radius != 0.0f) else if (radius != 0.0f)
{ {
body = BodyFactory.CreateCircle(Game1.world, radius, density); body = BodyFactory.CreateCircle(Game1.world, radius, density);
bodyShape = Shape.Circle; ; bodyShape = Shape.Circle;
} }
else else
{ {
+4 -5
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Subsurface namespace Subsurface
@@ -93,7 +92,7 @@ namespace Subsurface
} }
else else
{ {
DebugConsole.ThrowError("Failed to set the value of the property ''" + Name + "'' of ''" + obj.ToString() + "'' to " + value.ToString()); DebugConsole.ThrowError("Failed to set the value of the property ''" + Name + "'' of ''" + obj + "'' to " + value);
DebugConsole.ThrowError("(Type not implemented)"); DebugConsole.ThrowError("(Type not implemented)");
return false; return false;
@@ -146,7 +145,7 @@ namespace Subsurface
foreach (var property in obj.ObjectProperties.Values) foreach (var property in obj.ObjectProperties.Values)
{ {
if (property.Attributes.OfType<T>().Count() > 0) editableProperties.Add(property); if (property.Attributes.OfType<T>().Any()) editableProperties.Add(property);
} }
return editableProperties; return editableProperties;
@@ -200,7 +199,7 @@ namespace Subsurface
public static void SaveProperties(IPropertyObject obj, XElement element) public static void SaveProperties(IPropertyObject obj, XElement element)
{ {
var saveProperties = ObjectProperty.GetProperties<HasDefaultValue>(obj); var saveProperties = GetProperties<HasDefaultValue>(obj);
foreach (var property in saveProperties) foreach (var property in saveProperties)
{ {
object value = property.GetValue(); object value = property.GetValue();
@@ -220,7 +219,7 @@ namespace Subsurface
if (dontSave) continue; if (dontSave) continue;
string stringValue; string stringValue;
if (value.GetType() == typeof(float)) if (value is float)
{ {
//do this to make sure the decimal point isn't converted to a comma or anything like that //do this to make sure the decimal point isn't converted to a comma or anything like that
stringValue = ((float)value).ToString("G", CultureInfo.InvariantCulture); stringValue = ((float)value).ToString("G", CultureInfo.InvariantCulture);
@@ -35,12 +35,6 @@ namespace Subsurface
get { return cam; } get { return cam; }
} }
public EditCharacterScreen()
{
}
public override void Select() public override void Select()
{ {
base.Select(); base.Select();
-1
View File
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using Subsurface.Lights; using Subsurface.Lights;
using FarseerPhysics;
namespace Subsurface namespace Subsurface
{ {
-1
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Subsurface.Networking; using Subsurface.Networking;
+2 -4
View File
@@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.IO;
using Lidgren.Network; using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@@ -128,8 +126,8 @@ namespace Subsurface
textBox.Select(); textBox.Select();
int oldMapIndex = 0; //int oldMapIndex = 0;
if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex; //if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex;
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, infoFrame); new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, infoFrame);
mapList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, infoFrame); mapList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, infoFrame);
+1 -2
View File
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface namespace Subsurface
{ {
+3 -5
View File
@@ -35,8 +35,6 @@ namespace Subsurface
static class AmbientSoundManager static class AmbientSoundManager
{ {
private static Sound[] music = new Sound[4];
public static Sound[] flowSounds = new Sound[3]; public static Sound[] flowSounds = new Sound[3];
private static Sound waterAmbience; private static Sound waterAmbience;
@@ -57,9 +55,9 @@ namespace Subsurface
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return; if (doc == null) return;
var xDamageSounds = doc.Root.Elements("damagesound"); var xDamageSounds = doc.Root.Elements("damagesound").ToList();
if (xDamageSounds.Count()>0) if (!xDamageSounds.Any())
{ {
damageSounds = new DamageSound[xDamageSounds.Count()]; damageSounds = new DamageSound[xDamageSounds.Count()];
int i = 0; int i = 0;
@@ -124,7 +122,7 @@ namespace Subsurface
{ {
damage = MathHelper.Clamp(damage, 0.0f, 100.0f); damage = MathHelper.Clamp(damage, 0.0f, 100.0f);
var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList(); var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList();
if (sounds.Count() == 0) return; if (!sounds.Any()) return;
int selectedSound = Game1.localRandom.Next(sounds.Count()); int selectedSound = Game1.localRandom.Next(sounds.Count());
+2 -2
View File
@@ -204,14 +204,14 @@ namespace Subsurface
{ {
loadedSounds.Remove(this); loadedSounds.Remove(this);
System.Diagnostics.Debug.WriteLine(this.AlBufferId); System.Diagnostics.Debug.WriteLine(AlBufferId);
foreach (Sound s in loadedSounds) foreach (Sound s in loadedSounds)
{ {
if (s.oggSound == oggSound) return; if (s.oggSound == oggSound) return;
} }
SoundManager.ClearAlSource(this.AlBufferId); SoundManager.ClearAlSource(AlBufferId);
oggSound.Dispose(); oggSound.Dispose();
} }
+4 -4
View File
@@ -126,9 +126,9 @@ namespace Subsurface
{ {
this.texture = texture; this.texture = texture;
sourceRect = (sourceRectangle == null) ? new Rectangle(1, 1, texture.Width, texture.Height) : (Rectangle)sourceRectangle; sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height);
offset = (newOffset == null) ? Vector2.Zero : (Vector2)newOffset; offset = newOffset ?? Vector2.Zero;
size = new Vector2(sourceRect.Width, sourceRect.Height); size = new Vector2(sourceRect.Width, sourceRect.Height);
@@ -146,9 +146,9 @@ namespace Subsurface
file = newFile; file = newFile;
texture = LoadTexture(file); texture = LoadTexture(file);
sourceRect = (sourceRectangle == null) ? new Rectangle(1,1,texture.Width,texture.Height) : (Rectangle)sourceRectangle; sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height);
offset = (newOffset == null) ? Vector2.Zero : (Vector2)newOffset; offset = newOffset ?? Vector2.Zero;
size = new Vector2(sourceRect.Width, sourceRect.Height); size = new Vector2(sourceRect.Width, sourceRect.Height);
+1 -1
View File
@@ -444,7 +444,7 @@ namespace Subsurface
string randomLine = ""; string randomLine = "";
StreamReader file = new StreamReader(filePath); StreamReader file = new StreamReader(filePath);
var lines = File.ReadLines(filePath); var lines = File.ReadLines(filePath).ToList();
int lineCount = lines.Count(); int lineCount = lines.Count();
if (lineCount == 0) if (lineCount == 0)