Reliablesender exception handling, buttons crashing multiplayer, using screwdrivers/wrenches with left click, RestoreCollision exception handling, nerfed c4, UpdateLimbCollisionCategories fix
This commit is contained in:
@@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
attached = true;
|
||||
|
||||
item.NewComponentEvent(this, true, true);
|
||||
if (character != null) item.NewComponentEvent(this, true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Barotrauma.Items.Components
|
||||
if (picker == null) return false;
|
||||
if (picker.Inventory == null) return false;
|
||||
|
||||
if (picker.Inventory.TryPutItem(item, allowedSlots))
|
||||
if (picker.Inventory.TryPutItem(item, allowedSlots, picker==Character.Controlled))
|
||||
{
|
||||
if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false;
|
||||
this.picker = picker;
|
||||
|
||||
@@ -108,6 +108,18 @@ namespace Barotrauma.Items.Components
|
||||
set { canBeSelected = value; }
|
||||
}
|
||||
|
||||
public InputType PickKey
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public InputType SelectKey
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[HasDefaultValue(false, false)]
|
||||
public bool DeleteOnUse
|
||||
{
|
||||
@@ -166,24 +178,26 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
statusEffects = new List<StatusEffect>();
|
||||
|
||||
//var initableProperties = ObjectProperty.GetProperties<Initable>(this);
|
||||
//foreach (ObjectProperty initableProperty in initableProperties)
|
||||
//{
|
||||
// object value = ToolBox.GetAttributeObject(element, initableProperty.Name.ToLower());
|
||||
// if (value==null)
|
||||
// {
|
||||
// foreach (var ini in initableProperty.Attributes.OfType<Initable>())
|
||||
// {
|
||||
// value = ini.defaultValue;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
SelectKey = InputType.Select;
|
||||
|
||||
// initableProperty.TrySetValue(value);
|
||||
//}
|
||||
if (item.Name=="Welding Tool")
|
||||
try
|
||||
{
|
||||
int a = 1;
|
||||
SelectKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid select key in " + element + "!", e);
|
||||
}
|
||||
|
||||
PickKey = InputType.Select;
|
||||
|
||||
try
|
||||
{
|
||||
PickKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e);
|
||||
}
|
||||
|
||||
properties = ObjectProperty.InitProperties(this, element);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (voltage < minVoltage) return;
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Radar"))
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 200, 30), "Activate Sonar"))
|
||||
{
|
||||
IsActive = !IsActive;
|
||||
item.NewComponentEvent(this, true, false);
|
||||
|
||||
@@ -119,11 +119,31 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (stickTarget!=null)
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
try
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
|
||||
#endif
|
||||
}
|
||||
|
||||
stickTarget = null;
|
||||
}
|
||||
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
try
|
||||
{
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to remove stickJoint", e);
|
||||
#endif
|
||||
}
|
||||
|
||||
stickJoint = null;
|
||||
|
||||
IsActive = false;
|
||||
|
||||
@@ -420,11 +420,17 @@ namespace Barotrauma.Items.Components
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
||||
{
|
||||
Nodes.Clear();
|
||||
|
||||
List<Vector2> newNodes = new List<Vector2>();
|
||||
int nodeCount = message.ReadByte();
|
||||
for (int i = 0; i<nodeCount; i++)
|
||||
{
|
||||
Nodes.Add(new Vector2(message.ReadFloat(), message.ReadFloat()));
|
||||
Vector2 newNode = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
if (!MathUtils.IsValid(newNode)) return;
|
||||
newNodes.Add(newNode);
|
||||
}
|
||||
|
||||
Nodes = newNodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ namespace Barotrauma
|
||||
item.Drop(null, false);
|
||||
return;
|
||||
}
|
||||
public void DropItem(int i)
|
||||
{
|
||||
items[i].Drop();
|
||||
items[i] = null;
|
||||
}
|
||||
//public void DropItem(int i)
|
||||
//{
|
||||
// items[i].Drop();
|
||||
// items[i] = null;
|
||||
//}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
@@ -194,8 +194,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (Owner!=null)
|
||||
{
|
||||
ushort[] data = { draggingItem.ID, 0 };
|
||||
new NetworkEvent(NetworkEventType.InventoryUpdate, Owner.ID, true, data);
|
||||
new NetworkEvent(NetworkEventType.InventoryUpdate, Owner.ID, true);
|
||||
}
|
||||
|
||||
DropItem(draggingItem);
|
||||
@@ -281,8 +280,14 @@ namespace Barotrauma
|
||||
Vector2 pos = new Vector2(rect.X + rect.Width / 2, rect.Y - rect.Height + 20) - GUI.Font.MeasureString(item.Name) * 0.5f;
|
||||
pos.X = (int)pos.X;
|
||||
pos.Y = (int)pos.Y;
|
||||
#if DEBUG
|
||||
spriteBatch.DrawString(GUI.Font, item.Name+" - "+item.ID, pos - new Vector2(1.0f, 1.0f), Color.Black);
|
||||
spriteBatch.DrawString(GUI.Font, item.Name+" - "+item.ID, pos, Color.White);
|
||||
#else
|
||||
spriteBatch.DrawString(GUI.Font, item.Name, pos - new Vector2(1.0f, 1.0f), Color.Black);
|
||||
spriteBatch.DrawString(GUI.Font, item.Name, pos, Color.White);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (item.Condition < 100.0f)
|
||||
|
||||
@@ -853,9 +853,9 @@ namespace Barotrauma
|
||||
return closest;
|
||||
}
|
||||
|
||||
public bool Pick(Character picker, bool forcePick=false)
|
||||
public bool Pick(Character picker, bool ignoreRequiredItems=false, bool forceSelectKey=false, bool forceActionKey=false)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Item.Pick("+picker+", "+forcePick+")");
|
||||
|
||||
bool hasRequiredSkills = true;
|
||||
|
||||
bool picked = false, selected = false;
|
||||
@@ -864,13 +864,42 @@ namespace Barotrauma
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
bool pickHit = false, selectHit = false;
|
||||
if (Screen.Selected == GameMain.EditMapScreen)
|
||||
{
|
||||
pickHit = picker.GetInputState(InputType.Select);
|
||||
selectHit = picker.GetInputState(InputType.Select);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (forceSelectKey)
|
||||
{
|
||||
if (ic.PickKey == InputType.Select) pickHit = true;
|
||||
if (ic.SelectKey == InputType.Select) selectHit = true;
|
||||
}
|
||||
else if (forceActionKey)
|
||||
{
|
||||
if (ic.PickKey == InputType.ActionHit) pickHit = true;
|
||||
if (ic.SelectKey == InputType.ActionHit) selectHit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pickHit = picker.GetInputState(ic.PickKey);
|
||||
selectHit = picker.GetInputState(ic.SelectKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!pickHit && !selectHit) continue;
|
||||
|
||||
Skill tempRequiredSkill;
|
||||
if (!ic.HasRequiredSkills(picker, out tempRequiredSkill)) hasRequiredSkills = false;
|
||||
|
||||
if (tempRequiredSkill != null) requiredSkill = tempRequiredSkill;
|
||||
|
||||
if (!forcePick && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue;
|
||||
if ((ic.CanBePicked && ic.Pick(picker)) || (ic.CanBeSelected && ic.Select(picker)))
|
||||
if (!ignoreRequiredItems && !ic.HasRequiredItems(picker, picker == Character.Controlled)) continue;
|
||||
if ((ic.CanBePicked && pickHit && ic.Pick(picker)) ||
|
||||
(ic.CanBeSelected && selectHit && ic.Select(picker)))
|
||||
{
|
||||
picked = true;
|
||||
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
|
||||
@@ -879,9 +908,16 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
if (!picked) return false;
|
||||
if (selected)
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Item.Pick(" + picker + ", " + forceSelectKey + ")");
|
||||
|
||||
if (picker.SelectedConstruction == this)
|
||||
{
|
||||
picker.SelectedConstruction = (picker.SelectedConstruction == this) ? null : this;
|
||||
if (picker.GetInputState(InputType.Select)) picker.SelectedConstruction = null;
|
||||
}
|
||||
else if (selected)
|
||||
{
|
||||
picker.SelectedConstruction = this;
|
||||
}
|
||||
|
||||
if (!hasRequiredSkills && Character.Controlled==picker)
|
||||
@@ -1177,7 +1213,7 @@ namespace Barotrauma
|
||||
|
||||
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
|
||||
{
|
||||
message.Write(condition);
|
||||
message.Write((byte)MathHelper.Clamp(condition*2.55f,0.0f,255.0f));
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -1244,7 +1280,7 @@ namespace Barotrauma
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
{
|
||||
Condition = message.ReadFloat();
|
||||
Condition = (float)message.ReadByte()/2.55f;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user