Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
@@ -42,59 +42,98 @@ namespace Barotrauma.Items.Components
Vector2 axis = new Vector2(
msg.ReadSingle(),
msg.ReadSingle());
UInt16 entityID = msg.ReadUInt16();
StickTargetType targetType = (StickTargetType)msg.ReadByte();
Entity entity = Entity.FindEntityByID(entityID);
Submarine submarine = Entity.FindEntityByID(submarineID) as Submarine;
Hull hull = Entity.FindEntityByID(hullID) as Hull;
Hull hull = Entity.FindEntityByID(hullID) as Hull;
item.Submarine = submarine;
item.CurrentHull = hull;
item.body.SetTransform(simPosition, item.body.Rotation);
if (entity is Character character)
switch (targetType)
{
byte limbIndex = msg.ReadByte();
if (limbIndex >= character.AnimController.Limbs.Length)
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Limb index out of bounds ({limbIndex}, character: {character.ToString()})");
return;
}
if (character.Removed) { return; }
var limb = character.AnimController.Limbs[limbIndex];
StickToTarget(limb.body.FarseerBody, axis);
}
else if (entity is Structure structure)
{
byte bodyIndex = msg.ReadByte();
if (bodyIndex == 255) { bodyIndex = 0; }
if (bodyIndex >= structure.Bodies.Count)
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Structure body index out of bounds ({bodyIndex}, structure: {structure.ToString()})");
return;
}
var body = structure.Bodies[bodyIndex];
StickToTarget(body, axis);
}
else if (entity is Item item)
{
if (item.Removed) { return; }
var door = item.GetComponent<Door>();
if (door != null)
{
StickToTarget(door.Body.FarseerBody, axis);
}
else if (item.body != null)
{
StickToTarget(item.body.FarseerBody, axis);
}
}
else if (entity is Submarine sub)
{
StickToTarget(sub.PhysicsBody.FarseerBody, axis);
}
else
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Invalid stick target ({entity?.ToString() ?? "null"}, {entityID})");
}
case StickTargetType.Structure:
UInt16 structureId = msg.ReadUInt16();
byte bodyIndex = msg.ReadByte();
if (Entity.FindEntityByID(structureId) is Structure structure)
{
if (bodyIndex == 255) { bodyIndex = 0; }
if (bodyIndex >= structure.Bodies.Count)
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Structure body index out of bounds ({bodyIndex}, structure: {structure})");
return;
}
var body = structure.Bodies[bodyIndex];
StickToTarget(body, axis);
}
else
{
DebugConsole.AddWarning($"\"{item.Prefab.Identifier}\" failed to stick to a structure. Could not find a structure with the ID {structureId}");
}
break;
case StickTargetType.Limb:
UInt16 characterId = msg.ReadUInt16();
byte limbIndex = msg.ReadByte();
if (Entity.FindEntityByID(characterId) is Character character)
{
if (limbIndex >= character.AnimController.Limbs.Length)
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Limb index out of bounds ({limbIndex}, character: {character})");
return;
}
if (character.Removed) { return; }
var limb = character.AnimController.Limbs[limbIndex];
StickToTarget(limb.body.FarseerBody, axis);
}
else
{
DebugConsole.AddWarning($"\"{this.item.Prefab.Identifier}\" failed to stick to a limb. Could not find a character with the ID {characterId}");
}
break;
case StickTargetType.Item:
UInt16 itemID = msg.ReadUInt16();
if (Entity.FindEntityByID(itemID) is Item targetItem)
{
if (targetItem.Removed) { return; }
var door = targetItem.GetComponent<Door>();
if (door != null)
{
StickToTarget(door.Body.FarseerBody, axis);
}
else if (targetItem.body != null)
{
StickToTarget(targetItem.body.FarseerBody, axis);
}
}
else
{
DebugConsole.AddWarning($"\"{this.item.Prefab.Identifier}\" failed to stick to an item. Could not find n item with the ID {itemID}");
}
break;
case StickTargetType.Submarine:
UInt16 targetSubmarineId = msg.ReadUInt16();
if (Entity.FindEntityByID(targetSubmarineId) is Submarine targetSub)
{
StickToTarget(targetSub.PhysicsBody.FarseerBody, axis);
}
else
{
DebugConsole.AddWarning($"\"{item.Prefab.Identifier}\" failed to stick to a submarine. Could not find a structure with the ID {targetSubmarineId}");
}
break;
case StickTargetType.LevelWall:
int levelWallIndex = msg.ReadInt32();
var allCells = Level.Loaded.GetAllCells();
if (levelWallIndex >= 0 && levelWallIndex < allCells.Count)
{
StickToTarget(allCells[levelWallIndex].Body, axis);
}
else
{
DebugConsole.ThrowError($"Failed to read a projectile update from the server. Level wall index out of bounds ({levelWallIndex}, wall count: {allCells.Count})");
}
break;
}
}
else
{