diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index 8d54f0a0d..da4bf9838 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -15,6 +15,8 @@ namespace Barotrauma { protected float soundTimer; protected float soundInterval; + protected float nameTimer; + protected bool nameVisible; private List sounds; @@ -295,18 +297,50 @@ namespace Barotrauma } if (this == controlled) return; + + nameTimer -= (float)Timing.Step; + if (nameTimer <= 0.0f) + { + //Ideally it shouldn't send the character entirely if we can't see them but /shrug, this isn't the most hacker-proof game atm + Limb selfHead = controlled != null ? controlled.AnimController.GetLimb(LimbType.Head) : null; + Limb targHead = this.AnimController.GetLimb(LimbType.Head); + + if (controlled != null && controlled.Submarine == Submarine) + { + if (selfHead != null && targHead != null) + { + Body closestBody = Submarine.CheckVisibility(selfHead.SimPosition, targHead.SimPosition); + Structure wall = null; + if (closestBody != null) + wall = closestBody.UserData as Structure; + nameVisible = closestBody == null || wall == null || !wall.CastShadow; + } + else + nameVisible = false; + } + else + nameVisible = true; //Ideally it should check for visibility from outside the sub/from sub-to-sub, but this will work for now. + nameTimer = Rand.Range(0.5f, 2f); + } + + if (!nameVisible) + return; if (info != null) { - Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom; + string name = Info.DisplayName; + if (controlled == null && name != Info.Name) + name += " (Disguised)"; + + Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(name) * 0.5f / cam.Zoom; Color nameColor = Color.White; if (Character.Controlled != null && TeamID != Character.Controlled.TeamID) { nameColor = Color.Red; } - GUI.Font.DrawString(spriteBatch, Info.Name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f); - GUI.Font.DrawString(spriteBatch, Info.Name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f); + GUI.Font.DrawString(spriteBatch, name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f); + GUI.Font.DrawString(spriteBatch, name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f); if (GameMain.DebugDraw) { diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs index 46586ed9d..bed626321 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs @@ -242,7 +242,7 @@ namespace Barotrauma string focusName = character.FocusedCharacter.SpeciesName; if (character.FocusedCharacter.Info != null) { - focusName = character.FocusedCharacter.Info.Name; + focusName = character.FocusedCharacter.Info.DisplayName; } Vector2 textPos = startPos; textPos -= new Vector2(GUI.Font.MeasureString(focusName).X / 2, 20); diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs index 2b9015be1..51d728219 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterNetworking.cs @@ -143,11 +143,12 @@ namespace Barotrauma msg.ReadFloat(), msg.ReadFloat()); + float rotation = msg.ReadFloat(); int index = 0; - if (GameMain.NetworkMember.Character == this && AllowInput) + if (GameMain.NetworkMember.Character == this) { - var posInfo = new CharacterStateInfo(pos, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation); + var posInfo = new CharacterStateInfo(pos, rotation, networkUpdateID, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation); while (index < memState.Count && NetIdUtils.IdMoreRecent(posInfo.ID, memState[index].ID)) index++; @@ -155,7 +156,7 @@ namespace Barotrauma } else { - var posInfo = new CharacterStateInfo(pos, sendingTime, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation); + var posInfo = new CharacterStateInfo(pos, rotation, sendingTime, facingRight ? Direction.Right : Direction.Left, selectedEntity, animation); while (index < memState.Count && posInfo.Timestamp > memState[index].Timestamp) index++; diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs index 77e91591c..0c2477986 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs @@ -32,7 +32,7 @@ namespace Barotrauma } public GUIMessageBox(string headerText, string text) - : this(headerText, text, new string[] {"OK"}) + : this(headerText, text, new string[] {"OK"}, DefaultWidth, 0) { this.Buttons[0].OnClicked = Close; } diff --git a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs index 6ccfbc19c..6c609618e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/CharacterInventory.cs @@ -39,7 +39,7 @@ namespace Barotrauma case 3: case 4: SlotPositions[i] = new Vector2( - spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 2), + spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 1), GameMain.GraphicsHeight - (spacing + rectHeight) * 3); useOnSelfButton[i - 3] = new GUIButton( @@ -52,16 +52,24 @@ namespace Barotrauma break; + //face case 5: SlotPositions[i] = new Vector2( spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5), GameMain.GraphicsHeight - (spacing + rectHeight) * 3); + break; + //id card + case 6: + SlotPositions[i] = new Vector2( + spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5), + GameMain.GraphicsHeight - (spacing + rectHeight) * 3); + break; default: SlotPositions[i] = new Vector2( - spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 6) % 5), - GameMain.GraphicsHeight - (spacing + rectHeight) * ((i > 10) ? 2 : 1)); + spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 7) % 5), + GameMain.GraphicsHeight - (spacing + rectHeight) * ((i > 11) ? 2 : 1)); break; } } @@ -247,6 +255,13 @@ namespace Barotrauma new Vector2(15.0f, 16.0f), Vector2.One, SpriteEffects.None, 0.1f); } + else if (i == 6) + { + spriteBatch.Draw(icons, new Vector2(slotRect.Center.X, slotRect.Center.Y), + new Rectangle(62, 36, 22, 18), Color.White * 0.7f, 0.0f, + new Vector2(11.0f, 9.0f), Vector2.One, + SpriteEffects.None, 0.1f); + } } base.Draw(spriteBatch); diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Door.cs index 38817a23f..ccb31b328 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Door.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Door.cs @@ -7,7 +7,7 @@ using System; namespace Barotrauma.Items.Components { - partial class Door : ItemComponent, IDrawableComponent, IServerSerializable + partial class Door : Pickable, IDrawableComponent, IServerSerializable { private ConvexHull convexHull; private ConvexHull convexHull2; diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs index 63777556f..2e9691150 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs @@ -20,7 +20,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + (IsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(Character.Controlled.LogName + (IsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -39,7 +39,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(Character.Controlled.LogName + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -58,7 +58,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(Character.Controlled.LogName + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs index e113317cc..0de3d0b2b 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerContainer.cs @@ -19,7 +19,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(Character.Controlled.LogName + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { @@ -38,7 +38,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(Character.Controlled + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(Character.Controlled.LogName + " set the recharge speed of " + item.Name + " to " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs index 949859513..93b37d1f6 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs @@ -102,11 +102,11 @@ namespace Barotrauma.Items.Components { if (GameMain.Client != null) { - panel.Item.CreateClientEvent(panel); + panel.Item.CreateClientEvent(panel); } else if (GameMain.Server != null) { - panel.Item.CreateServerEvent(panel); + panel.Item.CreateServerEvent(panel); } draggingConnected = null; @@ -174,12 +174,12 @@ namespace Barotrauma.Items.Components var otherConnection = draggingConnected.OtherConnection(this); if (otherConnection == null) { - GameServer.Log(Character.Controlled + " connected a wire to " + + GameServer.Log(Character.Controlled.LogName + " connected a wire to " + Item.Name + " (" + Name + ")", ServerLog.MessageType.ItemInteraction); } else { - GameServer.Log(Character.Controlled + " connected a wire from " + + GameServer.Log(Character.Controlled.LogName + " connected a wire from " + Item.Name + " (" + Name + ") to " + otherConnection.item.Name + " (" + otherConnection.Name + ")", ServerLog.MessageType.ItemInteraction); } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/ConnectionPanel.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/ConnectionPanel.cs index e66a28d9a..b2f10ae90 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/ConnectionPanel.cs @@ -23,7 +23,6 @@ namespace Barotrauma.Items.Components HighlightedWire = null; Connection.DrawConnections(spriteBatch, this, character); - } } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs index 8130dea44..377c51275 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs @@ -296,9 +296,26 @@ namespace Barotrauma } else { - toolTip = string.IsNullOrEmpty(Items[i].Description) ? + string description = Items[i].Description; + if (Items[i].Prefab.NameMatches("ID Card")) + { + string[] readTags = Items[i].Tags.Split(','); + string idName = null; + string idJob = null; + foreach (string tag in readTags) + { + string[] s = tag.Split(':'); + if (s[0] == "name") + idName = s[1]; + if (s[0] == "job") + idJob = s[1]; + } + if (idName != null) + description = "This belongs to " + idName + (idJob != null ? ", the " + idJob + ".\n" : ".\n") + description; + } + toolTip = string.IsNullOrEmpty(description) ? Items[i].Name : - Items[i].Name + '\n' + Items[i].Description; + Items[i].Name + '\n' + description; } DrawToolTip(spriteBatch, toolTip, slots[i].Rect); diff --git a/Barotrauma/BarotraumaClient/Source/Map/WayPoint.cs b/Barotrauma/BarotraumaClient/Source/Map/WayPoint.cs index 983249d48..cf1f7a269 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/WayPoint.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/WayPoint.cs @@ -106,6 +106,16 @@ namespace Barotrauma return true; } + private bool EnterIDCardDesc(GUITextBox textBox, string text) + { + IdCardDesc = text; + textBox.Text = text; + textBox.Color = Color.Green; + + textBox.Deselect(); + + return true; + } private bool EnterIDCardTags(GUITextBox textBox, string text) { IdCardTags = text.Split(','); @@ -143,7 +153,7 @@ namespace Barotrauma private GUIComponent CreateEditingHUD(bool inGame = false) { int width = 500; - int height = spawnType == SpawnType.Path ? 100 : 140; + int height = spawnType == SpawnType.Path ? 100 : 200; int x = GameMain.GraphicsWidth / 2 - width / 2, y = 10; editingHUD = new GUIFrame(new Rectangle(x, y, width, height), Color.Black * 0.5f); @@ -172,8 +182,19 @@ namespace Barotrauma y = 40 + 20; + new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card desc:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD); + GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD); + propertyBox.MaxTextLength = 150; + propertyBox.Text = idCardDesc; + propertyBox.OnEnterPressed = EnterIDCardDesc; + propertyBox.OnTextChanged = TextBoxChanged; + propertyBox.ToolTip = "Characters spawning at this spawnpoint will have the specified description added to their ID card. This can be used to describe additional access levels their card has on the sub."; + + y = y + 30; + new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD); - GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), "", editingHUD); + propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD); + propertyBox.MaxTextLength = 60; propertyBox.Text = string.Join(", ", idCardTags); propertyBox.OnEnterPressed = EnterIDCardTags; propertyBox.OnTextChanged = TextBoxChanged; @@ -182,7 +203,8 @@ namespace Barotrauma y = y + 30; new GUITextBlock(new Rectangle(0, y, 100, 20), "Assigned job:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD); - propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), "", editingHUD); + propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD); + propertyBox.MaxTextLength = 60; propertyBox.Text = (assignedJob == null) ? "None" : assignedJob.Name; propertyBox.OnEnterPressed = EnterAssignedJob; propertyBox.OnTextChanged = TextBoxChanged; diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs index 8442023e4..9f7055eae 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs @@ -453,10 +453,11 @@ namespace Barotrauma { damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f); var sounds = damageSounds.FindAll(s => - damage >= s.damageRange.X && - damage <= s.damageRange.Y && + s.damageRange == null || + (damage >= s.damageRange.X && + damage <= s.damageRange.Y) && s.damageType == damageType && - (string.IsNullOrEmpty(s.requiredTag) || (tags != null && tags.Contains(s.requiredTag)))); + (tags == null ? string.IsNullOrEmpty(s.requiredTag) : tags.Contains(s.requiredTag))); if (!sounds.Any()) return; diff --git a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems index 0f3ac76c9..91e79eb92 100644 --- a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems +++ b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems @@ -976,6 +976,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -1021,6 +1027,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Barotrauma/BarotraumaShared/Content/Characters/Carrier/carrier.xml b/Barotrauma/BarotraumaShared/Content/Characters/Carrier/carrier.xml index 9377d3d06..81a8367e1 100644 --- a/Barotrauma/BarotraumaShared/Content/Characters/Carrier/carrier.xml +++ b/Barotrauma/BarotraumaShared/Content/Characters/Carrier/carrier.xml @@ -61,7 +61,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml b/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml index b18075da7..33e8bad60 100644 --- a/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml +++ b/Barotrauma/BarotraumaShared/Content/Characters/Human/humanhusk.xml @@ -1,17 +1,27 @@  - + + + - + - + @@ -115,9 +125,5 @@ - - diff --git a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml index 238988d26..9cbd1a043 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml @@ -41,7 +41,7 @@ - + @@ -92,7 +92,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml b/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml index 120365d6c..476f8a787 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml @@ -6,11 +6,13 @@ - + + + @@ -35,11 +37,13 @@ - + + + @@ -64,11 +68,13 @@ - + + + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Fabricators/fabricators.xml b/Barotrauma/BarotraumaShared/Content/Items/Fabricators/fabricators.xml index e90a36068..9ccb70b2f 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Fabricators/fabricators.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Fabricators/fabricators.xml @@ -40,13 +40,16 @@ + + + - + @@ -96,6 +99,7 @@ + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml index 5a8c593f1..cdb8cb115 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Jobgear/misc.xml @@ -38,6 +38,7 @@ + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml b/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml index 229e9bce8..e7e20a0a4 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml @@ -25,6 +25,15 @@ + + + + + + + + + - + - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Tools/bump.ogg b/Barotrauma/BarotraumaShared/Content/Items/Tools/bump.ogg new file mode 100644 index 000000000..d3cd6041a Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Items/Tools/bump.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Items/Tools/crowbar.ogg b/Barotrauma/BarotraumaShared/Content/Items/Tools/crowbar.ogg new file mode 100644 index 000000000..a0f604953 Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Items/Tools/crowbar.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.png b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.png index 55f741a6b..8cfb42834 100644 Binary files a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.png and b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.png differ diff --git a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml index 0d6c81251..417336892 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml @@ -116,7 +116,7 @@ - + @@ -175,7 +175,7 @@ price="10"> - + @@ -185,6 +185,23 @@ + + + + + + + + + + + @@ -231,12 +247,11 @@ - + - diff --git a/Barotrauma/BarotraumaShared/Content/Items/Weapons/railgun.xml b/Barotrauma/BarotraumaShared/Content/Items/Weapons/railgun.xml index 969b6213c..50662afde 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Weapons/railgun.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Weapons/railgun.xml @@ -36,11 +36,12 @@ category="Machine" type="Controller" linkable="true" + disableitemusagewhenselected="true" > - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Weapons/syringegun.ogg b/Barotrauma/BarotraumaShared/Content/Items/Weapons/syringegun.ogg new file mode 100644 index 000000000..a9ada88dd Binary files /dev/null and b/Barotrauma/BarotraumaShared/Content/Items/Weapons/syringegun.ogg differ diff --git a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.png b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.png index dd96c6070..2bd2a36f0 100644 Binary files a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.png and b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.png differ diff --git a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml index 454ed82e2..130d19aba 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml @@ -16,7 +16,7 @@ - + @@ -56,6 +56,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -117,7 +149,7 @@ - + @@ -134,7 +166,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/idcard.xml b/Barotrauma/BarotraumaShared/Content/Items/idcard.xml index 1c2d8c62e..d6659ef30 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/idcard.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/idcard.xml @@ -10,8 +10,5 @@ - - - - - + + \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/Content/Jobs.xml b/Barotrauma/BarotraumaShared/Content/Jobs.xml index 17fa0ac06..4ed0e602f 100644 --- a/Barotrauma/BarotraumaShared/Content/Jobs.xml +++ b/Barotrauma/BarotraumaShared/Content/Jobs.xml @@ -8,7 +8,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -48,7 +48,8 @@ - + + @@ -66,7 +67,7 @@ - + @@ -86,7 +87,7 @@ - + @@ -105,7 +106,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml index 8aae1829b..d4156d5d9 100644 --- a/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml +++ b/Barotrauma/BarotraumaShared/Content/Sounds/sounds.xml @@ -16,8 +16,8 @@ - - + + diff --git a/Barotrauma/BarotraumaShared/Content/UI/inventoryIcons.png b/Barotrauma/BarotraumaShared/Content/UI/inventoryIcons.png index ab2341432..885ca8b46 100644 Binary files a/Barotrauma/BarotraumaShared/Content/UI/inventoryIcons.png and b/Barotrauma/BarotraumaShared/Content/UI/inventoryIcons.png differ diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index cd7567166..18b1316a0 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -84,9 +84,13 @@ namespace Barotrauma { levitatingCollider = false; Collider.FarseerBody.FixedRotation = false; - - Collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition) * 20.0f; - Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation); + + if (Math.Abs(Collider.Rotation-GetLimb(LimbType.Torso).Rotation)>Math.PI*0.6f) + { + Collider.SetTransform(Collider.SimPosition, MathHelper.WrapAngle(Collider.Rotation + (float)Math.PI)); + } + Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation); + Collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition) * 20.0f; return; } @@ -1083,8 +1087,6 @@ namespace Barotrauma public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle) { - Holdable holdable = item.GetComponent(); - if (character.IsUnconscious || character.Stun > 0.0f) aim = false; //calculate the handle positions @@ -1102,7 +1104,6 @@ namespace Barotrauma bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent() != null; - float itemAngle; if (Anim != Animation.Climbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero) { @@ -1114,6 +1115,7 @@ namespace Barotrauma itemAngle = (torso.body.Rotation + holdAngle * Dir); + Holdable holdable = item.GetComponent(); if (holdable.ControlPose) { head.body.SmoothRotate(itemAngle); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index 2feb08dd3..a0dbe6343 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -1339,13 +1339,34 @@ namespace Barotrauma } } - Vector2 positionError = serverPos.Position - localPos.Position; - for (int i = localPosIndex; i < character.MemLocalState.Count; i++) + Hull serverHull = Hull.FindHull(serverPos.Position, character.CurrentHull, false); + Hull clientHull = Hull.FindHull(localPos.Position, serverHull, false); + + Vector2 positionError = serverPos.Position - localPos.Position; + float rotationError = serverPos.Rotation - localPos.Rotation; + + if (serverHull!=clientHull && ((serverHull==null) || (clientHull==null) || (serverHull.Submarine != clientHull.Submarine))) { - character.MemLocalState[i].Translate(positionError); + //hull subs don't match => just teleport the player to exactly this position to avoid mismatches, + //since this would completely break the camera + positionError = Collider.SimPosition - serverPos.Position; + character.MemLocalState.Clear(); + } + else + { + for (int i = localPosIndex; i < character.MemLocalState.Count; i++) + { + Hull pointHull = Hull.FindHull(character.MemLocalState[i].Position, clientHull, false); + if (pointHull != clientHull && ((pointHull == null) || (clientHull == null) || (pointHull.Submarine == clientHull.Submarine))) break; + character.MemLocalState[i].Translate(positionError, rotationError); + } } - Collider.SetTransform(Collider.SimPosition + positionError, Collider.Rotation); + Collider.SetTransform(Collider.SimPosition + positionError, Collider.Rotation + rotationError); + foreach (Limb limb in Limbs) + { + limb.body.SetTransform(limb.body.SimPosition + positionError, limb.body.Rotation); + } } if (character.MemLocalState.Count > 120) character.MemLocalState.RemoveRange(0, character.MemLocalState.Count - 120); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index 198eb25d4..bb15e2d8f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -138,6 +138,27 @@ namespace Barotrauma return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name : SpeciesName; } } + //Only used by server logs to determine "true identity" of the player for cases when they're disguised + public string LogName + { + get + { + return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name + (info.DisplayName != info.Name ? " (as " + info.DisplayName + ")" : "") : SpeciesName; + } + } + + private float hideFaceTimer; + public bool HideFace + { + get + { + return hideFaceTimer > 0.0f; + } + set + { + hideFaceTimer = MathHelper.Clamp(hideFaceTimer + (value ? 1.0f : -0.5f), 0.0f, 10.0f); + } + } public string ConfigPath { @@ -591,7 +612,7 @@ namespace Barotrauma { AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll")); AnimController.TargetDir = Direction.Right; - inventory = new CharacterInventory(16, this); + inventory = new CharacterInventory(17, this); } else { @@ -926,13 +947,16 @@ namespace Barotrauma } } - for (int i = 0; i < selectedItems.Length; i++ ) + if (SelectedConstruction == null || !SelectedConstruction.Prefab.DisableItemUsageWhenSelected) { - if (selectedItems[i] == null) continue; - if (i == 1 && selectedItems[0] == selectedItems[1]) continue; + for (int i = 0; i < selectedItems.Length; i++ ) + { + if (selectedItems[i] == null) continue; + if (i == 1 && selectedItems[0] == selectedItems[1]) continue; - if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this); - if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); + if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this); + if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this); + } } if (selectedConstruction != null) @@ -1406,6 +1430,8 @@ namespace Barotrauma item.Submarine = Submarine; } } + + HideFace = false; if (isDead) return; @@ -1633,7 +1659,7 @@ namespace Barotrauma var attackingCharacter = attacker as Character; if (attackingCharacter != null && attackingCharacter.AIController == null) { - GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, ServerLog.MessageType.Attack); + GameServer.Log(LogName + " attacked by " + attackingCharacter.LogName +". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, ServerLog.MessageType.Attack); } if (GameMain.Client == null && @@ -1798,7 +1824,7 @@ namespace Barotrauma AnimController.Frozen = false; - GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack); + GameServer.Log(LogName+" has died (Cause of death: "+causeOfDeath+")", ServerLog.MessageType.Attack); if (OnDeath != null) OnDeath(this, causeOfDeath); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs b/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs index dd6d8133f..12e5d93c4 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/CharacterInfo.cs @@ -12,7 +12,34 @@ namespace Barotrauma partial class CharacterInfo { public string Name; - + public string DisplayName + { + get { + string disguiseName = "?"; + if (Character != null && Character.HideFace) + { + if (Character.Inventory != null) + { + var idCard = Character.Inventory.FindItem("ID Card"); + if (idCard != null && Character.Inventory.IsInLimbSlot(idCard, InvSlotType.Card)) //Disguise as the ID card name if it's equipped + { + string[] readTags = idCard.Tags.Split(','); + foreach (string tag in readTags) + { + string[] s = tag.Split(':'); + if (s[0] == "name") + { + disguiseName = s[1]; + break; + } + } + } + } + return disguiseName; + } + return Name; + } + } public Character Character; public readonly string File; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/CharacterNetworking.cs b/Barotrauma/BarotraumaShared/Source/Characters/CharacterNetworking.cs index 28ab23947..0420bbab4 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/CharacterNetworking.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/CharacterNetworking.cs @@ -15,18 +15,18 @@ namespace Barotrauma public readonly AnimController.Animation Animation; - public CharacterStateInfo(Vector2 pos, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) - : this(pos, 0, time, dir, interact, animation) + public CharacterStateInfo(Vector2 pos, float rotation, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) + : this(pos, rotation, 0, time, dir, interact, animation) { } - public CharacterStateInfo(Vector2 pos, UInt16 ID, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) - : this(pos, ID, 0.0f, dir, interact, animation) + public CharacterStateInfo(Vector2 pos, float rotation, UInt16 ID, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) + : this(pos, rotation, ID, 0.0f, dir, interact, animation) { } - protected CharacterStateInfo(Vector2 pos, UInt16 ID, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) - : base(pos, ID, time) + protected CharacterStateInfo(Vector2 pos, float rotation, UInt16 ID, float time, Direction dir, Entity interact, AnimController.Animation animation = AnimController.Animation.None) + : base(pos, rotation, ID, time) { Direction = dir; Interact = interact; @@ -197,6 +197,7 @@ namespace Barotrauma { var posInfo = new CharacterStateInfo( SimPosition, + AnimController.Collider.Rotation, LastNetworkUpdateID, AnimController.TargetDir, SelectedCharacter == null ? (Entity)selectedConstruction : (Entity)SelectedCharacter, @@ -471,6 +472,7 @@ namespace Barotrauma tempBuffer.Write(SimPosition.X); tempBuffer.Write(SimPosition.Y); + tempBuffer.Write(AnimController.Collider.Rotation); tempBuffer.WritePadBits(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs index 2d207ec02..04271943d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs @@ -130,6 +130,10 @@ namespace Barotrauma { item.AddTag(s); } + item.AddTag("name:" + character.Name); + item.AddTag("job:" + Name); + if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc)) + item.Description = spawnPoint.IdCardDesc; } if (parentItem != null) parentItem.Combine(item); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs index a1d6cc4b0..1ef9c181f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/StatusEffect.cs @@ -265,7 +265,7 @@ namespace Barotrauma { SerializableProperty property; - if (!target.SerializableProperties.TryGetValue(propertyNames[i], out property)) continue; + if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(propertyNames[i], out property)) continue; if (duration > 0.0f) { diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index 15b2e7ffa..5919b05d7 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -97,7 +97,7 @@ namespace Barotrauma NewMessage("***************", Color.Cyan); foreach (Client c in GameMain.Server.ConnectedClients) { - NewMessage("- " + c.ID.ToString() + ": " + c.Name + ", " + c.Connection.RemoteEndPoint.Address.ToString(), Color.Cyan); + NewMessage("- " + c.ID.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Connection.RemoteEndPoint.Address.ToString(), Color.Cyan); } NewMessage("***************", Color.Cyan); })); @@ -114,6 +114,18 @@ namespace Barotrauma NewMessage("The code words are: " + traitorManager.codeWords + ", response: " + traitorManager.codeResponse + ".", Color.Cyan); })); + commands.Add(new Command("itemlist", "itemlist: List all the item prefabs available for spawning.", (string[] args) => + { + NewMessage("***************", Color.Cyan); + foreach (MapEntityPrefab ep in MapEntityPrefab.List) + { + var itemPrefab = ep as ItemPrefab; + if (itemPrefab == null || itemPrefab.Name == null) continue; + NewMessage("- " + itemPrefab.Name, Color.Cyan); + } + NewMessage("***************", Color.Cyan); + })); + commands.Add(new Command("createfilelist", "", (string[] args) => { UpdaterUtil.SaveFileList("filelist.xml"); @@ -360,7 +372,11 @@ namespace Barotrauma commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", (string[] args) => { if (GameMain.Server == null) return; - if (args.Length < 1) return; + if (args.Length < 1) + { + NewMessage("giveperm [id]: Grants administrative permissions to the player with the specified client ID.", Color.Cyan); + return; + } int id; int.TryParse(args[0], out id); @@ -370,7 +386,13 @@ namespace Barotrauma ThrowError("Client id \"" + id + "\" not found."); return; } - + + NewMessage("Valid permissions are:",Color.White); + NewMessage(" - all",Color.White); + foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions))) + { + NewMessage(" - " + permission.ToString(),Color.White); + } ShowQuestionPrompt("Permission to grant to \"" + client.Name + "\"?", (perm) => { ClientPermissions permission = ClientPermissions.None; @@ -380,7 +402,11 @@ namespace Barotrauma } else { - Enum.TryParse(perm, out permission); + if (!Enum.TryParse(perm, out permission)) + { + ThrowError("\"" + perm + "\" sn't a valid permission!"); + return; + } } client.SetPermissions(client.Permissions | permission); GameMain.Server.UpdateClientPermissions(client); @@ -391,7 +417,11 @@ namespace Barotrauma commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", (string[] args) => { if (GameMain.Server == null) return; - if (args.Length < 1) return; + if (args.Length < 1) + { + NewMessage("revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", Color.Cyan); + return; + } int id; int.TryParse(args[0], out id); @@ -402,6 +432,12 @@ namespace Barotrauma return; } + NewMessage("Valid permissions are:", Color.White); + NewMessage(" - all", Color.White); + foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions))) + { + NewMessage(" - " + permission.ToString(), Color.White); + } ShowQuestionPrompt("Permission to revoke from \"" + client.Name + "\"?", (perm) => { ClientPermissions permission = ClientPermissions.None; @@ -411,7 +447,11 @@ namespace Barotrauma } else { - Enum.TryParse(perm, out permission); + if (!Enum.TryParse(perm, out permission)) + { + ThrowError("\"" + perm + "\" isn't a valid permission!"); + return; + } } client.SetPermissions(client.Permissions & ~permission); GameMain.Server.UpdateClientPermissions(client); diff --git a/Barotrauma/BarotraumaShared/Source/Events/ArtifactEvent.cs b/Barotrauma/BarotraumaShared/Source/Events/ArtifactEvent.cs index 41b8577c4..be7ca10b1 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/ArtifactEvent.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/ArtifactEvent.cs @@ -34,7 +34,7 @@ namespace Barotrauma base.Init(); Vector2 position = Level.Loaded.GetRandomItemPos( - Level.PositionType.Cave | Level.PositionType.MainPath | Level.PositionType.Ruin, 500.0f, 30.0f); + Level.PositionType.Cave | Level.PositionType.MainPath | Level.PositionType.Ruin, 500.0f, 10000.0f, 30.0f); item = new Item(itemPrefab, position, null); item.MoveWithLevel = true; diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs index 315026dc8..bb2b00e00 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs @@ -28,7 +28,7 @@ namespace Barotrauma public override void Start(Level level) { Vector2 spawnPos; - Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, true, out spawnPos); + Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out spawnPos); monster = Character.Create(monsterFile, spawnPos, null, GameMain.Client != null, true, false); monster.Enabled = false; diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs index b5c4fc7b1..0d430ad10 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs @@ -46,7 +46,7 @@ namespace Barotrauma public override void Start(Level level) { - Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, 30.0f); + Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, Level.Loaded.Size.X * 0.3f, 30.0f); item = new Item(itemPrefab, position, null); item.MoveWithLevel = true; diff --git a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs index 9c2ed6ec2..9b6d2c34e 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs @@ -85,7 +85,7 @@ namespace Barotrauma if (disallowed) return null; Vector2 spawnPos; - if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, true, out spawnPos)) + if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, 20000.0f, out spawnPos)) { //no suitable position found, disable the event repeat = false; diff --git a/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs index b25a8e34a..00483a2e4 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs @@ -10,7 +10,7 @@ namespace Barotrauma [Flags] public enum InvSlotType { - None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64 + None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64, Card=128 }; partial class CharacterInventory : Inventory @@ -18,7 +18,7 @@ namespace Barotrauma private Character character; public static InvSlotType[] limbSlots = new InvSlotType[] { - InvSlotType.Head, InvSlotType.Torso, InvSlotType.Legs, InvSlotType.LeftHand, InvSlotType.RightHand, InvSlotType.Face, + InvSlotType.Head, InvSlotType.Torso, InvSlotType.Legs, InvSlotType.LeftHand, InvSlotType.RightHand, InvSlotType.Face, InvSlotType.Card, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any, InvSlotType.Any}; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/DockingPort.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/DockingPort.cs index 1b33e369a..236a2c85d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/DockingPort.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/DockingPort.cs @@ -699,12 +699,12 @@ namespace Barotrauma.Items.Components if (docked) { if (item.Submarine != null && dockingTarget?.item?.Submarine != null) - GameServer.Log(sender.Name + " docked " + item.Submarine.Name + " to " + dockingTarget.item.Submarine.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(sender.LogName + " docked " + item.Submarine.Name + " to " + dockingTarget.item.Submarine.Name, ServerLog.MessageType.ItemInteraction); } else { if (item.Submarine != null && prevDockingTarget?.item?.Submarine != null) - GameServer.Log(sender.Name + " undocked " + item.Submarine.Name + " from " + prevDockingTarget.item.Submarine.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(sender.LogName + " undocked " + item.Submarine.Name + " from " + prevDockingTarget.item.Submarine.Name, ServerLog.MessageType.ItemInteraction); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs index 5cf96029e..fbb0e3fe4 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Door.cs @@ -13,7 +13,7 @@ using Barotrauma.Lights; namespace Barotrauma.Items.Components { - partial class Door : ItemComponent, IDrawableComponent, IServerSerializable + partial class Door : Pickable, IDrawableComponent, IServerSerializable { private Gap linkedGap; @@ -203,12 +203,13 @@ namespace Barotrauma.Items.Components #endif } - - public override bool Pick(Character picker) + public override bool OnPicked(Character picker) { - isOpen = !isOpen; - - return true; + SetState(predictedState == null ? !isOpen : !predictedState.Value, false, true); //crowbar function +#if CLIENT + PlaySound(ActionType.OnPicked, item.WorldPosition); +#endif + return false; } public override bool Select(Character character) @@ -419,7 +420,7 @@ namespace Barotrauma.Items.Components bool newState = predictedState == null ? isOpen : predictedState.Value; if (sender != null && wasOpen != newState) { - GameServer.Log(sender.Name + (newState ? " opened " : " closed ") + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(sender.LogName + (newState ? " opened " : " closed ") + item.Name, ServerLog.MessageType.ItemInteraction); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 73d99dedc..22d855569 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -184,13 +184,13 @@ namespace Barotrauma.Items.Components item.SetTransform(rightHand.SimPosition, 0.0f); } - bool alreadySelected = character.HasSelectedItem(item); - if (picker.TrySelectItem(item)) + bool alreadySelected = character.HasEquippedItem(item); + if (picker.TrySelectItem(item) || picker.HasEquippedItem(item)) { item.body.Enabled = true; IsActive = true; - if (!alreadySelected) GameServer.Log(character.Name + " equipped " + item.Name, ServerLog.MessageType.ItemInteraction); + if (!alreadySelected) GameServer.Log(character.LogName + " equipped " + item.Name, ServerLog.MessageType.ItemInteraction); } } @@ -200,7 +200,7 @@ namespace Barotrauma.Items.Components picker.DeselectItem(item); - GameServer.Log(character.Name + " unequipped " + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(character.LogName + " unequipped " + item.Name, ServerLog.MessageType.ItemInteraction); item.body.Enabled = false; IsActive = false; @@ -224,7 +224,7 @@ namespace Barotrauma.Items.Components } } - protected override bool OnPicked(Character picker) + public override bool OnPicked(Character picker) { if (base.OnPicked(picker)) { @@ -235,7 +235,7 @@ namespace Barotrauma.Items.Components item.CreateServerEvent(this); if (picker != null) { - Networking.GameServer.Log(picker.Name + " detached " + item.Name + " from a wall", ServerLog.MessageType.ItemInteraction); + Networking.GameServer.Log(picker.LogName + " detached " + item.Name + " from a wall", ServerLog.MessageType.ItemInteraction); } } return true; @@ -290,7 +290,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { item.CreateServerEvent(this); - GameServer.Log(character.Name + " attached " + item.Name+" to a wall", ServerLog.MessageType.ItemInteraction); + GameServer.Log(character.LogName + " attached " + item.Name+" to a wall", ServerLog.MessageType.ItemInteraction); } item.Drop(); } @@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { if (item.body == null || !item.body.Enabled) return; - if (picker == null || !picker.HasSelectedItem(item)) + if (picker == null || !picker.HasEquippedItem(item)) { IsActive = false; return; @@ -320,7 +320,37 @@ namespace Barotrauma.Items.Components item.Submarine = picker.Submarine; - picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle); + if (picker.HasSelectedItem(item)) + { + picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle); + } + else + { + Limb equipLimb = null; + if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Face) || picker.Inventory.IsInLimbSlot(item, InvSlotType.Head)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Head); + } + else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Torso)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Torso); + } + else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Legs)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Waist); + } + + if (equipLimb != null) + { + float itemAngle = (equipLimb.Rotation + holdAngle * picker.AnimController.Dir); + + Matrix itemTransfrom = Matrix.CreateRotationZ(equipLimb.Rotation); + Vector2 transformedHandlePos = Vector2.Transform(handlePos[0], itemTransfrom); + + item.body.ResetDynamics(); + item.SetTransform(equipLimb.SimPosition - transformedHandlePos, itemAngle); + } + } } protected void Flip(Item item) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs index b98cb3361..38f8ca61a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/MeleeWeapon.cs @@ -137,7 +137,7 @@ namespace Barotrauma.Items.Components } else { - ac.HoldItem(deltaTime, item, handlePos, new Vector2(hitPos, 0.0f), aimPos, false, holdAngle); + ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, false, holdAngle); } } else @@ -255,12 +255,12 @@ namespace Barotrauma.Items.Components { GameMain.Server.CreateEntityEvent(item, new object[] { Networking.NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, targetCharacter.ID }); - string logStr = picker?.Name + " used " + item.Name; + string logStr = picker?.LogName + " used " + item.Name; if (item.ContainedItems != null && item.ContainedItems.Length > 0) { logStr += "(" + string.Join(", ", item.ContainedItems.Select(i => i?.Name)) + ")"; } - logStr += " on " + targetCharacter + "."; + logStr += " on " + targetCharacter.LogName + "."; Networking.GameServer.Log(logStr, Networking.ServerLog.MessageType.Attack); } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs index 7ee70e2c4..69e06f783 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs @@ -70,7 +70,7 @@ namespace Barotrauma.Items.Components } } - protected virtual bool OnPicked(Character picker) + public virtual bool OnPicked(Character picker) { if (picker.Inventory.TryPutItem(item, picker, allowedSlots)) { @@ -89,6 +89,7 @@ namespace Barotrauma.Items.Components #if CLIENT if (!GameMain.Instance.LoadingScreenOpen && picker == Character.Controlled) GUI.PlayUISound(GUISoundType.PickItem); + PlaySound(ActionType.OnPicked, item.WorldPosition); #endif return true; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs index 751a14836..7d31ae1d8 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs @@ -11,6 +11,7 @@ namespace Barotrauma.Items.Components float throwPos; bool throwing; + bool throwDone; [Serialize(1.0f, false)] public float ThrowForce @@ -27,18 +28,14 @@ namespace Barotrauma.Items.Components public override bool Use(float deltaTime, Character character = null) { - if (character == null) return false; - if (!character.IsKeyDown(InputType.Aim) || throwing) return false; - - throwing = true; - - IsActive = true; - return true; + return true; //We do the actual throwing in Aim because Use might be used by chems } - public override void SecondaryUse(float deltaTime, Character character = null) + public override bool SecondaryUse(float deltaTime, Character character = null) { - if (throwing) return; + if (!throwDone) return false; //This should only be triggered in update + throwDone = false; + return true; } public override void Drop(Character dropper) @@ -57,7 +54,14 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { if (!item.body.Enabled) return; - if (!picker.HasSelectedItem(item)) IsActive = false; + if (!picker.HasSelectedItem(item)) + { + IsActive = false; + return; + } + + if (picker.IsKeyDown(InputType.Aim) && picker.IsKeyHit(InputType.Use)) + throwing = true; if (!picker.IsKeyDown(InputType.Aim) && !throwing) throwPos = 0.0f; @@ -93,7 +97,7 @@ namespace Barotrauma.Items.Components Vector2 throwVector = picker.CursorWorldPosition - picker.WorldPosition; throwVector = Vector2.Normalize(throwVector); - GameServer.Log(picker.Name + " threw " + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(picker.LogName + " threw " + item.Name, ServerLog.MessageType.ItemInteraction); item.Drop(); item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f); @@ -103,7 +107,8 @@ namespace Barotrauma.Items.Components Limb rightHand = ac.GetLimb(LimbType.RightHand); item.body.AngularVelocity = rightHand.body.AngularVelocity; - + throwDone = true; + ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, picker); //Stun grenades, flares, etc. all have their throw-related things handled in "onSecondaryUse" throwing = false; } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs index 26bb3f2ad..498279d26 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs @@ -291,7 +291,10 @@ namespace Barotrauma.Items.Components } //called when the item is equipped and right mouse button is pressed - public virtual void SecondaryUse(float deltaTime, Character character = null) { } + public virtual bool SecondaryUse(float deltaTime, Character character = null) + { + return false; + } //called when the item is placed in a "limbslot" public virtual void Equip(Character character) { } @@ -503,13 +506,15 @@ namespace Barotrauma.Items.Components } List prevRequiredItems = new List(requiredItems); - requiredItems.Clear(); + bool overrideRequiredItems = false; foreach (XElement subElement in componentElement.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "requireditem": + if (!overrideRequiredItems) requiredItems.Clear(); + overrideRequiredItems = true; RelatedItem newRequiredItem = RelatedItem.Load(subElement); if (newRequiredItem == null) continue; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs index b75f1eb4b..3dbd1799a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs @@ -160,20 +160,20 @@ namespace Barotrauma.Items.Components return true; } - public override void SecondaryUse(float deltaTime, Character character = null) + public override bool SecondaryUse(float deltaTime, Character character = null) { if (this.character == null || this.character != character || this.character.SelectedConstruction != item || !character.CanInteractWith(item)) { character = null; - return; + return false; } - if (character == null) return; + if (character == null) return false; Entity focusTarget = GetFocusTarget(); if (focusTarget == null) { item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character); - return; + return false; } character.ViewTarget = focusTarget; @@ -191,6 +191,8 @@ namespace Barotrauma.Items.Components { item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character); } + + return true; } private Item GetFocusTarget() diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs index d9f127d14..96b285ea4 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs @@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components if (user != null) { - GameServer.Log(user.Name + (IsActive ? " activated " : " deactivated ") + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(user.LogName + (IsActive ? " activated " : " deactivated ") + item.Name, ServerLog.MessageType.ItemInteraction); } #if CLIENT diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs index 299bdf083..9857fb052 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs @@ -159,7 +159,7 @@ namespace Barotrauma.Items.Components if (user != null) { - GameServer.Log(user.Name + " started fabricating " + selectedItem.TargetItem.Name + " in " + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(user.LogName + " started fabricating " + selectedItem.TargetItem.Name + " in " + item.Name, ServerLog.MessageType.ItemInteraction); } #if CLIENT @@ -184,7 +184,7 @@ namespace Barotrauma.Items.Components { if (fabricatedItem != null && user != null) { - GameServer.Log(user.Name + " cancelled the fabrication of " + fabricatedItem.TargetItem.Name + " in " + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(user.LogName + " cancelled the fabrication of " + fabricatedItem.TargetItem.Name + " in " + item.Name, ServerLog.MessageType.ItemInteraction); } IsActive = false; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Pump.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Pump.cs index 88e7b74eb..b99f8ef31 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Pump.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Pump.cs @@ -157,11 +157,11 @@ namespace Barotrauma.Items.Components { if (newFlowPercentage != FlowPercentage) { - GameServer.Log(c.Character + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(c.Character.LogName + " set the pumping speed of " + item.Name + " to " + (int)(newFlowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } if (newIsActive != IsActive) { - GameServer.Log(c.Character + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(c.Character.LogName + (newIsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); } FlowPercentage = newFlowPercentage; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs index 9d25c3058..9e3b031f5 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Reactor.cs @@ -173,7 +173,7 @@ namespace Barotrauma.Items.Components { if (Timing.TotalTime >= (float)nextServerLogWriteTime) { - GameServer.Log(lastUser + " adjusted reactor settings: " + + GameServer.Log(lastUser.LogName + " adjusted reactor settings: " + "Temperature: " + (int)temperature + ", Fission rate: " + (int)fissionRate + ", Cooling rate: " + (int)coolingRate + diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs index be46a3539..47626ff3e 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/PowerContainer.cs @@ -201,7 +201,7 @@ namespace Barotrauma.Items.Components if (item.CanClientAccess(c)) { RechargeSpeed = newRechargeSpeed; - GameServer.Log(c.Character + " set the recharge speed of "+item.Name+" to "+ (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); + GameServer.Log(c.Character.LogName + " set the recharge speed of "+item.Name+" to "+ (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", ServerLog.MessageType.ItemInteraction); } item.CreateServerEvent(this); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/Powered.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/Powered.cs index 3f17757a3..60e3da7d2 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Power/Powered.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Power/Powered.cs @@ -88,7 +88,16 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { - if (currPowerConsumption == 0.0f) return; + if (currPowerConsumption == 0.0f) + { + //if the item consumes no power, ignore the voltage requirement and + //apply OnActive statuseffects as long as this component is active + if (powerConsumption == 0.0f) + { + ApplyStatusEffects(ActionType.OnActive, deltaTime, null); + } + return; + } #if CLIENT if (voltage > minVoltage) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs index 16e8b97a7..c5c079d2e 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Projectile.cs @@ -12,9 +12,14 @@ namespace Barotrauma.Items.Components { class Projectile : ItemComponent { - private float launchImpulse; + //continuous collision detection is used while the projectile is moving faster than this + const float ContinuousCollisionThreshold = 5.0f; - private bool doesStick; + //a duration during which the projectile won't drop from the body it's stuck to + private const float PersistentStickJointDuration = 1.0f; + + private float launchImpulse; + private PrismaticJoint stickJoint; private Body stickTarget; @@ -24,6 +29,8 @@ namespace Barotrauma.Items.Components public Character User; + private float persistentStickJointTimer; + [Serialize(10.0f, false)] public float LaunchImpulse { @@ -39,10 +46,32 @@ namespace Barotrauma.Items.Components } [Serialize(false, false)] + //backwards compatibility, can stick to anything public bool DoesStick { - get { return doesStick; } - set { doesStick = value; } + get; + set; + } + + [Serialize(false, false)] + public bool StickToCharacters + { + get; + set; + } + + [Serialize(false, false)] + public bool StickToStructures + { + get; + set; + } + + [Serialize(false, false)] + public bool StickToItems + { + get; + set; } [Serialize(false, false)] @@ -106,7 +135,7 @@ namespace Barotrauma.Items.Components IsActive = true; - if (stickJoint == null || !doesStick) return; + if (stickJoint == null) return; if (stickTarget != null) { @@ -182,7 +211,7 @@ namespace Barotrauma.Items.Components //the raycast didn't hit anything -> the projectile flew somewhere outside the level and is permanently lost if (!hitSomething) { - Item.Spawner.AddToRemoveQueue(item); + Entity.Spawner.AddToRemoveQueue(item); } } @@ -190,8 +219,23 @@ namespace Barotrauma.Items.Components { ApplyStatusEffects(ActionType.OnActive, deltaTime, null); - if (stickJoint != null && - (stickJoint.JointTranslation < stickJoint.LowerLimit * 0.9f || stickJoint.JointTranslation > stickJoint.UpperLimit * 0.9f)) + if (item.body != null && item.body.FarseerBody.IsBullet) + { + if (item.body.LinearVelocity.LengthSquared() < ContinuousCollisionThreshold * ContinuousCollisionThreshold) + { + item.body.FarseerBody.IsBullet = false; + } + } + + if (stickJoint == null) return; + + if (persistentStickJointTimer > 0.0f) + { + persistentStickJointTimer -= deltaTime; + return; + } + + if (stickJoint.JointTranslation < stickJoint.LowerLimit * 0.9f || stickJoint.JointTranslation > stickJoint.UpperLimit * 0.9f) { if (stickTarget != null) { @@ -218,7 +262,7 @@ namespace Barotrauma.Items.Components stickJoint = null; - IsActive = false; + if (!item.body.FarseerBody.IsBullet) IsActive = false; } } @@ -237,6 +281,7 @@ namespace Barotrauma.Items.Components } AttackResult attackResult = new AttackResult(); + Character character = null; if (attack != null) { var submarine = target.Body.UserData as Submarine; @@ -248,11 +293,13 @@ namespace Barotrauma.Items.Components return true; } - Limb limb; + Limb limb = target.Body.UserData as Limb; Structure structure; - if ((limb = (target.Body.UserData as Limb)) != null) + if (limb != null) { attackResult = attack.DoDamageToLimb(User, limb, item.WorldPosition, 1.0f); + if (limb.character != null) + character = limb.character; } else if ((structure = (target.Body.UserData as Structure)) != null) { @@ -260,14 +307,11 @@ namespace Barotrauma.Items.Components } } - ApplyStatusEffects(ActionType.OnUse, 1.0f); - ApplyStatusEffects(ActionType.OnImpact, 1.0f); - - IsActive = false; - + ApplyStatusEffects(ActionType.OnUse, 1.0f, character); + ApplyStatusEffects(ActionType.OnImpact, 1.0f, character); + item.body.FarseerBody.OnCollision -= OnProjectileCollision; - item.body.FarseerBody.IsBullet = false; item.body.CollisionCategories = Physics.CollisionItem; item.body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel; @@ -280,17 +324,20 @@ namespace Barotrauma.Items.Components { item.body.LinearVelocity *= 0.1f; } - else if (doesStick) + else if (Vector2.Dot(item.body.LinearVelocity, collisionNormal) < 0.0f && + (DoesStick || + (StickToCharacters && target.Body.UserData is Limb) || + (StickToStructures && target.Body.UserData is Structure) || + (StickToItems && target.Body.UserData is Item))) { Vector2 dir = new Vector2( (float)Math.Cos(item.body.Rotation), (float)Math.Sin(item.body.Rotation)); + + StickToTarget(target.Body, dir); + item.body.LinearVelocity *= 0.5f; - if (Vector2.Dot(item.body.LinearVelocity, collisionNormal) < 0.0f) - { - StickToTarget(target.Body, dir); - return Hitscan; - } + return Hitscan; } else { @@ -306,7 +353,7 @@ namespace Barotrauma.Items.Components { contained.SetTransform(item.SimPosition, contained.body.Rotation); } - contained.Condition = 0.0f; + //contained.Condition = 0.0f; //Let the freaking .xml handle it jeez } } @@ -333,6 +380,8 @@ namespace Barotrauma.Items.Components stickJoint.UpperLimit = ConvertUnits.ToSimUnits(item.Sprite.size.X * 0.3f); } + persistentStickJointTimer = PersistentStickJointDuration; + item.body.FarseerBody.IgnoreCollisionWith(targetBody); stickTarget = targetBody; GameMain.World.AddJoint(stickJoint); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Rope.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Rope.cs index db4f8068d..feb13df8a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Rope.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Rope.cs @@ -118,9 +118,9 @@ namespace Barotrauma.Items.Components } - public override void SecondaryUse(float deltaTime, Character character = null) + public override bool SecondaryUse(float deltaTime, Character character = null) { - if (reload > 0.0f) return; + if (reload > 0.0f) return false; bool first = true; for (int i = 0; i < ropeBodies.Length - 1; i++) @@ -157,7 +157,8 @@ namespace Barotrauma.Items.Components //ropeBodies[i + 1].ApplyForce(dist / length * pullForce * 0.1f); } - } + } + return true; } private void NextSection(int i) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs index 7b25c669b..f82c732d3 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs @@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components if (existingWire.Locked) { //this should not be possible unless the client is running a modified version of the game - GameServer.Log(c.Character.Name + " attempted to disconnect a locked wire from " + + GameServer.Log(c.Character.LogName + " attempted to disconnect a locked wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Error); continue; } @@ -224,20 +224,37 @@ namespace Barotrauma.Items.Components if (existingWire.Connections[0] == null && existingWire.Connections[1] == null) { - GameServer.Log(c.Character.Name + " disconnected a wire from " + + GameServer.Log(c.Character.LogName + " disconnected a wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.ItemInteraction); } else if (existingWire.Connections[0] != null) { - GameServer.Log(c.Character.Name + " disconnected a wire from " + + GameServer.Log(c.Character.LogName + " disconnected a wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + existingWire.Connections[0].Item.Name + " (" + existingWire.Connections[0].Name + ")", ServerLog.MessageType.ItemInteraction); + + //wires that are not in anyone's inventory (i.e. not currently being rewired) + //can never be connected to only one connection + // -> the client must have dropped the wire from the connection panel + if (existingWire.Item.ParentInventory == null) + { + //let other clients know the item was also disconnected from the other connection + existingWire.Connections[0].Item.CreateServerEvent(existingWire.Connections[0].Item.GetComponent()); + existingWire.Item.Drop(c.Character); + } } else if (existingWire.Connections[1] != null) { - GameServer.Log(c.Character.Name + " disconnected a wire from " + + GameServer.Log(c.Character.LogName + " disconnected a wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + existingWire.Connections[1].Item.Name + " (" + existingWire.Connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); - } + if (existingWire.Item.ParentInventory == null) + { + //let other clients know the item was also disconnected from the other connection + existingWire.Connections[1].Item.CreateServerEvent(existingWire.Connections[1].Item.GetComponent()); + existingWire.Item.Drop(c.Character); + } + } + Connections[i].Wires[j] = null; } @@ -259,13 +276,13 @@ namespace Barotrauma.Items.Components if (otherConnection == null) { - GameServer.Log(c.Character.Name + " connected a wire to " + + GameServer.Log(c.Character.LogName + " connected a wire to " + Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.ItemInteraction); } else { - GameServer.Log(c.Character.Name + " connected a wire from " + + GameServer.Log(c.Character.LogName + " connected a wire from " + Connections[i].Item.Name + " (" + Connections[i].Name + ") to " + (otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction); @@ -281,6 +298,9 @@ namespace Barotrauma.Items.Components public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { + List prevWires = Connections.SelectMany(c => Array.FindAll(c.Wires, w => w != null)).ToList(); + List newWires = new List(); + foreach (Connection connection in Connections) { connection.ClearConnections(); @@ -289,16 +309,33 @@ namespace Barotrauma.Items.Components { ushort wireId = msg.ReadUInt16(); - Item wireItem = MapEntity.FindEntityByID(wireId) as Item; + Item wireItem = Entity.FindEntityByID(wireId) as Item; if (wireItem == null) continue; Wire wireComponent = wireItem.GetComponent(); if (wireComponent == null) continue; + newWires.Add(wireComponent); + connection.Wires[i] = wireComponent; wireComponent.Connect(connection, false); } } + + foreach (Wire wire in prevWires) + { + if (wire.Connections[0] == null && wire.Connections[1] == null) + { + wire.Item.Drop(null); + } + //wires that are not in anyone's inventory (i.e. not currently being rewired) can never be connected to only one connection + // -> someone must have dropped the wire from the connection panel + else if (wire.Item.ParentInventory == null && + (wire.Connections[0] != null ^ wire.Connections[1] != null)) + { + wire.Item.Drop(null); + } + } } } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs index 086df16b3..f32fa02d9 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs @@ -242,7 +242,7 @@ namespace Barotrauma.Items.Components return true; } - public override void SecondaryUse(float deltaTime, Character character = null) + public override bool SecondaryUse(float deltaTime, Character character = null) { if (nodes.Count > 1) { @@ -251,6 +251,7 @@ namespace Barotrauma.Items.Components } Drawable = IsActive || sections.Count > 0; + return true; } public override bool Pick(Character picker) @@ -307,18 +308,18 @@ namespace Barotrauma.Items.Components { if (connections[0] != null && connections[1] != null) { - GameServer.Log(user.Name + " disconnected a wire from " + + GameServer.Log(user.LogName + " disconnected a wire from " + connections[0].Item.Name + " (" + connections[0].Name + ") to "+ connections[1].Item.Name + " (" + connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); } else if (connections[0] != null) { - GameServer.Log(user.Name + " disconnected a wire from " + + GameServer.Log(user.LogName + " disconnected a wire from " + connections[0].Item.Name + " (" + connections[0].Name + ")", ServerLog.MessageType.ItemInteraction); } else if (connections[1] != null) { - GameServer.Log(user.Name + " disconnected a wire from " + + GameServer.Log(user.LogName + " disconnected a wire from " + connections[1].Item.Name + " (" + connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs index 5d3563d18..29d5c60e4 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Turret.cs @@ -175,7 +175,7 @@ namespace Barotrauma.Items.Components if (character != null) { - string msg = character.Name + " launched " + item.Name + " (projectile: " + projectiles[0].Item.Name; + string msg = character.LogName + " launched " + item.Name + " (projectile: " + projectiles[0].Item.Name; if (projectiles[0].Item.ContainedItems == null || projectiles[0].Item.ContainedItems.All(i => i == null)) { msg += ")"; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs index ed782dd53..669b68f34 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs @@ -212,11 +212,11 @@ namespace Barotrauma { if (Owner == c.Character) { - GameServer.Log(c.Character + " picked up " + item.Name, ServerLog.MessageType.Inventory); + GameServer.Log(c.Character.LogName+ " picked up " + item.Name, ServerLog.MessageType.Inventory); } else { - GameServer.Log(c.Character + " placed " + item.Name + " in " + Owner, ServerLog.MessageType.Inventory); + GameServer.Log(c.Character.LogName + " placed " + item.Name + " in " + Owner, ServerLog.MessageType.Inventory); } } } @@ -227,11 +227,11 @@ namespace Barotrauma { if (Owner == c.Character) { - GameServer.Log(c.Character + " dropped " + item.Name, ServerLog.MessageType.Inventory); + GameServer.Log(c.Character.LogName + " dropped " + item.Name, ServerLog.MessageType.Inventory); } else { - GameServer.Log(c.Character + " removed " + item.Name + " from " + Owner, ServerLog.MessageType.Inventory); + GameServer.Log(c.Character.LogName + " removed " + item.Name + " from " + Owner, ServerLog.MessageType.Inventory); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 5405a9816..8af99c2af 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -119,9 +119,12 @@ namespace Barotrauma get { return prefab.Name; } } + private string description; + [Editable, Serialize("", true)] public string Description { - get { return prefab.Description; } + get { return description == null ? prefab.Description : description; } + set { description = value; } } public float ImpactTolerance @@ -800,6 +803,7 @@ namespace Barotrauma if (!ic.WasUsed) { ic.StopSounds(ActionType.OnUse); + ic.StopSounds(ActionType.OnSecondaryUse); } #endif ic.WasUsed = false; @@ -1167,11 +1171,28 @@ namespace Barotrauma public void SecondaryUse(float deltaTime, Character character = null) { + if (condition == 0.0f) return; + + bool remove = false; + foreach (ItemComponent ic in components) { if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue; - ic.SecondaryUse(deltaTime, character); + if (ic.SecondaryUse(deltaTime, character)) + { + ic.WasUsed = true; + +#if CLIENT + ic.PlaySound(ActionType.OnSecondaryUse, WorldPosition); +#endif + + ic.ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, character); + + if (ic.DeleteOnUse) remove = true; + } } + + if (remove) Remove(); } public List GetHUDTexts(Character character) @@ -1341,12 +1362,12 @@ namespace Barotrauma if (ContainedItems == null || ContainedItems.All(i => i == null)) { - GameServer.Log(c.Character.Name + " used item " + Name, ServerLog.MessageType.ItemInteraction); + GameServer.Log(c.Character.LogName + " used item " + Name, ServerLog.MessageType.ItemInteraction); } else { GameServer.Log( - c.Character.Name + " used item " + Name + " (contained items: " + string.Join(", ", Array.FindAll(ContainedItems, i => i != null).Select(i => i.Name)) + ")", + c.Character.LogName + " used item " + Name + " (contained items: " + string.Join(", ", Array.FindAll(ContainedItems, i => i != null).Select(i => i.Name)) + ")", ServerLog.MessageType.ItemInteraction); } @@ -1440,6 +1461,7 @@ namespace Barotrauma if (GameMain.Server == null) return; msg.Write(Prefab.Name); + msg.Write(Description); msg.Write(ID); if (ParentInventory == null || ParentInventory.Owner == null) @@ -1458,7 +1480,8 @@ namespace Barotrauma msg.Write(index < 0 ? (byte)255 : (byte)index); } - if (Name == "ID Card") msg.Write(Tags); + //TODO: See if tags are different from their prefab before sending 'em + msg.Write(Tags); } public static Item ReadSpawnData(NetBuffer msg, bool spawn = true) @@ -1466,6 +1489,7 @@ namespace Barotrauma if (GameMain.Server != null) return null; string itemName = msg.ReadString(); + string itemDesc = msg.ReadString(); ushort itemId = msg.ReadUInt16(); ushort inventoryId = msg.ReadUInt16(); @@ -1489,11 +1513,7 @@ namespace Barotrauma } } - string tags = ""; - if (itemName == "ID Card") - { - tags = msg.ReadString(); - } + string tags = msg.ReadString(); if (!spawn) return null; @@ -1523,6 +1543,7 @@ namespace Barotrauma var item = new Item(itemPrefab, pos, sub); + item.Description = itemDesc; item.ID = itemId; if (sub != null) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index a1ec49bbd..dba9dfd98 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -134,6 +134,13 @@ namespace Barotrauma private set; } + [Serialize(false, false)] + public bool DisableItemUsageWhenSelected + { + get; + private set; + } + public bool CanSpriteFlipX { get { return canSpriteFlipX; } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs b/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs index ae4401112..5c3a6999c 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Explosion.cs @@ -74,6 +74,15 @@ namespace Barotrauma { if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue; + //don't apply OnFire effects if the item is inside a fireproof container + //(or if it's inside a container that's inside a fireproof container, etc) + Item container = item.Container; + while (container != null) + { + if (container.FireProof) return; + container = container.Container; + } + if (Vector2.Distance(item.WorldPosition, worldPosition) > attack.Range * 0.1f) continue; item.ApplyStatusEffects(ActionType.OnFire, 1.0f); diff --git a/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs b/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs index bfa7eb231..4f0a684ce 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs @@ -217,7 +217,15 @@ namespace Barotrauma foreach (Item item in Item.ItemList) { if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue; - if (item.ParentInventory != null && item.ParentInventory.Owner is Character) return; + + //don't apply OnFire effects if the item is inside a fireproof container + //(or if it's inside a container that's inside a fireproof container, etc) + Item container = item.Container; + while (container != null) + { + if (container.FireProof) return; + container = container.Container; + } float range = (float)Math.Sqrt(size.X) * 10.0f; if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Gap.cs b/Barotrauma/BarotraumaShared/Source/Map/Gap.cs index cf1969028..8b79581b2 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Gap.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Gap.cs @@ -163,8 +163,11 @@ namespace Barotrauma searchPos[1] = new Vector2(rect.Center.X, rect.Y - rect.Height); } - hulls[0] = Hull.FindHullOld(searchPos[0], null, false); - hulls[1] = Hull.FindHullOld(searchPos[1], null, false); + for (int i = 0; i < 2; i++) + { + hulls[i] = Hull.FindHullOld(searchPos[i], null, false); + if (hulls[i] == null) hulls[i] = Hull.FindHullOld(searchPos[i], null, false, true); + } if (hulls[0] == null && hulls[1] == null) return; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 932807c2b..a74c65fd7 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -558,23 +558,23 @@ namespace Barotrauma return null; } - + //returns the water block which contains the point (or null if it isn't inside any) - public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true) + public static Hull FindHullOld(Vector2 position, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false) { - return FindHullOld(position, hullList, guess, useWorldCoordinates); + return FindHullOld(position, hullList, guess, useWorldCoordinates, inclusive); } - public static Hull FindHullOld(Vector2 position, List hulls, Hull guess = null, bool useWorldCoordinates = true) + public static Hull FindHullOld(Vector2 position, List hulls, Hull guess = null, bool useWorldCoordinates = true, bool inclusive = false) { if (guess != null && hulls.Contains(guess)) { - if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess; + if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position, inclusive)) return guess; } foreach (Hull hull in hulls) { - if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position)) return hull; + if (Submarine.RectContains(useWorldCoordinates ? hull.WorldRect : hull.rect, position, inclusive)) return hull; } return null; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs index 236cffcfe..74abdf6df 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs @@ -817,7 +817,7 @@ namespace Barotrauma //50% chance of placing the ruins at a cave if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.5f) { - TryGetInterestingPosition(true, PositionType.Cave, false, out ruinPos); + TryGetInterestingPosition(true, PositionType.Cave, 0.0f, out ruinPos); } ruinPos.Y = Math.Min(ruinPos.Y, borders.Y + borders.Height - ruinSize.Y / 2); @@ -894,7 +894,7 @@ namespace Barotrauma } } - public Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float offsetFromWall = 10.0f) + public Vector2 GetRandomItemPos(PositionType spawnPosType, float randomSpread, float minDistFromSubs, float offsetFromWall = 10.0f) { if (!positionsOfInterest.Any()) return Size*0.5f; @@ -906,7 +906,7 @@ namespace Barotrauma do { Vector2 startPos; - Level.Loaded.TryGetInterestingPosition(true, spawnPosType, true, out startPos); + Loaded.TryGetInterestingPosition(true, spawnPosType, minDistFromSubs, out startPos); startPos += Rand.Vector(Rand.Range(0.0f, randomSpread, Rand.RandSync.Server), Rand.RandSync.Server); @@ -935,7 +935,7 @@ namespace Barotrauma - public bool TryGetInterestingPosition(bool useSyncedRand, PositionType positionType, bool avoidSubs, out Vector2 position) + public bool TryGetInterestingPosition(bool useSyncedRand, PositionType positionType, float minDistFromSubs, out Vector2 position) { if (!positionsOfInterest.Any()) { @@ -945,17 +945,20 @@ namespace Barotrauma var matchingPositions = positionsOfInterest.FindAll(p => positionType.HasFlag(p.PositionType)); - if (avoidSubs) + if (minDistFromSubs > 0.0f) { foreach (Submarine sub in Submarine.Loaded) { - float minDist = Math.Max(sub.Borders.Width, sub.Borders.Height); - matchingPositions.RemoveAll(p => Vector2.Distance(p.Position, sub.WorldPosition) < minDist); + matchingPositions.RemoveAll(p => Vector2.DistanceSquared(p.Position, sub.WorldPosition) < minDistFromSubs * minDistFromSubs); } } if (!matchingPositions.Any()) { +#if DEBUG + DebugConsole.ThrowError("Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + "\n" + Environment.StackTrace); +#endif + position = positionsOfInterest[Rand.Int(positionsOfInterest.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position; return false; } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index 06d60a7e0..db64086cc 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -506,15 +506,15 @@ namespace Barotrauma float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal)*f2.Body.Mass*0.1f; - if (impact < 10.0f) return true; - #if CLIENT SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact, new Vector2( - sections[section].rect.X + sections[section].rect.Width / 2, - sections[section].rect.Y - sections[section].rect.Height / 2)); + sections[section].rect.X + sections[section].rect.Width / 2, + sections[section].rect.Y - sections[section].rect.Height / 2), tags: Tags); #endif + if (impact < 10.0f) return true; + AddDamage(section, impact); } } @@ -661,10 +661,10 @@ namespace Barotrauma #if CLIENT GameMain.ParticleManager.CreateParticle("dustcloud", SectionPosition(i), 0.0f, 0.0f); - if (playSound && !SectionBodyDisabled(i)) + if (playSound)// && !SectionBodyDisabled(i)) { DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash; - SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition); + SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition, tags: Tags); } #endif diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs index 45b4f17c0..854adb3be 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs @@ -491,10 +491,18 @@ namespace Barotrauma return new Rectangle((int)pos.X, (int)pos.Y, (int)size.X, (int)size.Y); } - public static bool RectContains(Rectangle rect, Vector2 pos) + public static bool RectContains(Rectangle rect, Vector2 pos, bool inclusive = false) { - return (pos.X > rect.X && pos.X < rect.X + rect.Width - && pos.Y < rect.Y && pos.Y > rect.Y - rect.Height); + if (inclusive) + { + return (pos.X >= rect.X && pos.X <= rect.X + rect.Width + && pos.Y <= rect.Y && pos.Y >= rect.Y - rect.Height); + } + else + { + return (pos.X > rect.X && pos.X < rect.X + rect.Width + && pos.Y < rect.Y && pos.Y > rect.Y - rect.Height); + } } public static bool RectsOverlap(Rectangle rect1, Rectangle rect2, bool inclusive=true) @@ -1258,7 +1266,7 @@ namespace Barotrauma return; } - subBody.MemPos.Insert(index, new PosInfo(newTargetPosition, sendingTime)); + subBody.MemPos.Insert(index, new PosInfo(newTargetPosition, 0.0f, sendingTime)); } } diff --git a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs index 809426c4c..65fb6bc8c 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/WayPoint.cs @@ -21,6 +21,7 @@ namespace Barotrauma protected SpawnType spawnType; //characters spawning at the waypoint will be given an ID card with these tags + private string idCardDesc; private string[] idCardTags; //only characters with this job will be spawned at the waypoint @@ -57,6 +58,11 @@ namespace Barotrauma } } + public string IdCardDesc + { + get { return idCardDesc; } + private set { idCardDesc = value; } + } public string[] IdCardTags { get { return idCardTags; } @@ -113,6 +119,7 @@ namespace Barotrauma public override MapEntity Clone() { var clone = new WayPoint(rect, Submarine); + clone.idCardDesc = idCardDesc; clone.idCardTags = idCardTags; clone.spawnType = spawnType; clone.assignedJob = assignedJob; @@ -570,6 +577,11 @@ namespace Barotrauma Enum.TryParse(element.GetAttributeString("spawn", "Path"), out w.spawnType); + string idCardDescString = element.GetAttributeString("idcarddesc", ""); + if (!string.IsNullOrWhiteSpace(idCardDescString)) + { + w.IdCardDesc = idCardDescString; + } string idCardTagString = element.GetAttributeString("idcardtags", ""); if (!string.IsNullOrWhiteSpace(idCardTagString)) { @@ -604,6 +616,7 @@ namespace Barotrauma new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)), new XAttribute("spawn", spawnType)); + if (!string.IsNullOrWhiteSpace(idCardDesc)) element.Add(new XAttribute("idcarddesc", idCardDesc)); if (idCardTags.Length > 0) { element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags))); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs index 6b7a2333f..e69dbf80f 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs @@ -105,18 +105,18 @@ namespace Barotrauma.Networking return ApplyDistanceEffect(listener, Sender, Text, SpeakRange); } - public static string ApplyDistanceEffect(Entity listener, Entity Sender, string text, float range) + public static string ApplyDistanceEffect(Entity listener, Entity Sender, string text, float range, float obstructionmult = 2.0f) { if (listener.WorldPosition == Sender.WorldPosition) return text; float dist = Vector2.Distance(listener.WorldPosition, Sender.WorldPosition); if (dist > range) return ""; - if (Submarine.CheckVisibility(listener.SimPosition, Sender.SimPosition) != null) dist *= 2.0f; + if (Submarine.CheckVisibility(listener.SimPosition, Sender.SimPosition) != null) dist = (dist + 100f) * obstructionmult; if (dist > range) return ""; float garbleAmount = dist / range; - if (garbleAmount < 0.5f) return text; + if (garbleAmount < 0.3f) return text; int startIndex = Math.Max(text.IndexOf(':') + 1, 1); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index cec645624..b40f789c1 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1848,7 +1848,7 @@ namespace Barotrauma.Networking case ChatMessageType.Default: if (!receiver.IsDead) { - return ChatMessage.ApplyDistanceEffect(receiver, sender, message, ChatMessage.SpeakRange); + return ChatMessage.ApplyDistanceEffect(receiver, sender, message, ChatMessage.SpeakRange, 3.0f); } break; case ChatMessageType.Radio: diff --git a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs index 44e8d777c..90cafee63 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/RespawnManager.cs @@ -533,7 +533,9 @@ namespace Barotrauma.Networking foreach (string s in shuttleSpawnPoints[i].IdCardTags) { item.AddTag(s); - } + } + if (!string.IsNullOrWhiteSpace(shuttleSpawnPoints[i].IdCardDesc)) + item.Description = shuttleSpawnPoints[i].IdCardDesc; } #if CLIENT GameMain.GameSession.CrewManager.AddCharacter(character); diff --git a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs index 4c54d48fd..3cfa569da 100644 --- a/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs +++ b/Barotrauma/BarotraumaShared/Source/Physics/PhysicsBody.cs @@ -16,22 +16,29 @@ namespace Barotrauma private set; } + public float Rotation + { + get; + private set; + } + public readonly float Timestamp; public readonly UInt16 ID; - public PosInfo(Vector2 pos, float time) - : this(pos, 0, time) + public PosInfo(Vector2 pos, float rotation, float time) + : this(pos, rotation, 0, time) { } - public PosInfo(Vector2 pos, UInt16 ID) - : this(pos, ID, 0.0f) + public PosInfo(Vector2 pos, float rotation, UInt16 ID) + : this(pos, rotation, ID, 0.0f) { } - protected PosInfo(Vector2 pos, UInt16 ID, float time) + protected PosInfo(Vector2 pos, float rotation, UInt16 ID, float time) { Position = pos; + Rotation = rotation; this.ID = ID; Timestamp = time; @@ -52,9 +59,9 @@ namespace Barotrauma } } - public void Translate(Vector2 amount) + public void Translate(Vector2 posAmount,float rotationAmount) { - Position += amount; + Position += posAmount; Rotation += rotationAmount; } }