Timer for deattaching items, more reliable door syncing, some new splash sounds

This commit is contained in:
Regalis
2016-02-13 21:25:59 +02:00
parent 9b5e78fce4
commit 9b6dd5da00
30 changed files with 252 additions and 59 deletions
+33
View File
@@ -1177,6 +1177,39 @@
<None Include="Content\Sounds\startDrone.ogg"> <None Include="Content\Sounds\startDrone.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Content\Sounds\Water\Splash0.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash2.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash3.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash4.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash5.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash6.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash7.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash8.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\Splash9.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\splashLoop.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Water\WaterAmbience2.ogg"> <None Include="Content\Sounds\Water\WaterAmbience2.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
@@ -9,7 +9,7 @@
<ragdoll waveamplitude="0.0" swimspeed="1.0" walkspeed="0.3" flip="true" rotatetowardsmovement="false" headangle="-90"> <ragdoll waveamplitude="0.0" swimspeed="1.0" walkspeed="0.3" flip="true" rotatetowardsmovement="false" headangle="-90">
<!-- head --> <!-- head -->
<limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0"> <limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="0,0,628,1024" depth="0.02" origin ="0.4,0.5"/> <sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="0,0,628,1024" depth="0.02" origin ="0.4,0.5"/>
<attack type="Hit" range="700" duration="0.2" force="400" damagetype="blunt"/> <attack type="Hit" range="700" duration="0.2" force="400" damagetype="blunt"/>
</limb> </limb>
+1 -1
View File
@@ -25,7 +25,7 @@
<output name="signal_out"/> <output name="signal_out"/>
</ConnectionPanel> </ConnectionPanel>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="10.0"
aimpos="35,-10" handle1="0,0" attachable="true" attachedbydefault="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" attachedbydefault="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -123,7 +123,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -158,7 +158,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -192,7 +192,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -226,7 +226,8 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -258,7 +259,7 @@
<Body width="31" height="24"/> <Body width="31" height="24"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -289,7 +290,7 @@
<Body width="31" height="24"/> <Body width="31" height="24"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -320,7 +321,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" <Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"> aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -354,7 +355,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" <Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"> slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
@@ -386,7 +387,7 @@
<Body width="16" height="16"/> <Body width="16" height="16"/>
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" <Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"> slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/> <requireditem name="Wrench" type="Equipped"/>
</Holdable> </Holdable>
+2 -2
View File
@@ -62,7 +62,7 @@
<Item name="Uranium Bar" requirefullcondition="true"/> <Item name="Uranium Bar" requirefullcondition="true"/>
</Deconstruct> </Deconstruct>
<Sprite texture ="fuelrod.png"/> <Sprite texture ="fuelrod.png" depth="0.55"/>
<Body radius="6" height="22" density="5"/> <Body radius="6" height="22" density="5"/>
@@ -81,7 +81,7 @@
<Item name="Incendium Bar" requirefullcondition="true"/> <Item name="Incendium Bar" requirefullcondition="true"/>
</Deconstruct> </Deconstruct>
<Sprite texture ="fuelrod.png"/> <Sprite texture ="fuelrod.png" depth="0.55"/>
<Body radius="6" height="22" density="5"/> <Body radius="6" height="22" density="5"/>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,8 @@ namespace Barotrauma
protected double onFloorTimer; protected double onFloorTimer;
private float splashSoundTimer;
//the movement speed of the ragdoll //the movement speed of the ragdoll
public Vector2 movement; public Vector2 movement;
//the target speed towards which movement is interpolated //the target speed towards which movement is interpolated
@@ -382,7 +384,9 @@ namespace Barotrauma
} }
avgVelocity = avgVelocity / Limbs.Count(); avgVelocity = avgVelocity / Limbs.Count();
if (character.Submarine == null && f2.Body.UserData is Submarine) avgVelocity -= (f2.Body.UserData as Submarine).Velocity;
float impact = Vector2.Dot(avgVelocity, -normal); float impact = Vector2.Dot(avgVelocity, -normal);
Limb l = (Limb)f1.Body.UserData; Limb l = (Limb)f1.Body.UserData;
@@ -396,7 +400,7 @@ namespace Barotrauma
{ {
if (!character.IsNetworkPlayer) if (!character.IsNetworkPlayer)
{ {
character.AddDamage(CauseOfDeath.Damage, impact - l.impactTolerance * 0.1f); character.AddDamage(CauseOfDeath.Damage, impact - l.impactTolerance * 0.1f, null);
strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance); strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance);
} }
@@ -610,6 +614,8 @@ namespace Barotrauma
FindLowestLimb(); FindLowestLimb();
FindHull(); FindHull();
splashSoundTimer -= deltaTime;
//ragdoll isn't in any room -> it's in the water //ragdoll isn't in any room -> it's in the water
if (currentHull == null) if (currentHull == null)
@@ -678,11 +684,18 @@ namespace Barotrauma
limb.LinearVelocity*0.001f, limb.LinearVelocity*0.001f,
0.0f, limbHull); 0.0f, limbHull);
//if the Character dropped into water, create a wave //if the Character dropped into water, create a wave
if (limb.LinearVelocity.Y<0.0f) if (limb.LinearVelocity.Y<0.0f)
{ {
if (splashSoundTimer <= 0.0f)
{
SoundPlayer.PlaySplashSound(limb.WorldPosition, Math.Abs(limb.LinearVelocity.Y) + Rand.Range(-5.0f, 0.0f));
splashSoundTimer = 0.5f;
}
//1.0 when the limb is parallel to the surface of the water //1.0 when the limb is parallel to the surface of the water
// = big splash and a large impact // = big splash and a large impact
float parallel = (float)Math.Abs(Math.Sin(limb.Rotation)); float parallel = (float)Math.Abs(Math.Sin(limb.Rotation));
+1 -1
View File
@@ -210,7 +210,7 @@ namespace Barotrauma
body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc; body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc;
} }
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", character.IsHumanoid ? 10.0f : 50.0f); impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f);
body.UserData = this; body.UserData = this;
+1 -1
View File
@@ -274,7 +274,7 @@ namespace Barotrauma
case "heal": case "heal":
if (Character.Controlled != null) if (Character.Controlled != null)
{ {
Character.Controlled.AddDamage(CauseOfDeath.Damage, -Character.Controlled.MaxHealth); Character.Controlled.AddDamage(CauseOfDeath.Damage, -Character.Controlled.MaxHealth, null);
Character.Controlled.Oxygen = 100.0f; Character.Controlled.Oxygen = 100.0f;
Character.Controlled.Bleeding = 0.0f; Character.Controlled.Bleeding = 0.0f;
} }
@@ -68,9 +68,7 @@ namespace Barotrauma
protected override void DropItem(Item item) protected override void DropItem(Item item)
{ {
if (item.body == null) return; bool enabled = item.body!=null && item.body.Enabled;
bool enabled = item.body.Enabled;
item.Drop(character); item.Drop(character);
if (!enabled) if (!enabled)
+35 -7
View File
@@ -31,6 +31,8 @@ namespace Barotrauma.Items.Components
private bool isStuck; private bool isStuck;
private float lastReceivedMessage;
private float stuck; private float stuck;
public float Stuck public float Stuck
{ {
@@ -429,22 +431,48 @@ namespace Barotrauma.Items.Components
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f) public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{ {
if (isStuck) return; if (isStuck || GameMain.Client != null) return;
if (connection.Name=="toggle") if (connection.Name=="toggle")
{ {
isOpen = !isOpen; SetState(!isOpen, false);
PlaySound(ActionType.OnUse, item.WorldPosition);
} }
else if (connection.Name == "set_state") else if (connection.Name == "set_state")
{ {
bool newState = (signal!="0"); SetState(signal != "0", false);
if (isOpen!=newState) PlaySound(ActionType.OnUse, item.WorldPosition);
isOpen = newState;
} }
item.NewComponentEvent(this, false, true);
}
private void SetState(bool state, bool isNetWorkMessage)
{
if (GameMain.Client != null && !isNetWorkMessage) return;
if (isStuck || isOpen == state) return;
PlaySound(ActionType.OnUse, item.WorldPosition);
isOpen = state;
//opening a partially stuck door makes it less stuck //opening a partially stuck door makes it less stuck
if (isOpen) stuck = MathHelper.Clamp(stuck-30.0f, 0.0f, 100.0f); if (isOpen) stuck = MathHelper.Clamp(stuck - 30.0f, 0.0f, 100.0f);
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
{
message.Write(isOpen);
return true;
}
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
{
if (sendingTime < lastReceivedMessage) return;
lastReceivedMessage = sendingTime;
SetState(message.ReadBoolean(), true);
} }
} }
} }
@@ -13,7 +13,7 @@ namespace Barotrauma.Items.Components
private List<RelatedItem> prevRequiredItems; private List<RelatedItem> prevRequiredItems;
string prevMsg; string prevMsg;
//the distance from the holding characters elbow to center of the physics body of the item //the distance from the holding characters elbow to center of the physics body of the item
protected Vector2 holdPos; protected Vector2 holdPos;
@@ -72,7 +72,7 @@ namespace Barotrauma.Items.Components
[HasDefaultValue(0.0f, false)] [HasDefaultValue(0.0f, false)]
public float HoldAngle public float HoldAngle
{ {
get { return MathHelper.ToDegrees(holdAngle); } get { return MathHelper.ToDegrees(holdAngle); }
set { holdAngle = MathHelper.ToRadians(value); } set { holdAngle = MathHelper.ToRadians(value); }
} }
@@ -101,7 +101,7 @@ namespace Barotrauma.Items.Components
Msg = ""; Msg = "";
} }
if (attachedByDefault || (Screen.Selected == GameMain.EditMapScreen && Submarine.Loaded!=null)) Use(1.0f); if (attachedByDefault || (Screen.Selected == GameMain.EditMapScreen && Submarine.Loaded != null)) Use(1.0f);
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f); //holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
@@ -110,12 +110,15 @@ namespace Barotrauma.Items.Components
public override void Drop(Character dropper) public override void Drop(Character dropper)
{ {
if (body != null) item.body = body;
if (item.body != null) item.body.Enabled = true; if (item.body != null) item.body.Enabled = true;
IsActive = false; IsActive = false;
if (picker == null) if (picker == null)
{ {
if (dropper==null) return; if (dropper == null) return;
picker = dropper; picker = dropper;
} }
if (picker.Inventory == null) return; if (picker.Inventory == null) return;
@@ -138,7 +141,7 @@ namespace Barotrauma.Items.Components
if (item.body == null) if (item.body == null)
{ {
if (body!=null) if (body != null)
{ {
item.body = body; item.body = body;
} }
@@ -151,7 +154,7 @@ namespace Barotrauma.Items.Components
if (!item.body.Enabled) if (!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);
} }
if (picker.TrySelectItem(item)) if (picker.TrySelectItem(item))
@@ -166,7 +169,7 @@ namespace Barotrauma.Items.Components
if (picker == null) return; if (picker == null) return;
picker.DeselectItem(item); picker.DeselectItem(item);
item.body.Enabled = false; item.body.Enabled = false;
IsActive = false; IsActive = false;
} }
@@ -189,7 +192,7 @@ namespace Barotrauma.Items.Components
} }
attached = false; attached = false;
if (body!=null) item.body = body; if (body != null) item.body = body;
//item.body.Enabled = true; //item.body.Enabled = true;
return true; return true;
@@ -197,13 +200,13 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null) public override bool Use(float deltaTime, Character character = null)
{ {
if (!attachable || item.body==null) return true; if (!attachable || item.body == null) return true;
if (character != null && !character.IsKeyDown(InputType.Aim)) return false; if (character != null && !character.IsKeyDown(InputType.Aim)) return false;
item.Drop(); item.Drop();
var containedItems = item.ContainedItems; var containedItems = item.ContainedItems;
if (containedItems!=null) if (containedItems != null)
{ {
foreach (Item contained in containedItems) foreach (Item contained in containedItems)
{ {
@@ -231,12 +234,12 @@ namespace Barotrauma.Items.Components
} }
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
{ {
if (!item.body.Enabled) return; if (!item.body.Enabled) return;
if (!picker.HasSelectedItem(item)) IsActive = false; if (!picker.HasSelectedItem(item)) IsActive = false;
ApplyStatusEffects(ActionType.OnActive, deltaTime, picker); ApplyStatusEffects(ActionType.OnActive, deltaTime, picker);
if (item.body.Dir != picker.AnimController.Dir) Flip(item); if (item.body.Dir != picker.AnimController.Dir) Flip(item);
AnimController ac = picker.AnimController; AnimController ac = picker.AnimController;
@@ -246,8 +249,8 @@ namespace Barotrauma.Items.Components
//item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f; //item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle); ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle);
} }
protected void Flip(Item item) protected void Flip(Item item)
{ {
handlePos[0].X = -handlePos[0].X; handlePos[0].X = -handlePos[0].X;
@@ -267,7 +270,7 @@ namespace Barotrauma.Items.Components
} }
else else
{ {
if (item.Inventory!=null) if (item.Inventory != null)
{ {
if (body != null) if (body != null)
{ {
@@ -300,7 +303,7 @@ namespace Barotrauma.Items.Components
} }
catch catch
{ {
return; return;
} }
@@ -1,4 +1,7 @@
using System; using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Linq; using System.Xml.Linq;
@@ -10,6 +13,9 @@ namespace Barotrauma.Items.Components
protected List<LimbSlot> allowedSlots; protected List<LimbSlot> allowedSlots;
private float pickTimer;
public List<LimbSlot> AllowedSlots public List<LimbSlot> AllowedSlots
{ {
get { return allowedSlots; } get { return allowedSlots; }
@@ -50,20 +56,49 @@ namespace Barotrauma.Items.Components
public override bool Pick(Character picker) public override bool Pick(Character picker)
{ {
if (picker == null) return false; //return if someone is already trying to pick the item
if (picker.Inventory == null) return false; if (pickTimer>0.0f) return false;
if (picker == null || picker.Inventory == null) return false;
if (picker.Inventory.TryPutItem(item, allowedSlots, picker==Character.Controlled)) if (PickingTime>0.0f)
{ {
if (!picker.HasSelectedItem(item) && item.body!=null) item.body.Enabled = false; CoroutineManager.StartCoroutine(WaitForPick(picker, PickingTime));
//create a networkevent here, because the item doesn't count as picked yet and the character won't create one
new NetworkEvent(NetworkEventType.PickItem, picker.ID, true,
new int[]
{
item.ID,
picker.IsKeyHit(InputType.Select) ? 1 : 0,
picker.IsKeyHit(InputType.Use) ? 1 : 0
});
return false;
}
else
{
return OnPicked(picker);
}
}
private bool OnPicked(Character picker)
{
if (picker.Inventory.TryPutItem(item, allowedSlots, picker == Character.Controlled))
{
if (!picker.HasSelectedItem(item) && item.body != null) item.body.Enabled = false;
this.picker = picker; this.picker = picker;
for (int i = item.linkedTo.Count - 1; i >= 0; i--) for (int i = item.linkedTo.Count - 1; i >= 0; i--)
{
item.linkedTo[i].RemoveLinked(item); item.linkedTo[i].RemoveLinked(item);
}
item.linkedTo.Clear(); item.linkedTo.Clear();
var connectionPanel = item.GetComponent<ConnectionPanel>(); var connectionPanel = item.GetComponent<ConnectionPanel>();
if (connectionPanel!=null) if (connectionPanel != null)
{ {
foreach (Connection c in connectionPanel.Connections) foreach (Connection c in connectionPanel.Connections)
{ {
@@ -72,7 +107,7 @@ namespace Barotrauma.Items.Components
if (w == null) continue; if (w == null) continue;
w.Item.Drop(picker); w.Item.Drop(picker);
w.Item.SetTransform(item.SimPosition, 0.0f); w.Item.SetTransform(picker.SimPosition, 0.0f);
} }
} }
} }
@@ -90,6 +125,63 @@ namespace Barotrauma.Items.Components
return false; return false;
} }
private IEnumerable<object> WaitForPick(Character picker, float requiredTime)
{
var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand);
var rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
pickTimer = 0.0f;
while (pickTimer < requiredTime)
{
if (picker.IsKeyHit(InputType.Aim) || !item.IsInPickRange(picker.WorldPosition))
{
StopPicking(picker);
yield return CoroutineStatus.Success;
}
picker.AnimController.Anim = AnimController.Animation.UsingConstruction;
picker.AnimController.TargetMovement = Vector2.Zero;
leftHand.Disabled = true;
leftHand.pullJoint.Enabled = true;
leftHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * (float)Math.Sin(pickTimer*10.0f)*0.1f;
rightHand.Disabled = true;
rightHand.pullJoint.Enabled = true;
rightHand.pullJoint.WorldAnchorB = item.SimPosition + Vector2.UnitY * (float)Math.Sin(pickTimer*10.0f) * 0.1f;
pickTimer += CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}
StopPicking(picker);
OnPicked(picker);
yield return CoroutineStatus.Success;
}
private void StopPicking(Character picker)
{
picker.AnimController.Anim = AnimController.Animation.None;
pickTimer = 0.0f;
}
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
if (pickTimer <= 0.0f) return;
float progressBarWidth = 100.0f;
GUI.DrawProgressBar(spriteBatch, item.DrawPosition + new Vector2(-progressBarWidth/2.0f, 50.0f), new Vector2(progressBarWidth, 15.0f),
pickTimer / PickingTime,
Color.Lerp(Color.Red, Color.Green, pickTimer / PickingTime));
}
public override void Drop(Character dropper) public override void Drop(Character dropper)
{ {
if (picker == null) if (picker == null)
@@ -67,6 +67,13 @@ namespace Barotrauma.Items.Components
public ItemComponent Parent; public ItemComponent Parent;
[HasDefaultValue(0.0f, false)]
public float PickingTime
{
get;
private set;
}
public readonly Dictionary<string, ObjectProperty> properties; public readonly Dictionary<string, ObjectProperty> properties;
public Dictionary<string, ObjectProperty> ObjectProperties public Dictionary<string, ObjectProperty> ObjectProperties
{ {
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Barotrauma
protected override void DropItem(Item item) protected override void DropItem(Item item)
{ {
item.Drop(); item.Drop();
item.body.Enabled = true; if (item.body != null) item.body.Enabled = true;
item.SetTransform(container.Item.SimPosition, 0.0f); item.SetTransform(container.Item.SimPosition, 0.0f);
} }
+1 -1
View File
@@ -159,7 +159,7 @@ namespace Barotrauma
body.SleepingAllowed = false; body.SleepingAllowed = false;
body.IgnoreGravity = true; body.IgnoreGravity = true;
body.OnCollision += OnCollision; body.OnCollision += OnCollision;
//body.UserData = this; body.UserData = submarine;
} }
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Barotrauma.Networking
private bool started; private bool started;
private NetServer server; private NetServer server;
private NetPeerConfiguration config; private NetPeerConfiguration config;
private DateTime sparseUpdateTimer; private DateTime sparseUpdateTimer;
private DateTime refreshMasterTimer; private DateTime refreshMasterTimer;
+20 -2
View File
@@ -10,11 +10,13 @@ using System.Collections.Generic;
namespace Barotrauma namespace Barotrauma
{ {
public enum DamageSoundType { public enum DamageSoundType
{
None, None,
StructureBlunt, StructureSlash, StructureBlunt, StructureSlash,
LimbBlunt, LimbSlash, LimbArmor, LimbBlunt, LimbSlash, LimbArmor,
Implode, Pressure } Implode, Pressure
}
public struct DamageSound public struct DamageSound
{ {
@@ -53,6 +55,8 @@ namespace Barotrauma
{ {
public static Sound[] flowSounds = new Sound[3]; public static Sound[] flowSounds = new Sound[3];
public static Sound[] SplashSounds = new Sound[10];
public static float MusicVolume = 1.0f; public static float MusicVolume = 1.0f;
private const float MusicLerpSpeed = 0.1f; private const float MusicLerpSpeed = 0.1f;
@@ -60,6 +64,7 @@ namespace Barotrauma
private static Sound[] waterAmbiences = new Sound[2]; private static Sound[] waterAmbiences = new Sound[2];
private static int[] waterAmbienceIndexes = new int[2]; private static int[] waterAmbienceIndexes = new int[2];
private static DamageSound[] damageSounds; private static DamageSound[] damageSounds;
private static BackgroundMusic currentMusic; private static BackgroundMusic currentMusic;
@@ -97,6 +102,12 @@ namespace Barotrauma
flowSounds[2] = Sound.Load("Content/Sounds/Water/FlowLarge.ogg", false); flowSounds[2] = Sound.Load("Content/Sounds/Water/FlowLarge.ogg", false);
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
for (int i = 0; i < 10; i++ )
{
SplashSounds[i] = Sound.Load("Content/Sounds/Water/Splash"+(i)+".ogg", false);
yield return CoroutineStatus.Running;
}
XDocument doc = ToolBox.TryLoadXml("Content/Sounds/sounds.xml"); XDocument doc = ToolBox.TryLoadXml("Content/Sounds/sounds.xml");
if (doc == null) yield return CoroutineStatus.Failure; if (doc == null) yield return CoroutineStatus.Failure;
@@ -282,6 +293,13 @@ namespace Barotrauma
} }
} }
public static void PlaySplashSound(Vector2 worldPosition, float strength)
{
int splashIndex = MathHelper.Clamp((int)(strength + Rand.Range(-2,2)), 0, SplashSounds.Length-1);
SplashSounds[splashIndex].Play(1.0f, 800.0f, worldPosition);
}
public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body) public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body)
{ {
Vector2 bodyPosition = body.DrawPosition; Vector2 bodyPosition = body.DrawPosition;
+2 -2
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 2013
VisualStudioVersion = 14.0.23107.0 VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma", "Subsurface\Barotrauma.csproj", "{008C0F83-E914-4966-9135-EA885059EDD8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Barotrauma", "Subsurface\Barotrauma.csproj", "{008C0F83-E914-4966-9135-EA885059EDD8}"
EndProject EndProject
Binary file not shown.