Unstable 1.2.4.0

This commit is contained in:
Markus Isberg
2023-11-30 13:53:00 +02:00
parent 8a2e2ea0ae
commit fb5ea537bf
210 changed files with 4201 additions and 1283 deletions
@@ -66,7 +66,7 @@ namespace Barotrauma
{
foreach (Item item in slots[i].Items.ToList())
{
if (!receivedItemIdsFromClient[i].Contains(item.ID))
if (!receivedItemIdsFromClient[i].Contains(item.ID) && item.IsInteractable(c.Character))
{
Item droppedItem = item;
Entity prevOwner = Owner;
@@ -107,8 +107,7 @@ namespace Barotrauma
if (Entity.FindEntityByID(id) is not Item item || slots[i].Contains(item)) { continue; }
if (item.GetComponent<Pickable>() is not Pickable pickable ||
(pickable.IsAttached && !pickable.PickingDone) ||
item.AllowedSlots.None())
(pickable.IsAttached && !pickable.PickingDone) || item.AllowedSlots.None() || !item.IsInteractable(c.Character))
{
DebugConsole.AddWarning($"Client {c.Name} tried to pick up a non-pickable item \"{item}\" (parent inventory: {item.ParentInventory?.Owner.ToString() ?? "null"})",
item.Prefab.ContentPackage);
@@ -161,6 +161,20 @@ namespace Barotrauma
msg.WriteUInt16(droppedItem.ID);
}
break;
case SetHighlightEventData highlightEventData:
bool isTargetedForClient =
highlightEventData.TargetClients.IsEmpty ||
highlightEventData.TargetClients.Contains(c);
msg.WriteBoolean(isTargetedForClient);
if (isTargetedForClient)
{
msg.WriteBoolean(highlightEventData.Highlighted);
if (highlightEventData.Highlighted)
{
msg.WriteColorR8G8B8A8(highlightEventData.Color);
}
}
break;
default:
throw error($"Unsupported event type {itemEventData.GetType().Name}");
}
@@ -1,4 +1,7 @@
using System.Collections.Generic;
#nullable enable
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -16,4 +19,20 @@ partial class Item
Items = items.Distinct().ToImmutableArray();
}
}
public readonly struct SetHighlightEventData : IEventData
{
public EventType EventType => EventType.SetHighlight;
public readonly bool Highlighted;
public readonly Color Color;
public readonly ImmutableArray<Client> TargetClients;
public SetHighlightEventData(bool highlighted, Color color, IEnumerable<Client>? targetClients)
{
Highlighted = highlighted;
Color = color;
TargetClients = (targetClients ?? Enumerable.Empty<Client>()).ToImmutableArray();
}
}
}