(50447ac17) Inventory syncing fixes. Could be related to #768. - When moving an item from an inventory to another, create the event for the target inventory first, then for the inventory the item is being removed from. Otherwise clients would first drop the item, and then put it in the container with the next event, which works most of the time, but if the second event is delayed enough that the item is not within the character's reach by the time it arrives, the client will be unable to put it in the container and the item will just be dropped. - Fixed item velocities not being reset when they're dropped from a character's inventory. I'm not exactly sure why, but sometimes they had very high downwards velocities (even though the body was previously inactive), which caused them to launch through floors and made the previous inventory syncing issue much worse (because a delay of just a couple of frames was enough to move the item out of the character's reach).
This commit is contained in:
@@ -276,6 +276,9 @@ namespace Barotrauma
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the character from the crew (and crew menus).
|
||||
/// </summary>
|
||||
|
||||
@@ -170,6 +170,13 @@ namespace Barotrauma
|
||||
|
||||
Inventory prevInventory = item.ParentInventory;
|
||||
|
||||
if (createNetworkEvent)
|
||||
{
|
||||
CreateNetworkEvent();
|
||||
//also delay syncing the inventory the item was inside
|
||||
if (prevInventory != null && prevInventory != this) prevInventory.syncItemsDelay = 1.0f;
|
||||
}
|
||||
|
||||
if (removeItem)
|
||||
{
|
||||
item.Drop(user);
|
||||
@@ -187,13 +194,6 @@ namespace Barotrauma
|
||||
{
|
||||
item.body.Enabled = false;
|
||||
}
|
||||
|
||||
if (createNetworkEvent)
|
||||
{
|
||||
CreateNetworkEvent();
|
||||
//also delay syncing the inventory the item was inside
|
||||
if (prevInventory != null && prevInventory != this) prevInventory.syncItemsDelay = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
|
||||
@@ -1630,21 +1630,25 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components) { ic.Drop(dropper); }
|
||||
if (body != null)
|
||||
{
|
||||
body.Enabled = true;
|
||||
body.ResetDynamics();
|
||||
if (dropper != null)
|
||||
{
|
||||
body.SetTransform(dropper.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components) { ic.Drop(dropper); }
|
||||
|
||||
if (Container != null)
|
||||
{
|
||||
if (body != null)
|
||||
{
|
||||
body.Enabled = true;
|
||||
body.LinearVelocity = Vector2.Zero;
|
||||
}
|
||||
SetTransform(Container.SimPosition, 0.0f);
|
||||
|
||||
Container.RemoveContained(this);
|
||||
Container = null;
|
||||
}
|
||||
|
||||
|
||||
if (parentInventory != null)
|
||||
{
|
||||
parentInventory.RemoveItem(this);
|
||||
|
||||
Reference in New Issue
Block a user