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

This commit is contained in:
Regalis
2015-10-26 01:46:52 +02:00
parent aeeae13b35
commit ebe248a7cc
25 changed files with 142 additions and 88 deletions
+2 -2
View File
@@ -67,8 +67,8 @@
<Body width="90" height="30" density="10"/> <Body width="90" height="30" density="10"/>
<MeleeWeapon slots="Any,RightHand,LeftHand" <MeleeWeapon slots="Any,RightHand"
aimpos="50,0" handle1="-15,-6" holdangle="100" reload="1.0"> aimpos="50,0" handle1="-5,0" holdangle="10" reload="1.0">
<Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/> <Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg"> <StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/> <RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
@@ -518,8 +518,8 @@ namespace Barotrauma
if (wallAttack) if (wallAttack)
{ {
message.WriteRangedSingle(wallAttackPos.X, -50.0f, 50.0f, 10); message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10);
message.WriteRangedSingle(wallAttackPos.Y, -50.0f, 50.0f, 10); message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10);
} }
//message.Write(Velocity.X); //message.Write(Velocity.X);
+9 -9
View File
@@ -95,10 +95,10 @@ namespace Barotrauma
{ {
if (limb.ignoreCollisions) continue; 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.X, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); message.WriteRangedSingle(limb.body.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
message.Write(limb.body.Rotation); message.Write(limb.body.Rotation);
@@ -114,11 +114,11 @@ namespace Barotrauma
message.Write((float)NetTime.Now); message.Write((float)NetTime.Now);
message.Write(AnimController.TargetDir == Direction.Right); message.Write(AnimController.TargetDir == Direction.Right);
message.WriteRangedSingle(AnimController.TargetMovement.X, -1.0f, 1.0f, 8); message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -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(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.X, -NetConfig.AllowedRagdollDistance, NetConfig.AllowedRagdollDistance, 16); message.WriteRangedSingle(AnimController.RefLimb.SimPosition.Y, -NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
//message.Write(AnimController.RefLimb.LinearVelocity.X); //message.Write(AnimController.RefLimb.LinearVelocity.X);
//message.Write(AnimController.RefLimb.LinearVelocity.Y); //message.Write(AnimController.RefLimb.LinearVelocity.Y);
@@ -196,8 +196,8 @@ namespace Barotrauma
targetMovement.X = message.ReadRangedSingle(-1.0f, 1.0f, 8); targetMovement.X = message.ReadRangedSingle(-1.0f, 1.0f, 8);
targetMovement.Y = 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.X = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
pos.Y = message.ReadRangedSingle(-1.0f, 1.0f, 8); pos.Y = message.ReadRangedSingle(-NetConfig.CharacterIgnoreDistance, NetConfig.CharacterIgnoreDistance, 16);
//vel.X = message.ReadFloat(); //vel.X = message.ReadFloat();
//vel.Y = message.ReadFloat(); //vel.Y = message.ReadFloat();
+14 -4
View File
@@ -1081,6 +1081,11 @@ namespace Barotrauma
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 //otherwise don't kill the character unless received a message about the character dying
else if (!isNetworkMessage) else if (!isNetworkMessage)
{ {
@@ -1210,8 +1215,13 @@ namespace Barotrauma
{ {
Vector2 relativeCursorPosition = cursorPosition - Position; Vector2 relativeCursorPosition = cursorPosition - Position;
message.WriteRangedSingle(relativeCursorPosition.X, -2000.0f, 2000.0f, 8); if (relativeCursorPosition.Length()>4950.0f)
message.WriteRangedSingle(relativeCursorPosition.Y, -2000.0f, 2000.0f, 8); {
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 else
{ {
@@ -1397,8 +1407,8 @@ namespace Barotrauma
if (secondaryKeyState) if (secondaryKeyState)
{ {
relativeCursorPos = new Vector2( relativeCursorPos = new Vector2(
message.ReadRangedSingle(-2000.0f, 2000.0f, 8), message.ReadRangedSingle(-5000.0f, 5000.0f, 16),
message.ReadRangedSingle(-2000.0f, 2000.0f, 8)); message.ReadRangedSingle(-5000.0f, 5000.0f, 16));
} }
else else
{ {
@@ -832,16 +832,17 @@ namespace Barotrauma
if (itemPos == Vector2.Zero) 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) if (character.SelectedItems[1] == item)
{ {
transformedHoldPos = leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1]; transformedHoldPos = leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1];
itemAngle = (leftHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir); 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 else
{ {
+2
View File
@@ -279,6 +279,8 @@ namespace Barotrauma
{ {
limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f; limb.sprite.Depth = startDepth + limb.sprite.Depth * 0.0001f;
} }
FindLowestLimb();
} }
public bool OnLimbCollision(Fixture f1, Fixture f2, Contact contact) public bool OnLimbCollision(Fixture f1, Fixture f2, Contact contact)
@@ -68,6 +68,7 @@ namespace Barotrauma.Items.Components
{ {
item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody); 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.LeftFoot || l.type == LimbType.LeftThigh || l.type == LimbType.LeftLeg) continue;
if (l.type == LimbType.Head || l.type == LimbType.Torso) if (l.type == LimbType.Head || l.type == LimbType.Torso)
@@ -95,8 +95,10 @@ namespace Barotrauma.Items.Components
if (item.body!= null && !item.body.Enabled) if (item.body!= null && !item.body.Enabled)
{ {
Limb rightHand = picker.AnimController.GetLimb(LimbType.RightHand); Limb rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
item.SetTransform(rightHand.SimPosition, 0.0f); item.SetTransform(rightHand.SimPosition, 0.0f);
item.body.Enabled = true; item.body.Enabled = true;
} }
picker.Inventory.RemoveItem(item); picker.Inventory.RemoveItem(item);
picker = null; picker = null;
@@ -201,6 +201,8 @@ namespace Barotrauma.Items.Components
prevPos = pos; prevPos = pos;
} }
voltage = 0.0f;
} }
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius) private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius)
@@ -427,7 +427,7 @@ namespace Barotrauma.Items.Components
{ {
message.Write(autoTemp); message.Write(autoTemp);
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16); 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(coolingRate, 0.0f, 100.0f, 8);
message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8); message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8);
@@ -443,8 +443,8 @@ namespace Barotrauma.Items.Components
{ {
newAutoTemp = message.ReadBoolean(); newAutoTemp = message.ReadBoolean();
newTemperature = message.ReadRangedSingle(0.0f, 10000.0f, 16); newTemperature = message.ReadRangedSingle(0.0f, 10000.0f, 16);
newShutDownTemp = message.ReadRangedSingle(0.0f, 10000.0f, 7); newShutDownTemp = message.ReadRangedSingle(0.0f, 10000.0f, 8);
newShutDownTemp = MathUtils.Round(newShutDownTemp, 100.0f); newShutDownTemp = MathUtils.RoundTowardsClosest(newShutDownTemp, 100.0f);
newCoolingRate = message.ReadRangedSingle(0.0f, 100.0f, 8); newCoolingRate = message.ReadRangedSingle(0.0f, 100.0f, 8);
newFissionRate = message.ReadRangedSingle(0.0f, 100.0f, 8); newFissionRate = message.ReadRangedSingle(0.0f, 100.0f, 8);
@@ -104,6 +104,7 @@ namespace Barotrauma.Items.Components
} }
item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out"); item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out");
item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out"); item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out");
} }
@@ -281,6 +281,7 @@ namespace Barotrauma.Items.Components
if (!PlayerInput.LeftButtonDown()) if (!PlayerInput.LeftButtonDown())
{ {
panel.Item.NewComponentEvent(panel, true, true); panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(character);
draggingConnected = null; draggingConnected = null;
} }
} }
@@ -318,6 +319,8 @@ namespace Barotrauma.Items.Components
if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent)) if (index>-1 && wireComponent!=null && !Wires.Contains(wireComponent))
{ {
wireComponent.RemoveConnection(item);
Wires[index] = wireComponent; Wires[index] = wireComponent;
wireComponent.Connect(this); wireComponent.Connect(this);
} }
@@ -325,15 +328,15 @@ namespace Barotrauma.Items.Components
//far away -> disconnect if the wire is linked to this connector //far away -> disconnect if the wire is linked to this connector
else else
{ {
int index = FindWireIndex(draggingConnected); //int index = FindWireIndex(draggingConnected);
if (index>-1) //if (index>-1)
{ //{
Wires[index].RemoveConnection(this); // Wires[index].RemoveConnection(this);
//Wires[index].Item.SetTransform(item.SimPosition, 0.0f); // //Wires[index].Item.SetTransform(item.SimPosition, 0.0f);
//Wires[index].Item.Drop(); // //Wires[index].Item.Drop();
//Wires[index].Item.body.Enabled = true; // //Wires[index].Item.body.Enabled = true;
Wires[index] = null; // Wires[index] = null;
} //}
} }
} }
@@ -36,6 +36,10 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character) public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{ {
if (character != Character.Controlled || character != user) return; if (character != Character.Controlled || character != user) return;
if (character.GetInputState(InputType.Select) &&
character.SelectedConstruction==this.item) character.SelectedConstruction = null;
Connection.DrawConnections(spriteBatch, this, character); Connection.DrawConnections(spriteBatch, this, character);
} }
@@ -57,6 +57,20 @@ namespace Barotrauma.Items.Components
return null; 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) public void RemoveConnection(Connection connection)
{ {
if (connection == connections[0]) connections[0] = null; if (connection == connections[0]) connections[0] = 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) public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
{ {
message.Write((byte)Math.Min(Nodes.Count, 10)); message.Write((byte)Math.Min(Nodes.Count, 10));
+5 -4
View File
@@ -130,12 +130,13 @@ namespace Barotrauma.Items.Components
Projectile projectileComponent = null; Projectile projectileComponent = null;
//search for a projectile from linked containers //search for a projectile from linked containers
Item projectile = null; Item projectile = null;
Item projectileContainer = null;
foreach (MapEntity e in item.linkedTo) foreach (MapEntity e in item.linkedTo)
{ {
Item container = e as Item; projectileContainer = e as Item;
if (container == null) continue; if (projectileContainer == null) continue;
ItemContainer containerComponent = container.GetComponent<ItemContainer>(); ItemContainer containerComponent = projectileContainer.GetComponent<ItemContainer>();
if (containerComponent == null) continue; if (containerComponent == null) continue;
for (int i = 0; i < containerComponent.inventory.items.Length; i++) 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); projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y)), -rotation);
projectileComponent.Use(deltaTime); projectileComponent.Use(deltaTime);
item.RemoveContained(projectile); projectileContainer.RemoveContained(projectile);
return true; return true;
} }
+2 -1
View File
@@ -179,7 +179,7 @@ namespace Barotrauma
UpdateSlot(spriteBatch, slotRect, i, items[i], false); 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) if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed)
{ {
@@ -198,6 +198,7 @@ namespace Barotrauma
} }
DropItem(draggingItem); DropItem(draggingItem);
//draggingItem = null;
} }
} }
} }
+15 -3
View File
@@ -333,7 +333,19 @@ namespace Barotrauma
public void SetTransform(Vector2 simPosition, float rotation) 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); Vector2 displayPos = ConvertUnits.ToDisplayUnits(simPosition);
@@ -803,7 +815,7 @@ namespace Barotrauma
foreach (Item item in itemList) foreach (Item item in itemList)
{ {
if (ignoredItems!=null && ignoredItems.Contains(item)) continue; if (ignoredItems!=null && ignoredItems.Contains(item)) continue;
if (hull != item.CurrentHull && (hull==null || (item.Rect.Height<hull.Rect.Height && item.rect.Width < hull.Rect.Width))) continue; //if (hull != item.CurrentHull && (hull==null || (item.Rect.Height<hull.Rect.Height && item.rect.Width < hull.Rect.Width))) continue;
if (item.body != null && !item.body.Enabled) continue; if (item.body != null && !item.body.Enabled) continue;
Pickable pickableComponent = item.GetComponent<Pickable>(); Pickable pickableComponent = item.GetComponent<Pickable>();
@@ -813,7 +825,7 @@ namespace Barotrauma
{ {
Rectangle transformedTrigger = item.TransformTrigger(trigger); Rectangle transformedTrigger = item.TransformTrigger(trigger);
if (!Submarine.RectContains(transformedTrigger, displayPos))continue; if (!Submarine.RectContains(transformedTrigger, displayPos)) continue;
Vector2 triggerCenter = Vector2 triggerCenter =
new Vector2( new Vector2(
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Barotrauma
{ {
item.Drop(); item.Drop();
item.body.Enabled = true; 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) public override int FindAllowedSlot(Item item)
+1
View File
@@ -484,6 +484,7 @@ namespace Barotrauma
try try
{ {
float newPercentage = message.ReadRangedSingle(0.0f, 1.5f, 6); float newPercentage = message.ReadRangedSingle(0.0f, 1.5f, 6);
newVolume = newPercentage * FullVolume;
} }
catch catch
+20 -36
View File
@@ -23,8 +23,6 @@ namespace Barotrauma
public float lastSentDamage; public float lastSentDamage;
public float lastUpdate;
public bool isHighLighted; public bool isHighLighted;
public WallSection(Rectangle rect) public WallSection(Rectangle rect)
@@ -57,6 +55,8 @@ namespace Barotrauma
bool isHorizontal; bool isHorizontal;
public float lastUpdate;
public override Sprite Sprite public override Sprite Sprite
{ {
get { return prefab.sprite; } get { return prefab.sprite; }
@@ -451,8 +451,8 @@ namespace Barotrauma
if (damage != sections[sectionIndex].damage && Math.Abs(sections[sectionIndex].lastSentDamage - damage)>5.0f) if (damage != sections[sectionIndex].damage && Math.Abs(sections[sectionIndex].lastSentDamage - damage)>5.0f)
{ {
new NetworkEvent(NetworkEventType.WallDamage, ID, false, sectionIndex); new NetworkEvent(NetworkEventType.WallDamage, ID, false);
sections[sectionIndex].lastSentDamage = damage; //sections[sectionIndex].lastSentDamage = damage;
} }
if (damage < prefab.MaxHealth*0.5f) if (damage < prefab.MaxHealth*0.5f)
@@ -638,48 +638,32 @@ namespace Barotrauma
public override bool FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data) 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((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; return true;
} }
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message) public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
{ {
int sectionIndex = 0; float updateTime = message.ReadFloat();
float damage = 0.0f; if (updateTime < lastUpdate) return;
float updateTime = 0.0f;
try while (message.Position <= message.LengthBits-8)
{ {
updateTime = message.ReadFloat(); byte sectionIndex = message.ReadByte();
sectionIndex = message.ReadByte(); float damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health;
damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health;
SetDamage(sectionIndex, damage);
} }
catch
{
return;
}
if (sections[sectionIndex].lastUpdate != 0.0f && updateTime < sections[sectionIndex].lastUpdate) return;
sections[sectionIndex].lastUpdate = updateTime;
SetDamage(sectionIndex, damage);
} }
} }
+2
View File
@@ -95,6 +95,8 @@ namespace Barotrauma
"Oops! Subsurface just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error); "Oops! Subsurface just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif #endif
Sounds.SoundManager.Dispose();
} }
} }
@@ -309,6 +309,7 @@ namespace Barotrauma
if (dummyCharacter.SelectedConstruction == dummyCharacter.ClosestItem) if (dummyCharacter.SelectedConstruction == dummyCharacter.ClosestItem)
{ {
dummyCharacter.SelectedConstruction.DrawHUD(spriteBatch, dummyCharacter); dummyCharacter.SelectedConstruction.DrawHUD(spriteBatch, dummyCharacter);
} }
else else
{ {
@@ -330,6 +331,8 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, cam); GUI.Draw((float)deltaTime, spriteBatch, cam);
if (!PlayerInput.LeftButtonDown()) Inventory.draggingItem = null;
spriteBatch.End(); spriteBatch.End();
} }
+2 -4
View File
@@ -81,9 +81,7 @@ namespace Barotrauma
GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f); GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f);
} }
#endif #endif
dustOffset -= Vector2.UnitY * 10.0f * (float)deltaTime;
//dustOffset -= Vector2.UnitY * 100.0f * (float)deltaTime;
if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime); if (GameMain.GameSession!=null) GameMain.GameSession.Update((float)deltaTime);
//EventManager.Update(gameTime); //EventManager.Update(gameTime);
@@ -208,7 +206,7 @@ namespace Barotrauma
BackgroundSpriteManager.Draw(spriteBatch); 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; if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
Rectangle viewRect = cam.WorldView; Rectangle viewRect = cam.WorldView;
+5
View File
@@ -22,6 +22,11 @@ namespace Barotrauma
(float)Math.Floor(value / div) * div; (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) public static float VectorToAngle(Vector2 vector)
{ {
return (float)Math.Atan2(vector.Y, vector.X); return (float)Math.Atan2(vector.Y, vector.X);
Binary file not shown.