Build 0.21.6.0 (1.0 pre-patch)

This commit is contained in:
Regalis11
2023-01-31 18:08:26 +02:00
parent e1c04bc31d
commit cf9ecd35b3
231 changed files with 4479 additions and 2276 deletions
@@ -1,4 +1,5 @@
using Barotrauma.Items.Components;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
@@ -19,7 +20,7 @@ namespace Barotrauma
bool accessible = c.Character.CanAccessInventory(this);
if (this is CharacterInventory characterInventory && accessible)
{
if (Owner == null || !(Owner is Character ownerCharacter))
if (Owner == null || Owner is not Character ownerCharacter)
{
accessible = false;
}
@@ -39,7 +40,7 @@ namespace Barotrauma
{
foreach (ushort id in newItemIDs[i])
{
if (!(Entity.FindEntityByID(id) is Item item)) { continue; }
if (Entity.FindEntityByID(id) is not Item item) { continue; }
item.PositionUpdateInterval = 0.0f;
if (item.ParentInventory != null && item.ParentInventory != this)
{
@@ -94,7 +95,15 @@ namespace Barotrauma
{
foreach (ushort id in newItemIDs[i])
{
if (!(Entity.FindEntityByID(id) is Item item) || slots[i].Contains(item)) { continue; }
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())
{
DebugConsole.AddWarning($"Client {c.Name} tried to pick up a non-pickable item \"{item}\" (parent inventory: {item.ParentInventory?.Owner.ToString() ?? "null"})");
continue;
}
if (GameMain.Server != null)
{
@@ -105,7 +114,7 @@ namespace Barotrauma
(c.Character == null || item.PreviousParentInventory == null || !c.Character.CanAccessInventory(item.PreviousParentInventory)))
{
#if DEBUG || UNSTABLE
DebugConsole.NewMessage($"Client {c.Name} failed to pick up item \"{item}\" (parent inventory: {(item.ParentInventory?.Owner.ToString() ?? "null")}). No access.", Color.Yellow);
DebugConsole.NewMessage($"Client {c.Name} failed to pick up item \"{item}\" (parent inventory: {item.ParentInventory?.Owner.ToString() ?? "null"}). No access.", Color.Yellow);
#endif
if (item.body != null && !c.PendingPositionUpdates.Contains(item))
{
@@ -153,25 +153,27 @@ namespace Barotrauma
(components[containerIndex] as ItemContainer).Inventory.ServerEventRead(msg, c);
break;
case EventType.Treatment:
if (c.Character == null || !c.Character.CanInteractWith(this)) return;
if (c.Character == null || !c.Character.CanInteractWith(this)) { return; }
UInt16 characterID = msg.ReadUInt16();
byte limbIndex = msg.ReadByte();
Character targetCharacter = FindEntityByID(characterID) as Character;
if (targetCharacter == null) break;
if (targetCharacter != c.Character && c.Character.SelectedCharacter != targetCharacter) break;
if (HealingCooldown.IsOnCooldown(c)) { return; }
if (FindEntityByID(characterID) is not Character targetCharacter) { break; }
if (targetCharacter != c.Character && c.Character.SelectedCharacter != targetCharacter) { break; }
HealingCooldown.SetCooldown(c);
Limb targetLimb = limbIndex < targetCharacter.AnimController.Limbs.Length ? targetCharacter.AnimController.Limbs[limbIndex] : null;
if (ContainedItems == null || ContainedItems.All(i => i == null))
if (ContainedItems == null || ContainedItems.All(static i => i == null))
{
GameServer.Log(GameServer.CharacterLogName(c.Character) + " used item " + Name, ServerLog.MessageType.ItemInteraction);
GameServer.Log($"{GameServer.CharacterLogName(c.Character)} used item {Name}", ServerLog.MessageType.ItemInteraction);
}
else
{
GameServer.Log(
GameServer.CharacterLogName(c.Character) + " used item " + Name + " (contained items: " + string.Join(", ", ContainedItems.Select(i => i.Name)) + ")",
$"{GameServer.CharacterLogName(c.Character)} used item {Name} (contained items: {string.Join(", ", ContainedItems.Select(i => i.Name))})",
ServerLog.MessageType.ItemInteraction);
}
@@ -348,15 +350,9 @@ namespace Barotrauma
}
}
public void ServerWritePosition(IWriteMessage msg, Client c)
public void ServerWritePosition(ReadWriteMessage tempBuffer, Client c)
{
msg.WriteUInt16(ID);
IWriteMessage tempBuffer = new WriteOnlyMessage();
body.ServerWrite(tempBuffer);
msg.WriteVariableUInt32((uint)tempBuffer.LengthBytes);
msg.WriteBytes(tempBuffer.Buffer, 0, tempBuffer.LengthBytes);
msg.WritePadBits();
}
public void CreateServerEvent<T>(T ic) where T : ItemComponent, IServerSerializable
@@ -378,7 +374,7 @@ namespace Barotrauma
if (!components.Contains(ic)) { return; }
var eventData = new ComponentStateEventData(ic, extraData);
if (!ic.ValidateEventData(eventData)) { throw new Exception($"Component event creation failed: {typeof(T).Name}.{nameof(ItemComponent.ValidateEventData)} returned false"); }
if (!ic.ValidateEventData(eventData)) { throw new Exception($"Component event creation for the item \"{Prefab.Identifier}\" failed: {typeof(T).Name}.{nameof(ItemComponent.ValidateEventData)} returned false."); }
GameMain.Server.CreateEntityEvent(this, eventData);
}