From ebe248a7cc0eda50f330aa35d19538920f0ed429 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 26 Oct 2015 01:46:52 +0200 Subject: [PATCH] Ragdoll raycast crash, holding items in correct angles, ghost wires, dropping items properly in editmapscreen, radar wont work without power, remove wire from connectors if its deleted --- Subsurface/Content/Items/Weapons/weapons.xml | 4 +- .../Source/Characters/AI/EnemyAIController.cs | 4 +- Subsurface/Source/Characters/AICharacter.cs | 18 +++--- Subsurface/Source/Characters/Character.cs | 22 +++++-- .../Characters/HumanoidAnimController.cs | 11 ++-- Subsurface/Source/Characters/Ragdoll.cs | 2 + .../Items/Components/Holdable/MeleeWeapon.cs | 1 + .../Items/Components/Holdable/Pickable.cs | 2 + .../Source/Items/Components/Machines/Radar.cs | 4 +- .../Items/Components/Machines/Reactor.cs | 6 +- .../Items/Components/Machines/Steering.cs | 3 +- .../Items/Components/Signal/Connection.cs | 21 ++++--- .../Components/Signal/ConnectionPanel.cs | 4 ++ .../Source/Items/Components/Signal/Wire.cs | 23 ++++++- Subsurface/Source/Items/Components/Turret.cs | 9 +-- Subsurface/Source/Items/Inventory.cs | 3 +- Subsurface/Source/Items/Item.cs | 18 +++++- Subsurface/Source/Items/ItemInventory.cs | 2 +- Subsurface/Source/Map/Hull.cs | 1 + Subsurface/Source/Map/Structure.cs | 56 +++++++----------- Subsurface/Source/Program.cs | 2 + Subsurface/Source/Screens/EditMapScreen.cs | 3 + Subsurface/Source/Screens/GameScreen.cs | 6 +- Subsurface/Source/Utils/MathUtils.cs | 5 ++ Subsurface_Solution.v12.suo | Bin 811008 -> 811008 bytes 25 files changed, 142 insertions(+), 88 deletions(-) diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml index 486ba31d5..b4a5ff050 100644 --- a/Subsurface/Content/Items/Weapons/weapons.xml +++ b/Subsurface/Content/Items/Weapons/weapons.xml @@ -67,8 +67,8 @@ - + diff --git a/Subsurface/Source/Characters/AI/EnemyAIController.cs b/Subsurface/Source/Characters/AI/EnemyAIController.cs index 58b4242eb..e1b237122 100644 --- a/Subsurface/Source/Characters/AI/EnemyAIController.cs +++ b/Subsurface/Source/Characters/AI/EnemyAIController.cs @@ -518,8 +518,8 @@ namespace Barotrauma if (wallAttack) { - message.WriteRangedSingle(wallAttackPos.X, -50.0f, 50.0f, 10); - message.WriteRangedSingle(wallAttackPos.Y, -50.0f, 50.0f, 10); + message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10); + message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10); } //message.Write(Velocity.X); diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 57f0d9e38..2f265fe20 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -95,10 +95,10 @@ namespace Barotrauma { if (limb.ignoreCollisions) continue; - if (limb.SimPosition.Length() > NetConfig.AllowedRagdollDistance) return false; + if (limb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false; - message.WriteRangedSingle(limb.body.SimPosition.X, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); - message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); + message.WriteRangedSingle(limb.body.SimPosition.X, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); + message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); message.Write(limb.body.Rotation); @@ -114,11 +114,11 @@ namespace Barotrauma message.Write((float)NetTime.Now); message.Write(AnimController.TargetDir == Direction.Right); - message.WriteRangedSingle(AnimController.TargetMovement.X, -1.0f, 1.0f, 8); - message.WriteRangedSingle(AnimController.TargetMovement.Y, -1.0f, 1.0f, 8); + message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8); + message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8); - message.WriteRangedSingle(AnimController.RefLimb.SimPosition.X, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); - message.WriteRangedSingle(AnimController.RefLimb.SimPosition.X, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); + message.WriteRangedSingle(AnimController.RefLimb.SimPosition.X, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); + message.WriteRangedSingle(AnimController.RefLimb.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); //message.Write(AnimController.RefLimb.LinearVelocity.X); //message.Write(AnimController.RefLimb.LinearVelocity.Y); @@ -196,8 +196,8 @@ namespace Barotrauma targetMovement.X = message.ReadRangedSingle(-1.0f, 1.0f, 8); targetMovement.Y = message.ReadRangedSingle(-1.0f, 1.0f, 8); - pos.X = message.ReadRangedSingle(-1.0f, 1.0f, 8); - pos.Y = message.ReadRangedSingle(-1.0f, 1.0f, 8); + pos.X = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); + pos.Y = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16); //vel.X = message.ReadFloat(); //vel.Y = message.ReadFloat(); diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 654d8610c..43d157e00 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1077,9 +1077,14 @@ namespace Barotrauma if (GameMain.Client!=null) chatMessage += " Your chat messages will only be visible to other dead players."; GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead); - GameMain.LightManager.LosEnabled = false; + GameMain.LightManager.LosEnabled = false; - new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); + new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); + } + //if it's an ai character, only let the server kill it + else if (GameMain.Server != null && this is AICharacter) + { + new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath); } //otherwise don't kill the character unless received a message about the character dying else if (!isNetworkMessage) @@ -1210,8 +1215,13 @@ namespace Barotrauma { Vector2 relativeCursorPosition = cursorPosition - Position; - message.WriteRangedSingle(relativeCursorPosition.X, -2000.0f, 2000.0f, 8); - message.WriteRangedSingle(relativeCursorPosition.Y, -2000.0f, 2000.0f, 8); + if (relativeCursorPosition.Length()>4950.0f) + { + relativeCursorPosition = Vector2.Normalize(relativeCursorPosition) * 4950.0f; + } + + message.WriteRangedSingle(relativeCursorPosition.X, -5000.0f, 5000.0f, 16); + message.WriteRangedSingle(relativeCursorPosition.Y, -5000.0f, 5000.0f, 16); } else { @@ -1397,8 +1407,8 @@ namespace Barotrauma if (secondaryKeyState) { relativeCursorPos = new Vector2( - message.ReadRangedSingle(-2000.0f, 2000.0f, 8), - message.ReadRangedSingle(-2000.0f, 2000.0f, 8)); + message.ReadRangedSingle(-5000.0f, 5000.0f, 16), + message.ReadRangedSingle(-5000.0f, 5000.0f, 16)); } else { diff --git a/Subsurface/Source/Characters/HumanoidAnimController.cs b/Subsurface/Source/Characters/HumanoidAnimController.cs index 66055a29d..e77cb263d 100644 --- a/Subsurface/Source/Characters/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/HumanoidAnimController.cs @@ -832,16 +832,17 @@ namespace Barotrauma if (itemPos == Vector2.Zero) { - if (character.SelectedItems[0] == item) - { - transformedHoldPos = rightHand.pullJoint.WorldAnchorA - transformedHandlePos[0]; - itemAngle = (rightHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir); - } + if (character.SelectedItems[1] == item) { transformedHoldPos = leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1]; itemAngle = (leftHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir); } + if (character.SelectedItems[0] == item) + { + transformedHoldPos = rightHand.pullJoint.WorldAnchorA - transformedHandlePos[0]; + itemAngle = (rightHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir); + } } else { diff --git a/Subsurface/Source/Characters/Ragdoll.cs b/Subsurface/Source/Characters/Ragdoll.cs index fe01e2bd4..9f8835052 100644 --- a/Subsurface/Source/Characters/Ragdoll.cs +++ b/Subsurface/Source/Characters/Ragdoll.cs @@ -279,6 +279,8 @@ namespace Barotrauma { limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f; } + + FindLowestLimb(); } public bool OnLimbCollision(Fixture f1, Fixture f2, Contact contact) diff --git a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs index 7fe6922b1..4d902b2f5 100644 --- a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs +++ b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs @@ -68,6 +68,7 @@ namespace Barotrauma.Items.Components { item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody); + if (character.AnimController.InWater) continue; if (l.type == LimbType.LeftFoot || l.type == LimbType.LeftThigh || l.type == LimbType.LeftLeg) continue; if (l.type == LimbType.Head || l.type == LimbType.Torso) diff --git a/Subsurface/Source/Items/Components/Holdable/Pickable.cs b/Subsurface/Source/Items/Components/Holdable/Pickable.cs index 260887a64..6b383140f 100644 --- a/Subsurface/Source/Items/Components/Holdable/Pickable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Pickable.cs @@ -95,8 +95,10 @@ namespace Barotrauma.Items.Components if (item.body!= null && !item.body.Enabled) { Limb rightHand = picker.AnimController.GetLimb(LimbType.RightHand); + item.SetTransform(rightHand.SimPosition, 0.0f); item.body.Enabled = true; + } picker.Inventory.RemoveItem(item); picker = null; diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index 7940096da..9560934b9 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -59,7 +59,7 @@ namespace Barotrauma.Items.Components else { pingState = 0.0f; - } + } } public override bool Use(float deltaTime, Character character = null) @@ -201,6 +201,8 @@ namespace Barotrauma.Items.Components prevPos = pos; } + + voltage = 0.0f; } private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius) diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs index 5bc195f42..8e2754a90 100644 --- a/Subsurface/Source/Items/Components/Machines/Reactor.cs +++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs @@ -427,7 +427,7 @@ namespace Barotrauma.Items.Components { message.Write(autoTemp); message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16); - message.WriteRangedSingle(shutDownTemp, 0.0f, 10000.0f, 7); + message.WriteRangedSingle(shutDownTemp, 0.0f, 10000.0f, 8); message.WriteRangedSingle(coolingRate, 0.0f, 100.0f, 8); message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8); @@ -443,8 +443,8 @@ namespace Barotrauma.Items.Components { newAutoTemp = message.ReadBoolean(); newTemperature = message.ReadRangedSingle(0.0f, 10000.0f, 16); - newShutDownTemp = message.ReadRangedSingle(0.0f, 10000.0f, 7); - newShutDownTemp = MathUtils.Round(newShutDownTemp, 100.0f); + newShutDownTemp = message.ReadRangedSingle(0.0f, 10000.0f, 8); + newShutDownTemp = MathUtils.RoundTowardsClosest(newShutDownTemp, 100.0f); newCoolingRate = message.ReadRangedSingle(0.0f, 100.0f, 8); newFissionRate = message.ReadRangedSingle(0.0f, 100.0f, 8); diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index 2fb7040e4..38ae89fa9 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -27,7 +27,7 @@ namespace Barotrauma.Items.Components private bool valueChanged; private float autopilotRayCastTimer; - + bool AutoPilot { get { return autoPilot; } @@ -104,6 +104,7 @@ namespace Barotrauma.Items.Components } item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out"); + item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out"); } diff --git a/Subsurface/Source/Items/Components/Signal/Connection.cs b/Subsurface/Source/Items/Components/Signal/Connection.cs index 2d5b64e96..685197230 100644 --- a/Subsurface/Source/Items/Components/Signal/Connection.cs +++ b/Subsurface/Source/Items/Components/Signal/Connection.cs @@ -281,6 +281,7 @@ namespace Barotrauma.Items.Components if (!PlayerInput.LeftButtonDown()) { panel.Item.NewComponentEvent(panel, true, true); + //draggingConnected.Drop(character); draggingConnected = null; } } @@ -318,6 +319,8 @@ namespace Barotrauma.Items.Components if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent)) { + wireComponent.RemoveConnection(item); + Wires[index] = wireComponent; wireComponent.Connect(this); } @@ -325,15 +328,15 @@ namespace Barotrauma.Items.Components //far away -> disconnect if the wire is linked to this connector else { - int index = FindWireIndex(draggingConnected); - if (index>-1) - { - Wires[index].RemoveConnection(this); - //Wires[index].Item.SetTransform(item.SimPosition, 0.0f); - //Wires[index].Item.Drop(); - //Wires[index].Item.body.Enabled = true; - Wires[index] = null; - } + //int index = FindWireIndex(draggingConnected); + //if (index>-1) + //{ + // Wires[index].RemoveConnection(this); + // //Wires[index].Item.SetTransform(item.SimPosition, 0.0f); + // //Wires[index].Item.Drop(); + // //Wires[index].Item.body.Enabled = true; + // Wires[index] = null; + //} } } diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index 2f4ff91f2..838eb95e3 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -36,6 +36,10 @@ namespace Barotrauma.Items.Components public override void DrawHUD(SpriteBatch spriteBatch, Character character) { if (character != Character.Controlled || character != user) return; + + if (character.GetInputState(InputType.Select) && + character.SelectedConstruction==this.item) character.SelectedConstruction = null; + Connection.DrawConnections(spriteBatch, this, character); } diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index ca42763e1..f312e35b8 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -57,9 +57,23 @@ namespace Barotrauma.Items.Components return null; } + public void RemoveConnection(Item item) + { + for (int i = 0; i<2; i++) + { + if (connections[i]==null || connections[i].Item!=item) continue; + + for (int n = 0; n< connections[i].Wires.Length; n++) + { + if (connections[i].Wires[n] == this) connections[i].Wires[n] = null; + } + connections[i] = null; + } + } + public void RemoveConnection(Connection connection) { - if (connection == connections[0]) connections[0] = null; + if (connection == connections[0]) connections[0] = null; if (connection == connections[1]) connections[1] = null; } @@ -407,6 +421,13 @@ namespace Barotrauma.Items.Components } + public override void Remove() + { + ClearConnections(); + + base.Remove(); + } + public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message) { message.Write((byte)Math.Min(Nodes.Count, 10)); diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs index 62a2ce1f3..ff617ef98 100644 --- a/Subsurface/Source/Items/Components/Turret.cs +++ b/Subsurface/Source/Items/Components/Turret.cs @@ -130,12 +130,13 @@ namespace Barotrauma.Items.Components Projectile projectileComponent = null; //search for a projectile from linked containers Item projectile = null; + Item projectileContainer = null; foreach (MapEntity e in item.linkedTo) { - Item container = e as Item; - if (container == null) continue; + projectileContainer = e as Item; + if (projectileContainer == null) continue; - ItemContainer containerComponent = container.GetComponent(); + ItemContainer containerComponent = projectileContainer.GetComponent(); if (containerComponent == null) continue; for (int i = 0; i < containerComponent.inventory.items.Length; i++) @@ -182,7 +183,7 @@ namespace Barotrauma.Items.Components projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y)), -rotation); projectileComponent.Use(deltaTime); - item.RemoveContained(projectile); + projectileContainer.RemoveContained(projectile); return true; } diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index 4b89da197..382400e62 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -179,7 +179,7 @@ namespace Barotrauma UpdateSlot(spriteBatch, slotRect, i, items[i], false); } - if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition)) + if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.container == this.Owner) { if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) { @@ -198,6 +198,7 @@ namespace Barotrauma } DropItem(draggingItem); + //draggingItem = null; } } } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 037c7224e..d9696d903 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -333,7 +333,19 @@ namespace Barotrauma public void SetTransform(Vector2 simPosition, float rotation) { - if (body != null) body.SetTransform(simPosition, rotation); + if (body != null) + { + try + { + body.SetTransform(simPosition, rotation); + } + catch (Exception e) + { +#if DEBUG + DebugConsole.ThrowError("Failed to set item transform", e); +#endif + } + } Vector2 displayPos = ConvertUnits.ToDisplayUnits(simPosition); @@ -803,7 +815,7 @@ namespace Barotrauma foreach (Item item in itemList) { if (ignoredItems!=null && ignoredItems.Contains(item)) continue; - if (hull != item.CurrentHull && (hull==null || (item.Rect.Height(); @@ -813,7 +825,7 @@ namespace Barotrauma { Rectangle transformedTrigger = item.TransformTrigger(trigger); - if (!Submarine.RectContains(transformedTrigger, displayPos))continue; + if (!Submarine.RectContains(transformedTrigger, displayPos)) continue; Vector2 triggerCenter = new Vector2( diff --git a/Subsurface/Source/Items/ItemInventory.cs b/Subsurface/Source/Items/ItemInventory.cs index c15ba1478..3acbf3209 100644 --- a/Subsurface/Source/Items/ItemInventory.cs +++ b/Subsurface/Source/Items/ItemInventory.cs @@ -17,7 +17,7 @@ namespace Barotrauma { item.Drop(); item.body.Enabled = true; - item.body.SetTransform(container.Item.SimPosition, 0.0f); + item.SetTransform(container.Item.SimPosition, 0.0f); } public override int FindAllowedSlot(Item item) diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 5f586dbbd..f77300f5d 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -484,6 +484,7 @@ namespace Barotrauma try { float newPercentage = message.ReadRangedSingle(0.0f, 1.5f, 6); + newVolume = newPercentage * FullVolume; } catch diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index e0c2a21a7..3e73a182f 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -23,8 +23,6 @@ namespace Barotrauma public float lastSentDamage; - public float lastUpdate; - public bool isHighLighted; public WallSection(Rectangle rect) @@ -56,6 +54,8 @@ namespace Barotrauma private WallSection[] sections; bool isHorizontal; + + public float lastUpdate; public override Sprite Sprite { @@ -451,8 +451,8 @@ namespace Barotrauma if (damage != sections[sectionIndex].damage && Math.Abs(sections[sectionIndex].lastSentDamage - damage)>5.0f) { - new NetworkEvent(NetworkEventType.WallDamage, ID, false, sectionIndex); - sections[sectionIndex].lastSentDamage = damage; + new NetworkEvent(NetworkEventType.WallDamage, ID, false); + //sections[sectionIndex].lastSentDamage = damage; } if (damage < prefab.MaxHealth*0.5f) @@ -638,48 +638,32 @@ namespace Barotrauma public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data) { - int sectionIndex = 0; - byte byteIndex = 0; - - try - { - sectionIndex = (int)data; - byteIndex = (byte)sectionIndex; - } - catch - { - return false; - } - message.Write((float)NetTime.Now); - message.Write(byteIndex); - message.WriteRangedSingle(sections[sectionIndex].damage/Health, 0.0f, 1.0f, 8); + + for (int i = 0; i < sections.Length; i++) + { + if (Math.Abs(sections[i].damage - sections[i].lastSentDamage) < 0.1f) continue; + message.Write((byte)i); + message.WriteRangedSingle(sections[i].damage / Health, 0.0f, 1.0f, 8); + + sections[i].lastSentDamage = sections[i].damage; + } return true; } public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message) { - int sectionIndex = 0; - float damage = 0.0f; - float updateTime = 0.0f; + float updateTime = message.ReadFloat(); + if (updateTime < lastUpdate) return; - try + while (message.Position <= message.LengthBits-8) { - updateTime = message.ReadFloat(); - sectionIndex = message.ReadByte(); - damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health; - } - catch - { - return; - } + byte sectionIndex = message.ReadByte(); + float damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health; - if (sections[sectionIndex].lastUpdate != 0.0f && updateTime < sections[sectionIndex].lastUpdate) return; - - sections[sectionIndex].lastUpdate = updateTime; - SetDamage(sectionIndex, damage); - + SetDamage(sectionIndex, damage); + } } } diff --git a/Subsurface/Source/Program.cs b/Subsurface/Source/Program.cs index f70f20a8b..dd2d14c37 100644 --- a/Subsurface/Source/Program.cs +++ b/Subsurface/Source/Program.cs @@ -95,6 +95,8 @@ namespace Barotrauma "Oops! Subsurface just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error); #endif + Sounds.SoundManager.Dispose(); + } } diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index 5a4c68f78..335fed863 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -309,6 +309,7 @@ namespace Barotrauma if (dummyCharacter.SelectedConstruction == dummyCharacter.ClosestItem) { dummyCharacter.SelectedConstruction.DrawHUD(spriteBatch, dummyCharacter); + } else { @@ -329,6 +330,8 @@ namespace Barotrauma } GUI.Draw((float)deltaTime, spriteBatch, cam); + + if (!PlayerInput.LeftButtonDown()) Inventory.draggingItem = null; spriteBatch.End(); diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 20a499de7..102f35380 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -81,9 +81,7 @@ namespace Barotrauma GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f); } #endif - - - //dustOffset -= Vector2.UnitY * 100.0f * (float)deltaTime; + dustOffset -= Vector2.UnitY * 10.0f * (float)deltaTime; if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime); //EventManager.Update(gameTime); @@ -208,7 +206,7 @@ namespace Barotrauma BackgroundSpriteManager.Draw(spriteBatch); - backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y); + backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y) + dustOffset; if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; Rectangle viewRect = cam.WorldView; diff --git a/Subsurface/Source/Utils/MathUtils.cs b/Subsurface/Source/Utils/MathUtils.cs index 9c355344f..645e46eb2 100644 --- a/Subsurface/Source/Utils/MathUtils.cs +++ b/Subsurface/Source/Utils/MathUtils.cs @@ -22,6 +22,11 @@ namespace Barotrauma (float)Math.Floor(value / div) * div; } + public static float RoundTowardsClosest(float value, float div) + { + return (float)Math.Round(value / div) * div; + } + public static float VectorToAngle(Vector2 vector) { return (float)Math.Atan2(vector.Y, vector.X); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 7d29b38485b79d0ff6344788ffcf895f349d128c..37dfb929e65e716ddc62f627cbbe901a05ea7101 100644 GIT binary patch delta 5721 zcmchb3tUxI_Q&tq`&{k=gbQ3AA;JYOh@vE-_{hfv(|jeAuO!5GikhJj6_Q;1j|7GU zoat`!V~U_xEgulcAvFhdeB~p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