diff --git a/Barotrauma/BarotraumaClient/ClientCode.projitems b/Barotrauma/BarotraumaClient/ClientCode.projitems index a5cc964a4..74a09042b 100644 --- a/Barotrauma/BarotraumaClient/ClientCode.projitems +++ b/Barotrauma/BarotraumaClient/ClientCode.projitems @@ -220,5 +220,6 @@ + \ No newline at end of file diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index 60e369ebf..b77e42d54 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -567,45 +567,6 @@ namespace Barotrauma } }, isCheat: true)); - commands.Add(new Command("alpha", "Change the alpha (as bytes from 0 to 255) of the selected item/structure instances. Applied only in the subeditor.", (string[] args) => - { - if (Screen.Selected == GameMain.SubEditorScreen) - { - if (!MapEntity.SelectedAny) - { - ThrowError("You have to select item(s)/structure(s) first!"); - } - else - { - if (args.Length > 0) - { - if (!byte.TryParse(args[0], out byte a)) - { - ThrowError($"Failed to parse value for ALPHA from {args[0]}"); - } - else - { - foreach (var mapEntity in MapEntity.SelectedList) - { - if (mapEntity is Structure s) - { - s.SpriteColor = new Color(s.SpriteColor.R, s.SpriteColor.G, s.SpriteColor.G, a); - } - else if (mapEntity is Item i) - { - i.SpriteColor = new Color(i.SpriteColor.R, i.SpriteColor.G, i.SpriteColor.G, a); - } - } - } - } - else - { - ThrowError("Not enough arguments provided! One required!"); - } - } - } - }, isCheat: true)); - commands.Add(new Command("tutorial", "", (string[] args) => { TutorialMode.StartTutorial(Tutorials.Tutorial.Tutorials[0]); @@ -974,6 +935,30 @@ namespace Barotrauma } } } + XNode nextNode = destinationElement.NextNode; + while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode; + destinationElement = nextNode as XElement; + } + destinationDoc.Save(destinationPath); + }, + () => + { + var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray(); + return new string[][] + { + files, + files + }; + })); + + commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) => + { + string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt"; + List lines = new List(); + foreach (MapEntityPrefab me in MapEntityPrefab.List) + { + lines.Add("" + me.Name + ""); + lines.Add("" + me.Description + ""); } }, isCheat: false)); #endif diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs index 923effbe7..d8becadba 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/ContextualTutorial.cs @@ -481,7 +481,7 @@ namespace Barotrauma.Tutorials } break; case ContentTypes.Text: - infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Name), TextManager.Get(activeSegment.Content.GetAttributeString("tag", ""), false, args), + infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Name), TextManager.GetFormatted(activeSegment.Content.GetAttributeString("tag", ""), false, args), activeSegment.Content.GetAttributeInt("width", 300), activeSegment.Content.GetAttributeInt("height", 80), activeSegment.Content.GetAttributeString("anchor", "Center"), true, CurrentSegmentStopCallback); diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index cc99a09f7..898b2e2a1 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -865,40 +865,14 @@ namespace Barotrauma.Networking CoroutineManager.StopCoroutines("WaitInServerQueue"); } else - { - //disconnected/denied for some other reason than the server being full - // -> stop queuing and show a message box - waitInServerQueueBox?.Close(); - waitInServerQueueBox = null; - CoroutineManager.StopCoroutines("WaitInServerQueue"); - } - - if (allowReconnect && disconnectReason == DisconnectReason.Unknown) - { - DebugConsole.NewMessage("Attempting to reconnect..."); - - string msg = TextManager.GetServerMessage(disconnectMsg); - msg = string.IsNullOrWhiteSpace(msg) ? - TextManager.Get("ConnectionLostReconnecting") : - msg + '\n' + TextManager.Get("ConnectionLostReconnecting"); - - reconnectBox = new GUIMessageBox( - TextManager.Get("ConnectionLost"), - msg, new string[0]); - connected = false; - ConnectToServer(serverIP); - } - else { string msg = ""; if (disconnectReason == DisconnectReason.Unknown) { - DebugConsole.NewMessage("Do not attempt reconnect (not allowed)."); msg = disconnectMsg; } else { - DebugConsole.NewMessage("Do not attempt to reconnect (DisconnectReason doesn't allow reconnection)."); msg = TextManager.Get("DisconnectReason." + disconnectReason.ToString()); if (allowReconnect && disconnectReason == DisconnectReason.Unknown) @@ -1394,6 +1368,9 @@ namespace Barotrauma.Networking case ServerNetObject.CLIENT_LIST: ReadClientList(inc); break; + case ServerNetObject.CLIENT_LIST: + ReadClientList(inc); + break; case ServerNetObject.CHAT_MESSAGE: ChatMessage.ClientRead(inc); break; diff --git a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index 5ab63d5e1..b710434c8 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -365,12 +365,6 @@ namespace Barotrauma.Networking msg.Write((byte)ServerNetObject.ENTITY_EVENT); Write(msg, eventsToSync, out sentEvents, client); } - - foreach (NetEntityEvent entityEvent in sentEvents) - { - (entityEvent as ServerEntityEvent).Sent = true; - client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; - } sentEvents = eventsToSync; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 2f0623bd3..272c56938 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -475,18 +475,6 @@ namespace Barotrauma } attackSimPos = ConvertUnits.ToSimUnits(attackWorldPos); } - else - { - // Take the sub position into account in the sim pos - if (Character.Submarine == null && SelectedAiTarget.Entity.Submarine != null) - { - attackSimPos += SelectedAiTarget.Entity.Submarine.SimPosition; - } - else if (Character.Submarine != null && SelectedAiTarget.Entity.Submarine == null) - { - attackSimPos -= Character.Submarine.SimPosition; - } - } if (raycastTimer > 0.0) { @@ -546,9 +534,7 @@ namespace Barotrauma } } } - - bool canAttack = true; - if (IsCoolDownRunning) + else { UpdateWallTarget(); raycastTimer = RaycastInterval; @@ -1032,46 +1018,15 @@ namespace Barotrauma { targetingTag = targetCharacter.SpeciesName.ToLowerInvariant(); } - else if (targetCharacter.Submarine != null && Character.Submarine == null) - { - //target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms - targetingTag = "room"; - } else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant())) - { - targetingTag = targetCharacter.SpeciesName.ToLowerInvariant(); - } - } - else if (target.Entity != null) - { - //skip the target if it's a room and the character is already inside a sub - if (character.CurrentHull != null && target.Entity is Hull) continue; - - Door door = null; - if (target.Entity is Item item) { if (targetCharacter.AIController is EnemyAIController enemy) { - targetingTag = "room"; - } - - door = item.GetComponent(); - foreach (TargetingPriority prio in targetingPriorities.Values) - { - if (item.HasTag(prio.TargetTag)) + if (enemy.combatStrength > combatStrength) { targetingTag = "stronger"; } - } - } - else if (target.Entity is Structure s) - { - targetingTag = "wall"; - if (aggressiveBoarding) - { - // Ignore walls when inside. - valueModifier = character.CurrentHull == null ? 2 : 0; - if (valueModifier > 0) + else if (enemy.combatStrength < combatStrength) { targetingTag = "weaker"; } @@ -1203,14 +1158,6 @@ namespace Barotrauma #endregion - protected override void OnStateChanged(AIState from, AIState to) - { - latchOntoAI?.DeattachFromBody(); - Character.AnimController.ReleaseStuckLimbs(); - escapePoint = Vector2.Zero; - wallTarget = null; - } - if (toBeRemoved != null) { foreach (AITarget target in toBeRemoved) @@ -1232,6 +1179,19 @@ namespace Barotrauma return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize); } + #endregion + + protected override void OnStateChanged(AIState from, AIState to) + { + latchOntoAI?.DeattachFromBody(); + Character.AnimController.ReleaseStuckLimbs(); + } + + private int GetMinimumPassableHoleCount() + { + return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize); + } + private bool CanPassThroughHole(Structure wall, int sectionIndex) { int requiredHoleCount = GetMinimumPassableHoleCount(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs index 11a8756a6..802af18e9 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs @@ -408,7 +408,7 @@ namespace Barotrauma } } } - else if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) + while (MainLimb.Rotation - (movementAngle + mainLimbAngle) < -MathHelper.Pi) { movementAngle = Dir > 0 ? -MathHelper.PiOver2 : MathHelper.PiOver2; if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index 52dc40baf..a0fc07c53 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -1037,6 +1037,8 @@ namespace Barotrauma CheckValidity(); + CheckValidity(); + UpdateNetPlayerPosition(deltaTime); CheckDistFromCollider(); UpdateCollisionCategories(); @@ -1348,7 +1350,7 @@ namespace Barotrauma SetInitialLimbPositions(); return; } - return true; + UpdateProjSpecific(deltaTime); } partial void UpdateProjSpecific(float deltaTime); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs index 2291509bf..5413a6deb 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs @@ -179,6 +179,9 @@ namespace Barotrauma.Items.Components newConnection.Item.Position - refSub.HiddenSubPosition; + if (nodes.Count > 0 && nodes[0] == nodePos) break; + if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break; + if (nodes.Count > 0 && nodes[0] == nodePos) break; if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs b/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs index c94dffa0f..67cb5f5c5 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs @@ -186,6 +186,9 @@ namespace Barotrauma Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false); bool underWater = hull == null || explosionPos.Y < hull.Surface; + Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false); + bool underWater = hull == null || explosionPos.Y < hull.Surface; + explosionPos = ConvertUnits.ToSimUnits(explosionPos); Dictionary distFactors = new Dictionary(); diff --git a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs index 071cb99a3..b8edb356a 100644 --- a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs +++ b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs @@ -48,6 +48,18 @@ namespace Barotrauma private set; } + public Vector2 LinearVelocity + { + get; + private set; + } + + public float AngularVelocity + { + get; + private set; + } + public readonly float Timestamp; public readonly UInt16 ID;