PhysicsBodyPosition networkevents aren't sent for items that are inside an inventory (e.g. carried by a character), items can be moved from the inventory to containers by double clicking

This commit is contained in:
Regalis
2016-05-11 20:22:32 +03:00
parent d1e9be188f
commit 11e4f5699f
3 changed files with 24 additions and 6 deletions
+22 -2
View File
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Input;
using Barotrauma.Networking; using Barotrauma.Networking;
using Lidgren.Network; using Lidgren.Network;
using System.Collections.Generic; using System.Collections.Generic;
using Barotrauma.Items.Components;
namespace Barotrauma namespace Barotrauma
{ {
@@ -282,10 +283,29 @@ namespace Barotrauma
string toolTip = ""; string toolTip = "";
Rectangle highlightedSlot = Rectangle.Empty; Rectangle highlightedSlot = Rectangle.Empty;
if (doubleClickedItem!=null && doubleClickedItem.ParentInventory!=this) if (doubleClickedItem != null)
{ {
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true); if (doubleClickedItem.ParentInventory != this)
{
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
}
else
{
if (character.SelectedConstruction != null)
{
var selectedContainer = character.SelectedConstruction.GetComponent<ItemContainer>();
if (selectedContainer != null && selectedContainer.Inventory != null)
{
selectedContainer.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
}
}
else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
{
character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
}
}
} }
doubleClickedItem = null; doubleClickedItem = null;
const int rectWidth = 40, rectHeight = 40; const int rectWidth = 40, rectHeight = 40;
-2
View File
@@ -169,8 +169,6 @@ namespace Barotrauma
public virtual void Draw(SpriteBatch spriteBatch) public virtual void Draw(SpriteBatch spriteBatch)
{ {
doubleClickedItem = null;
string toolTip = ""; string toolTip = "";
int rectWidth = 40, rectHeight = 40; int rectWidth = 40, rectHeight = 40;
+1 -1
View File
@@ -701,7 +701,7 @@ namespace Barotrauma
FindHull(); FindHull();
Vector2 moveAmount = body.SimPosition - body.LastSentPosition; Vector2 moveAmount = body.SimPosition - body.LastSentPosition;
if (moveAmount != Vector2.Zero && moveAmount.Length() > NetConfig.ItemPosUpdateDistance) if (parentInventory == null && moveAmount != Vector2.Zero && moveAmount.Length() > NetConfig.ItemPosUpdateDistance)
{ {
new NetworkEvent(NetworkEventType.PhysicsBodyPosition, ID, false); new NetworkEvent(NetworkEventType.PhysicsBodyPosition, ID, false);
} }