diff --git a/Subsurface/Content/Items/Diving/DivingSuit.png b/Subsurface/Content/Items/Diving/DivingSuit.png index 0967e3fb1..ece1b6d2a 100644 Binary files a/Subsurface/Content/Items/Diving/DivingSuit.png and b/Subsurface/Content/Items/Diving/DivingSuit.png differ diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index de9b788c9..27a88df32 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -42,22 +42,27 @@ pickdistance="200" price="200"> - + - - + - - + + - - + + + + + + + + - + diff --git a/Subsurface/Content/Items/Door/door.png b/Subsurface/Content/Items/Door/door.png index 8a69d05d7..8eda30353 100644 Binary files a/Subsurface/Content/Items/Door/door.png and b/Subsurface/Content/Items/Door/door.png differ diff --git a/Subsurface/Content/Items/Door/doors.xml b/Subsurface/Content/Items/Door/doors.xml index 9bd4eeb16..61842dd34 100644 --- a/Subsurface/Content/Items/Door/doors.xml +++ b/Subsurface/Content/Items/Door/doors.xml @@ -4,10 +4,11 @@ linkable="true" pickdistance="150.0"> - + - + + @@ -26,10 +27,11 @@ linkable="true" pickdistance="150.0"> - + + diff --git a/Subsurface/Content/Items/idcard.xml b/Subsurface/Content/Items/idcard.xml index 8e75e69f1..d768e840f 100644 --- a/Subsurface/Content/Items/idcard.xml +++ b/Subsurface/Content/Items/idcard.xml @@ -5,7 +5,7 @@ Tags="smallitem" pickdistance="150"> - + diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 6fa63f03c..a498b37f1 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -134,10 +134,12 @@ namespace Subsurface get { return selectedCharacter; } } - //public AITarget AiTarget - //{ - // get { return aiTarget; } - //} + private float lowPassMultiplier; + public float LowPassMultiplier + { + get { return lowPassMultiplier; } + set { lowPassMultiplier = MathHelper.Clamp(value, 0.0f, 1.0f); } + } public float SoundRange { @@ -195,6 +197,12 @@ namespace Subsurface bleeding = Math.Max(value, 0.0f); } } + + public float SpeedMultiplier + { + get; + set; + } public Item[] SelectedItems { @@ -296,7 +304,6 @@ namespace Subsurface public Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false) { - keys = new Key[Enum.GetNames(typeof(InputType)).Length]; keys[(int)InputType.Select] = new Key(false); keys[(int)InputType.ActionHeld] = new Key(true); @@ -319,6 +326,8 @@ namespace Subsurface //blood = 100.0f; aiTarget = new AITarget(this); + lowPassMultiplier = 1.0f; + Properties = ObjectProperty.GetProperties(this); Info = characterInfo==null ? new CharacterInfo(file) : characterInfo; @@ -499,6 +508,9 @@ namespace Subsurface if (Math.Sign(targetMovement.X) == Math.Sign(AnimController.Dir) && GetInputState(InputType.Run)) targetMovement *= 3.0f; + targetMovement *= SpeedMultiplier; + SpeedMultiplier = 1.0f; + AnimController.TargetMovement = targetMovement; AnimController.IsStanding = true; @@ -740,6 +752,8 @@ namespace Subsurface UpdateSightRange(); aiTarget.SoundRange = 0.0f; + lowPassMultiplier = MathHelper.Lerp(lowPassMultiplier, 1.0f, 0.1f); + if (needsAir) { if (AnimController.HeadInWater) diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index 243105f59..741f0b130 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -414,11 +414,22 @@ namespace Subsurface Vector2 origin = wearingItemSprite.Sprite.Origin; if (body.Dir == -1.0f) origin.X = wearingItemSprite.Sprite.SourceRect.Width - origin.X; + float depth = sprite.Depth - 0.000001f; + + if (wearingItemSprite.DepthLimb==LimbType.None) + { + Limb depthLimb = character.AnimController.GetLimb(wearingItemSprite.DepthLimb); + if (depthLimb!=null) + { + depth = depthLimb.sprite.Depth - 0.000001f; + } + } + wearingItemSprite.Sprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), color, origin, -body.DrawRotation, - 1.0f, spriteEffect, sprite.Depth - 0.000001f); + 1.0f, spriteEffect, depth); } if (!GameMain.DebugDraw) return; diff --git a/Subsurface/Source/Characters/StatusEffect.cs b/Subsurface/Source/Characters/StatusEffect.cs index 2ce45779e..8854ba914 100644 --- a/Subsurface/Source/Characters/StatusEffect.cs +++ b/Subsurface/Source/Characters/StatusEffect.cs @@ -21,6 +21,8 @@ namespace Subsurface public string[] propertyNames; private object[] propertyEffects; + private bool setValue; + private bool disableDeltaTime; private string[] onContainingNames; @@ -63,7 +65,6 @@ namespace Subsurface IEnumerable attributes = element.Attributes(); List propertyAttributes = new List(); - disableDeltaTime = ToolBox.GetAttributeBool(element, "disabledeltatime", false); foreach (XAttribute attribute in attributes) { @@ -96,6 +97,12 @@ namespace Subsurface targetTypes |= (TargetType)Enum.Parse(typeof(TargetType), s, true); } + break; + case "disabledeltatime": + disableDeltaTime = ToolBox.GetAttributeBool(attribute, false); + break; + case "setvalue": + setValue = ToolBox.GetAttributeBool(attribute, false); break; case "targetnames": string[] names = attribute.Value.Split(','); @@ -220,11 +227,15 @@ namespace Subsurface Type type = value.GetType(); if (type == typeof(float)) { - property.TrySetValue((float)property.GetValue() + (float)value * deltaTime); + float floatValue = (float)value * deltaTime; + if (!setValue) floatValue += (float)property.GetValue(); + property.TrySetValue(floatValue); } else if (type == typeof(int)) { - property.TrySetValue((int)property.GetValue() + (int)value * deltaTime); + int intValue = (int)((int)value * deltaTime); + if (!setValue) intValue += (int)property.GetValue(); + property.TrySetValue(intValue); } else if (type == typeof(bool)) { diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index a6eed6412..f6680e106 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -98,7 +98,7 @@ namespace Subsurface.Items.Components PhysicsBody body; - Sprite doorSprite; + Sprite doorSprite, weldedSprite; public Door(Item item, XElement element) : base(item, element) @@ -108,9 +108,15 @@ namespace Subsurface.Items.Components // isOpen = false; foreach (XElement subElement in element.Elements()) { - if (subElement.Name.ToString().ToLower() != "sprite") continue; - doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile)); - break; + switch (subElement.Name.ToString().ToLower()) + { + case "sprite": + doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile)); + break; + case "weldedsprite": + weldedSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile)); + break; + } } doorRect = new Rectangle( @@ -258,6 +264,11 @@ namespace Subsurface.Items.Components //prefab.sprite.Draw(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color); + if (stuck>0.0f && weldedSprite!=null) + { + weldedSprite.Draw(spriteBatch, new Vector2(item.Rect.X, -item.Rect.Y), Color.White*(stuck/100.0f), 0.0f, 1.0f); + } + if (openState == 1.0f) { body.Enabled = false; @@ -311,6 +322,8 @@ namespace Subsurface.Items.Components public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f) { + if (isStuck) return; + if (connection.Name=="toggle") { isOpen = !isOpen; @@ -318,7 +331,10 @@ namespace Subsurface.Items.Components else if (connection.Name == "set_state") { isOpen = (signal!="0"); - } + } + + //opening a partially stuck door makes it less stuck + if (isOpen) stuck = MathHelper.Clamp(stuck-30.0f, 0.0f, 100.0f); ; } } } diff --git a/Subsurface/Source/Items/Components/Machines/Pump.cs b/Subsurface/Source/Items/Components/Machines/Pump.cs index 0198c6b28..13989f9c1 100644 --- a/Subsurface/Source/Items/Components/Machines/Pump.cs +++ b/Subsurface/Source/Items/Components/Machines/Pump.cs @@ -59,10 +59,9 @@ namespace Subsurface.Items.Components { float hullPercentage = 0.0f; if (hull1 != null) hullPercentage = (hull1.Volume / hull1.FullVolume) * 100.0f; - flowPercentage = ((float)targetLevel - hullPercentage); + FlowPercentage = ((float)targetLevel - hullPercentage) * 10.0f; } - currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f); if (voltage < minVoltage) return; @@ -72,11 +71,8 @@ namespace Subsurface.Items.Components float powerFactor = (currPowerConsumption==0.0f) ? 1.0f : voltage; //flowPercentage = maxFlow * powerFactor; - float deltaVolume = 0.0f; - - deltaVolume = (flowPercentage/100.0f) * maxFlow * powerFactor; + float deltaVolume = (flowPercentage/100.0f) * maxFlow * powerFactor; - hull1.Volume += deltaVolume; if (hull1.Volume > hull1.FullVolume) hull1.Pressure += 0.5f; @@ -171,7 +167,7 @@ namespace Subsurface.Items.Components float tempTarget; if (float.TryParse(signal, NumberStyles.Any, CultureInfo.InvariantCulture, out tempTarget)) { - targetLevel = MathHelper.Clamp(tempTarget, 0.0f, 100.0f); + targetLevel = MathHelper.Clamp((tempTarget+100.0f)/2.0f, 0.0f, 100.0f); } } diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index f7eba534c..feb9ee919 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -152,7 +152,7 @@ namespace Subsurface.Items.Components if (PlayerInput.LeftButtonDown()) { - targetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y); + TargetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y); targetVelocity.Y = -targetVelocity.Y; valueChanged = true; diff --git a/Subsurface/Source/Items/Components/Wearable.cs b/Subsurface/Source/Items/Components/Wearable.cs index ed50c116a..449f4e3d7 100644 --- a/Subsurface/Source/Items/Components/Wearable.cs +++ b/Subsurface/Source/Items/Components/Wearable.cs @@ -9,11 +9,14 @@ namespace Subsurface.Items.Components { public Sprite Sprite; public bool HideLimb; + public LimbType DepthLimb; - public WearableSprite(Sprite sprite, bool hideLimb) + public WearableSprite(Sprite sprite, bool hideLimb, LimbType depthLimb = LimbType.None) { Sprite = sprite; HideLimb = hideLimb; + + DepthLimb = depthLimb; } } @@ -31,8 +34,8 @@ namespace Subsurface.Items.Components var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList(); int spriteCount = sprites.Count(); wearableSprite = new WearableSprite[spriteCount]; - limbType = new LimbType[spriteCount]; - limb = new Limb[spriteCount]; + limbType = new LimbType[spriteCount]; + limb = new Limb[spriteCount]; int i = 0; foreach (XElement subElement in sprites) @@ -53,11 +56,12 @@ namespace Subsurface.Items.Components spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"/"+spritePath; var sprite = new Sprite(subElement, "", spritePath); - wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false)); - //sprite[i].origin = new Vector2(sourceRect.Width / 2.0f, sourceRect.Height / 2.0f); + wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false), + (LimbType)Enum.Parse(typeof(LimbType), + ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true)); limbType[i] = (LimbType)Enum.Parse(typeof(LimbType), - ToolBox.GetAttributeString(subElement, "limb", "Head")); + ToolBox.GetAttributeString(subElement, "limb", "Head"), true); i++; } diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index d0948cff6..2f1b2624e 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -564,10 +564,10 @@ namespace Subsurface { Color color = (isSelected && editing) ? color = Color.Red : spriteColor; if (isHighlighted) color = Color.Orange; - - if (prefab.sprite!=null) + + if (prefab.sprite != null) { - if (body==null) + if (body == null) { prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color); } @@ -576,8 +576,7 @@ namespace Subsurface body.Draw(spriteBatch, prefab.sprite, color); } } - - + foreach (ItemComponent component in components) component.Draw(spriteBatch, editing); if (!editing || (body!=null && !body.Enabled)) diff --git a/Subsurface/Source/Items/RelatedItem.cs b/Subsurface/Source/Items/RelatedItem.cs index 1cfab0856..bdbbf339d 100644 --- a/Subsurface/Source/Items/RelatedItem.cs +++ b/Subsurface/Source/Items/RelatedItem.cs @@ -76,6 +76,8 @@ namespace Subsurface element.Add( new XAttribute("name", JoinedNames), new XAttribute("type", type.ToString())); + + if (!string.IsNullOrWhiteSpace("msg")) element.Add(new XAttribute("msg", Msg)); } public static RelatedItem Load(XElement element) diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index 6b16b76fb..42c7cc6bf 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -237,6 +237,7 @@ namespace Subsurface soundIndex = AmbientSoundManager.flowSounds[index].Loop(soundIndex, soundVolume, Position, 2000.0f); flowForce = Vector2.Zero; + lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f); if (open == 0.0f) return; @@ -253,8 +254,6 @@ namespace Subsurface UpdateRoomToRoom(deltaTime); } - lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f); - if (FlowForce.Length() > 150.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume) { //UpdateFlowForce(); diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index e5abeae62..2c42bc697 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -532,9 +532,9 @@ namespace Subsurface stream.Dispose(); } - catch + catch (Exception e) { - DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!"); + DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed! ("+e.Message+")"); return null; } } @@ -545,9 +545,9 @@ namespace Subsurface doc = XDocument.Load(file); } - catch + catch (Exception e) { - DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed!"); + DebugConsole.ThrowError("Loading submarine ''" + file + "'' failed! (" + e.Message + ")"); return null; } } diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs index 77d27661c..73da4aaf8 100644 --- a/Subsurface/Source/Particles/Particle.cs +++ b/Subsurface/Source/Particles/Particle.cs @@ -117,7 +117,14 @@ namespace Subsurface.Particles { if (gap.isHorizontal != isHorizontal) continue; if (gap.Open < 0.01f) continue; - if (gap.linkedTo[0]==currentHull && gap.linkedTo[1]!=null) + if (gap.linkedTo.Count==1) + { + if (!adjacentHulls.Contains(gap.linkedTo[0] as Hull)) + { + adjacentHulls.Add(gap.linkedTo[0] as Hull); + } + } + else if (gap.linkedTo[0] == currentHull && gap.linkedTo[1] != null) { if (!adjacentHulls.Contains(gap.linkedTo[1] as Hull)) { diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index a48ed31f5..c8afddeb5 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -283,7 +283,7 @@ namespace Subsurface if (subList.CountChildren > 0 && subList.Selected == null) subList.Select(-1); if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(-1); - if (infoFrame.children.Find(c => c.UserData as string == "playyourself") == null) + if (playerFrame.children.Find(c => c.UserData as string == "playyourself") == null) { var playYourself = new GUITickBox(new Rectangle(-30, -30, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame); playYourself.Selected = GameMain.Server.CharacterInfo != null; diff --git a/Subsurface/Source/Sounds/AmbientSoundManager.cs b/Subsurface/Source/Sounds/AmbientSoundManager.cs index 84eb0cc5d..84de54632 100644 --- a/Subsurface/Source/Sounds/AmbientSoundManager.cs +++ b/Subsurface/Source/Sounds/AmbientSoundManager.cs @@ -176,6 +176,8 @@ namespace Subsurface lowpassHFGain = 0.2f; } + + lowpassHFGain *= Character.Controlled.LowPassMultiplier; } //how fast the sub is moving, scaled to 0.0 -> 1.0 diff --git a/Subsurface/Source/Utils/ToolBox.cs b/Subsurface/Source/Utils/ToolBox.cs index 62f18258f..dd36e51b4 100644 --- a/Subsurface/Source/Utils/ToolBox.cs +++ b/Subsurface/Source/Utils/ToolBox.cs @@ -158,12 +158,21 @@ namespace Subsurface return val; } - + public static bool GetAttributeBool(XElement element, string name, bool defaultValue) { - if (element.Attribute(name) == null) return defaultValue; + var attribute = element.Attribute(name); + if (attribute == null) return defaultValue; - string val = element.Attribute(name).Value.ToLower().Trim(); + string val = attribute.Value.ToLower().Trim(); + return GetAttributeBool(attribute, defaultValue); + } + + public static bool GetAttributeBool(XAttribute attribute, bool defaultValue) + { + if (attribute == null) return defaultValue; + + string val = attribute.Value.ToLower().Trim(); if (val == "true") { return true; @@ -174,10 +183,13 @@ namespace Subsurface } else { - DebugConsole.ThrowError("Error in " + element + "! ''" + val + "'' is not a valid boolean value"); + DebugConsole.ThrowError("Error in " + attribute.Value.ToString() + "! ''" + val + "'' is not a valid boolean value"); return false; } } + + + public static Vector2 GetAttributeVector2(XElement element, string name, Vector2 defaultValue) { if (element.Attribute(name) == null) return defaultValue; diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index b3c1d69db..468866532 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ