water ambience sounds change according to speed, oxygengenerator fills oxygen tanks even if their condition is 0, submarine refactoring & bugfixes, wire node editing bugfixes

This commit is contained in:
Regalis
2015-09-24 15:21:10 +03:00
parent f6966f06c3
commit bf7619bcc4
33 changed files with 635 additions and 490 deletions
+2 -2
View File
@@ -245,9 +245,9 @@ namespace Subsurface.Items.Components
public override void UpdateBroken(float deltaTime, Camera cam)
{
body.Enabled = false;
convexHull.Enabled = false;
//convexHull.Enabled = false;
linkedGap.Open = 1.0f;
if (convexHull2 != null) convexHull2.Enabled = false;
//if (convexHull2 != null) convexHull2.Enabled = false;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
@@ -16,6 +16,8 @@ namespace Subsurface.Items.Components
private float range;
private Character user;
[HasDefaultValue(0.0f, false)]
public float Range
{
@@ -45,6 +47,8 @@ namespace Subsurface.Items.Components
if (character == null) return false;
if (!character.GetInputState(InputType.SecondaryHeld) || hitting) return false;
user = character;
if (hitPos < MathHelper.Pi * 0.69f) return false;
item.body.FarseerBody.CollisionCategories = Physics.CollisionProjectile;
@@ -178,7 +182,7 @@ namespace Subsurface.Items.Components
if (target == null) return false;
attack.DoDamage(target, item.Position, 1.0f);
attack.DoDamage(user, target, item.Position, 1.0f);
RestoreCollision();
hitting = false;
+85 -85
View File
@@ -1,106 +1,106 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class Label : ItemComponent
{
GUITextBox textBox;
//namespace Subsurface.Items.Components
//{
// class Label : ItemComponent
// {
// GUITextBox textBox;
private string text;
// private string text;
[HasDefaultValue("", true)]
public string Text
{
get { return text; }
set
{
text = value;
}
}
// [HasDefaultValue("", true)]
// public string Text
// {
// get { return text; }
// set
// {
// text = value;
// }
// }
public Label(Item item, XElement element)
: base(item, element)
{
// public Label(Item item, XElement element)
// : base(item, element)
// {
}
// }
public override bool Select(Character character)
{
if (textBox == null)
{
textBox = new GUITextBox(Rectangle.Empty, GUI.Style, GuiFrame);
textBox.Wrap = true;
textBox.OnTextChanged = TextChanged;
textBox.LimitText = true;
// public override bool Select(Character character)
// {
// if (textBox == null)
// {
// textBox = new GUITextBox(Rectangle.Empty, GUI.Style, GuiFrame);
// textBox.Wrap = true;
// textBox.OnTextChanged = TextChanged;
// textBox.LimitText = true;
GUIButton button = new GUIButton(new Rectangle(0,0,100,15), "OK", null, Alignment.BottomRight, GUI.Style, GuiFrame);
button.OnClicked = Close;
}
// GUIButton button = new GUIButton(new Rectangle(0,0,100,15), "OK", null, Alignment.BottomRight, GUI.Style, GuiFrame);
// button.OnClicked = Close;
// }
textBox.Text = text;
// textBox.Text = text;
textBox.Select();
// textBox.Select();
return base.Select(character);
}
// return base.Select(character);
// }
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
//isActive = true;
GuiFrame.Update((float)Physics.step);
GuiFrame.Draw(spriteBatch);
// public override void DrawHUD(SpriteBatch spriteBatch, Character character)
// {
// //isActive = true;
// GuiFrame.Update((float)Physics.step);
// GuiFrame.Draw(spriteBatch);
//int width = 300, height = 300;
//int x = Game1.GraphicsWidth / 2 - width / 2;
//int y = Game1.GraphicsHeight / 2 - height / 2 - 50;
// //int width = 300, height = 300;
// //int x = Game1.GraphicsWidth / 2 - width / 2;
// //int y = Game1.GraphicsHeight / 2 - height / 2 - 50;
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
if (!textBox.Selected) character.SelectedConstruction = null;
}
// //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
// if (!textBox.Selected) character.SelectedConstruction = null;
// }
private bool TextChanged(GUITextBox textBox, string text)
{
this.text = text;
item.NewComponentEvent(this, true);
// private bool TextChanged(GUITextBox textBox, string text)
// {
// this.text = text;
// item.NewComponentEvent(this, true);
return true;
}
// return true;
// }
private bool Close(GUIButton button, object obj)
{
textBox.Deselect();
// private bool Close(GUIButton button, object obj)
// {
// textBox.Deselect();
return true;
}
// return true;
// }
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
{
message.Write(Text);
}
// public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
// {
// message.Write(Text);
// }
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
{
string newText = "";
try
{
newText = message.ReadString();
}
// public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
// {
// string newText = "";
// try
// {
// newText = message.ReadString();
// }
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("invalid network message", e);
#endif
return;
}
// catch (Exception e)
// {
//#if DEBUG
// DebugConsole.ThrowError("invalid network message", e);
//#endif
// return;
// }
Text = newText;
}
}
}
// Text = newText;
// }
// }
//}
@@ -145,11 +145,11 @@ namespace Subsurface.Items.Components
Structure structure;
if ((limb = (f2.Body.UserData as Limb)) != null)
{
attackResult = attack.DoDamage(limb.character, item.SimPosition, 1.0f);
attackResult = attack.DoDamage(null, limb.character, item.SimPosition, 1.0f);
}
else if ((structure = (f2.Body.UserData as Structure)) != null)
{
attackResult = attack.DoDamage(structure, item.SimPosition, 1.0f);
attackResult = attack.DoDamage(null, structure, item.SimPosition, 1.0f);
}
}
@@ -289,37 +289,39 @@ namespace Subsurface.Items.Components
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 3, (int)-Nodes[i].Y - 3, 6, 6), Color.Red, true, 0.0f);
if (GUIComponent.MouseOn == null &&
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) < 20.0f)
if (GUIComponent.MouseOn != null ||
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) > 20.0f)
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 10, (int)-Nodes[i].Y - 10, 20, 20), Color.Red, false, 0.0f);
continue;
}
if (selectedNodeIndex==null)// && selectedNodeIndex>0 && selectedNodeIndex<Nodes.Count-1)
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 10, (int)-Nodes[i].Y - 10, 20, 20), Color.Red, false, 0.0f);
if (selectedNodeIndex == null && !MapEntity.SelectedAny)
{
if (PlayerInput.LeftButtonDown())
{
if (PlayerInput.LeftButtonDown())
{
MapEntity.SelectEntity(item);
selectedNodeIndex = i;
}
else if (PlayerInput.RightButtonClicked())
{
Nodes.RemoveAt(i);
break;
}
MapEntity.SelectEntity(item);
selectedNodeIndex = i;
MapEntity.DisableSelect = true;
}
else if (PlayerInput.RightButtonClicked())
{
Nodes.RemoveAt(i);
break;
}
}
}
}
if (PlayerInput.LeftButtonDown())
{
if (selectedNodeIndex!=null && item.IsSelected)
if (selectedNodeIndex != null && item.IsSelected)
{
MapEntity.DisableSelect = true;
Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
Vector2 pos = Nodes[(int)selectedNodeIndex];
Nodes[(int)selectedNodeIndex] = RoundNode(Nodes[(int)selectedNodeIndex], Hull.FindHull(Nodes[(int)selectedNodeIndex]));
MapEntity.SelectEntity(item);
}
@@ -328,9 +330,6 @@ namespace Subsurface.Items.Components
{
selectedNodeIndex = null;
}
}
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
+4 -4
View File
@@ -459,11 +459,11 @@ namespace Subsurface
}
public AttackResult AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound = true)
public AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, bool playSound = true)
{
Condition -= amount;
Condition -= attack.Damage;
return new AttackResult(amount, 0.0f, false);
return new AttackResult(attack.Damage, 0.0f, false);
}
@@ -601,7 +601,7 @@ namespace Subsurface
GUI.DrawLine(spriteBatch,
new Vector2(rect.X + rect.Width / 2, -rect.Y + rect.Height / 2),
new Vector2(e.Rect.X + e.Rect.Width / 2, -e.Rect.Y + e.Rect.Height / 2),
Color.Red);
Color.Red*0.3f);
}
}