diff --git a/Subsurface/Characters/Character.cs b/Subsurface/Characters/Character.cs index 3fd571a2e..a17bb1466 100644 --- a/Subsurface/Characters/Character.cs +++ b/Subsurface/Characters/Character.cs @@ -172,6 +172,13 @@ namespace Subsurface } } + public float Bleeding + { + get { return bleeding; } + set { bleeding = value; } + } + + //public float Blood //{ // get { return blood; } @@ -575,7 +582,7 @@ namespace Subsurface Body body = Submarine.PickBody(AnimController.limbs[0].SimPosition, mouseSimPos); Structure structure = null; if (body != null) structure = body.UserData as Structure; - if (structure!=null) + if (structure != null) { if (!structure.CastShadow && moveCam) { diff --git a/Subsurface/Characters/Limb.cs b/Subsurface/Characters/Limb.cs index 6c6ce7fcf..bcc33b0bd 100644 --- a/Subsurface/Characters/Limb.cs +++ b/Subsurface/Characters/Limb.cs @@ -184,7 +184,7 @@ namespace Subsurface body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc; } - impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 20.0f); + impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 8.0f); body.UserData = this; diff --git a/Subsurface/Characters/Ragdoll.cs b/Subsurface/Characters/Ragdoll.cs index abdc11695..4bd4c68e8 100644 --- a/Subsurface/Characters/Ragdoll.cs +++ b/Subsurface/Characters/Ragdoll.cs @@ -312,7 +312,17 @@ namespace Subsurface private void CalculateImpact(Fixture f1, Fixture f2, Contact contact) { Vector2 normal = contact.Manifold.LocalNormal; - float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal); + + Vector2 avgVelocity = Vector2.Zero; + foreach (Limb limb in limbs) + { + avgVelocity += limb.LinearVelocity; + } + + avgVelocity = avgVelocity / limbs.Count(); + + + float impact = Vector2.Dot((f1.Body.LinearVelocity + avgVelocity)/2.0f, -normal); Limb l = (Limb)f1.Body.UserData; diff --git a/Subsurface/Content/Characters/Human/human.xml b/Subsurface/Content/Characters/Human/human.xml index 84842b744..faae36450 100644 --- a/Subsurface/Content/Characters/Human/human.xml +++ b/Subsurface/Content/Characters/Human/human.xml @@ -76,12 +76,12 @@ - + - + diff --git a/Subsurface/Content/Items/Medical/med.png b/Subsurface/Content/Items/Medical/med.png new file mode 100644 index 000000000..6521e2b95 Binary files /dev/null and b/Subsurface/Content/Items/Medical/med.png differ diff --git a/Subsurface/Content/Items/Medical/medical.xml b/Subsurface/Content/Items/Medical/medical.xml new file mode 100644 index 000000000..12e02440f --- /dev/null +++ b/Subsurface/Content/Items/Medical/medical.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Subsurface/Items/Components/ItemComponent.cs b/Subsurface/Items/Components/ItemComponent.cs index a568b8b4d..3645951ac 100644 --- a/Subsurface/Items/Components/ItemComponent.cs +++ b/Subsurface/Items/Components/ItemComponent.cs @@ -90,6 +90,13 @@ namespace Subsurface set { canBeSelected = value; } } + [HasDefaultValue(false, false)] + public bool DeleteOnUse + { + get; + set; + } + public Item Item { get { return item; } diff --git a/Subsurface/Items/Components/Power/PowerTransfer.cs b/Subsurface/Items/Components/Power/PowerTransfer.cs index 537f5abc0..b51c9eaa7 100644 --- a/Subsurface/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Items/Components/Power/PowerTransfer.cs @@ -49,8 +49,7 @@ namespace Subsurface.Items.Components { pt.powerLoad += (fullLoad - pt.powerLoad) / inertia; pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia; - pt.Item.SendSignal("", - "power", fullPower / Math.Max(fullLoad, 1.0f)); + pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f)); if (-pt.currPowerConsumption > pt.powerLoad * 2.0f) pt.item.Condition = 0.0f; } } diff --git a/Subsurface/Items/Components/Power/Powered.cs b/Subsurface/Items/Components/Power/Powered.cs index ada384bd8..236f82daf 100644 --- a/Subsurface/Items/Components/Power/Powered.cs +++ b/Subsurface/Items/Components/Power/Powered.cs @@ -10,15 +10,19 @@ namespace Subsurface.Items.Components //negative values mean that the item is providing power to connected items protected float currPowerConsumption; - //the amount of power available for the item through connected items + //current voltage of the item (load / power) protected float voltage; - //the amount of power required for the item to work + //the minimum voltage required for the item to work protected float minVoltage; //the maximum amount of power the item can draw from connected items protected float powerConsumption; + private bool powerOnSoundPlayed; + + private static Sound powerOnSound; + [Editable, HasDefaultValue(0.5f, true)] public float MinVoltage { @@ -68,14 +72,28 @@ namespace Subsurface.Items.Components public override void Update(float deltaTime, Camera cam) { if (currPowerConsumption == 0.0f) return; - if (voltage > minVoltage) ApplyStatusEffects(ActionType.OnActive, deltaTime); + if (voltage > minVoltage) + { + if (!powerOnSoundPlayed) + { + powerOnSound.Play(1.0f, 600.0f, item.Position); + powerOnSoundPlayed = true; + } + ApplyStatusEffects(ActionType.OnActive, deltaTime); + } + else if (voltage < 0.1f) + { + powerOnSoundPlayed = false; + } } public Powered(Item item, XElement element) : base(item, element) { - //minVoltage = ToolBox.GetAttributeFloat(element, "minvoltage", 10.0f); - //powerConsumption = ToolBox.GetAttributeFloat(element, "powerconsumption", 15.0f); + if (powerOnSound==null) + { + powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg"); + } } } } diff --git a/Subsurface/Items/Item.cs b/Subsurface/Items/Item.cs index 0dc288099..d736ede36 100644 --- a/Subsurface/Items/Item.cs +++ b/Subsurface/Items/Item.cs @@ -796,6 +796,8 @@ namespace Subsurface { if (condition == 0.0f) return; + bool remove = false; + foreach (ItemComponent ic in components) { if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue; @@ -804,8 +806,12 @@ namespace Subsurface ic.PlaySound(ActionType.OnUse, 1.0f, Position); ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character); + + if (ic.DeleteOnUse) remove = true; } } + + if (remove) Remove(); } public void SecondaryUse(float deltaTime, Character character = null) diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index 417b836b4..baa86edad 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -286,6 +286,13 @@ Designer PreserveNewest + + PreserveNewest + Designer + + + PreserveNewest + PreserveNewest Designer diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index ea8fe93b2..49ca8b7ad 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ