v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -4,6 +4,7 @@ using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -135,6 +136,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
EnsureItemsInBothHands(c.Character);
|
||||
|
||||
CreateNetworkEvent();
|
||||
foreach (Inventory prevInventory in prevItemInventories.Distinct())
|
||||
{
|
||||
@@ -174,6 +177,33 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureItemsInBothHands(Character character)
|
||||
{
|
||||
if (this is not CharacterInventory charInv) { return; }
|
||||
|
||||
int leftHandSlot = charInv.FindLimbSlot(InvSlotType.LeftHand),
|
||||
rightHandSlot = charInv.FindLimbSlot(InvSlotType.RightHand);
|
||||
|
||||
if (IsSlotIndexOutOfBound(leftHandSlot) || IsSlotIndexOutOfBound(rightHandSlot)) { return; }
|
||||
|
||||
TryPutInOppositeHandSlot(rightHandSlot, leftHandSlot);
|
||||
TryPutInOppositeHandSlot(leftHandSlot, rightHandSlot);
|
||||
|
||||
void TryPutInOppositeHandSlot(int originalSlot, int otherHandSlot)
|
||||
{
|
||||
const InvSlotType bothHandSlot = InvSlotType.LeftHand | InvSlotType.RightHand;
|
||||
|
||||
foreach (Item it in slots[originalSlot].Items)
|
||||
{
|
||||
if (it.AllowedSlots.None(static s => s.HasFlag(bothHandSlot)) || slots[otherHandSlot].Contains(it)) { continue; }
|
||||
|
||||
TryPutItem(it, otherHandSlot, true, true, character, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsSlotIndexOutOfBound(int index) => index < 0 || index >= slots.Length;
|
||||
}
|
||||
|
||||
public void ServerEventWrite(IWriteMessage msg, Client c, NetEntityEvent.IData extraData = null)
|
||||
{
|
||||
SharedWrite(msg, extraData);
|
||||
|
||||
@@ -65,7 +65,8 @@ namespace Barotrauma
|
||||
msg.WriteUInt16(GameMain.Server.EntityEventManager.Events.Last()?.ID ?? (ushort)0);
|
||||
itemContainer.Inventory.ServerEventWrite(msg, c);
|
||||
break;
|
||||
case ItemStatusEventData _:
|
||||
case ItemStatusEventData statusEvent:
|
||||
msg.WriteBoolean(statusEvent.LoadingRound);
|
||||
msg.WriteSingle(condition);
|
||||
break;
|
||||
case AssignCampaignInteractionEventData _:
|
||||
|
||||
Reference in New Issue
Block a user