Merged branch combat-mission into combat-mission
This commit is contained in:
@@ -82,6 +82,10 @@
|
|||||||
|
|
||||||
<Projectile launchimpulse="80.0">
|
<Projectile launchimpulse="80.0">
|
||||||
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
|
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
|
||||||
|
|
||||||
|
<StatusEffect type="OnActive" target="This">
|
||||||
|
<ParticleEmitter particle="bubbles" anglemin="0" anglemax="360" particleamount="10" velocitymin="0" velocitymax="50" scalemin="2" scalemax="5"/>
|
||||||
|
</StatusEffect>
|
||||||
</Projectile>
|
</Projectile>
|
||||||
|
|
||||||
<ItemContainer hideitems="true" capacity="1" canbeselected = "true">
|
<ItemContainer hideitems="true" capacity="1" canbeselected = "true">
|
||||||
@@ -110,9 +114,14 @@
|
|||||||
|
|
||||||
<Projectile launchimpulse="80.0">
|
<Projectile launchimpulse="80.0">
|
||||||
<Attack damage="1000" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
|
<Attack damage="1000" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
|
||||||
|
|
||||||
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/bigexplosion.ogg">
|
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/bigexplosion.ogg">
|
||||||
<Explosion range="1000.0" structuredamage="1000" damage="1000" stun="10" force="50.0"/>
|
<Explosion range="1000.0" structuredamage="1000" damage="1000" stun="10" force="50.0"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
|
|
||||||
|
<StatusEffect type="OnActive" target="This">
|
||||||
|
<ParticleEmitter particle="bubbles" anglemin="0" anglemax="360" particleamount="10" velocitymin="0" velocitymax="50" scalemin="2" scalemax="5"/>
|
||||||
|
</StatusEffect>
|
||||||
</Projectile>
|
</Projectile>
|
||||||
|
|
||||||
<ItemContainer hideitems="true" capacity="1" canbeselected = "true">
|
<ItemContainer hideitems="true" capacity="1" canbeselected = "true">
|
||||||
|
|||||||
@@ -422,7 +422,11 @@ namespace Barotrauma
|
|||||||
float volume = stairs == null ? impact / 5.0f : impact;
|
float volume = stairs == null ? impact / 5.0f : impact;
|
||||||
volume = Math.Min(impact, 1.0f);
|
volume = Math.Min(impact, 1.0f);
|
||||||
|
|
||||||
if (impact > 0.8f && l.HitSound != null && l.soundTimer <= 0.0f) l.HitSound.Play(volume, impact * 100.0f, l.WorldPosition);
|
if (impact > 0.5f && l.HitSound != null && l.soundTimer <= 0.0f)
|
||||||
|
{
|
||||||
|
l.soundTimer = Limb.SoundInterval;
|
||||||
|
l.HitSound.Play(volume, impact * 250.0f, l.WorldPosition);
|
||||||
|
}
|
||||||
|
|
||||||
if (impact > l.impactTolerance)
|
if (impact > l.impactTolerance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1328,7 +1328,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
Vector2 namePos = new Vector2(pos.X, pos.Y - 80.0f - (5.0f/cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom;
|
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f/cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom;
|
||||||
Color nameColor = Color.White;
|
Color nameColor = Color.White;
|
||||||
|
|
||||||
if (Character.Controlled != null && TeamID!=Character.Controlled.TeamID)
|
if (Character.Controlled != null && TeamID!=Character.Controlled.TeamID)
|
||||||
|
|||||||
@@ -462,14 +462,14 @@ namespace Barotrauma
|
|||||||
Vector2 normal = new Vector2(-line.Y, line.X);
|
Vector2 normal = new Vector2(-line.Y, line.X);
|
||||||
normal = Vector2.Normalize(-normal);
|
normal = Vector2.Normalize(-normal);
|
||||||
|
|
||||||
float dragDot = Vector2.Dot(normal, velDir);
|
float dragDot = Math.Abs(Vector2.Dot(normal, velDir));
|
||||||
Vector2 dragForce = Vector2.Zero;
|
Vector2 dragForce = Vector2.Zero;
|
||||||
if (dragDot > 0)
|
if (dragDot > 0)
|
||||||
{
|
{
|
||||||
float vel = LinearVelocity.Length()*2.0f;
|
float vel = LinearVelocity.Length()*2.0f;
|
||||||
float drag = dragDot * vel * vel
|
float drag = dragDot * vel * vel
|
||||||
* ConvertUnits.ToSimUnits(sprite.size.Y);
|
* ConvertUnits.ToSimUnits(sprite.size.Y);
|
||||||
dragForce = drag * -velDir;
|
dragForce = Math.Min(drag, Mass*1000.0f) * -velDir;
|
||||||
//if (dragForce.Length() > 100.0f) { }
|
//if (dragForce.Length() > 100.0f) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 position = new Vector2(
|
Vector2 position = new Vector2(
|
||||||
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
cargoSpawnPos.Position.X + Rand.Range(-20.0f, 20.0f, false),
|
||||||
cargoRoom.Rect.Y - cargoRoom.Rect.Height);
|
cargoRoom.Rect.Y - cargoRoom.Rect.Height + itemPrefab.Size.Y / 2);
|
||||||
|
|
||||||
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
var item = new Item(itemPrefab, position, cargoRoom.Submarine);
|
||||||
item.FindHull();
|
item.FindHull();
|
||||||
|
|||||||
@@ -449,6 +449,33 @@ namespace Barotrauma
|
|||||||
"Sub pos: " + Submarine.MainSub.Position.ToPoint(),
|
"Sub pos: " + Submarine.MainSub.Position.ToPoint(),
|
||||||
new Vector2(10, 50), Color.White);
|
new Vector2(10, 50), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < Sounds.SoundManager.DefaultSourceCount; i++)
|
||||||
|
{
|
||||||
|
Color clr = Color.White;
|
||||||
|
|
||||||
|
string soundStr = i+": ";
|
||||||
|
|
||||||
|
var playingSound = Sounds.SoundManager.GetPlayingSound(i);
|
||||||
|
|
||||||
|
if (playingSound == null)
|
||||||
|
{
|
||||||
|
soundStr+= "none";
|
||||||
|
clr *= 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
soundStr += System.IO.Path.GetFileNameWithoutExtension(playingSound.FilePath);
|
||||||
|
|
||||||
|
if (Sounds.SoundManager.IsLooping(i))
|
||||||
|
{
|
||||||
|
soundStr += " (looping)";
|
||||||
|
clr = Color.Yellow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.DrawString(spriteBatch, new Vector2(200, i * 15), soundStr, clr, Color.Black * 0.5f, 0, GUI.SmallFont);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMain.NetworkMember != null) GameMain.NetworkMember.Draw(spriteBatch);
|
if (GameMain.NetworkMember != null) GameMain.NetworkMember.Draw(spriteBatch);
|
||||||
|
|||||||
@@ -124,9 +124,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
base.Rect = value;
|
||||||
|
|
||||||
frame.Rect = new Rectangle(value.X, value.Y, frame.Rect.Width, frame.Rect.Height);
|
frame.Rect = new Rectangle(value.X, value.Y, frame.Rect.Width, frame.Rect.Height);
|
||||||
textBlock.Rect = value;
|
textBlock.Rect = value;
|
||||||
rect = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
base.Rect = value;
|
||||||
|
|
||||||
box.Rect = new Rectangle(value.X,value.Y,box.Rect.Width,box.Rect.Height);
|
box.Rect = new Rectangle(value.X,value.Y,box.Rect.Width,box.Rect.Height);
|
||||||
text.Rect = new Rectangle(box.Rect.Right + 10, box.Rect.Y + 2, 20, box.Rect.Height);
|
text.Rect = new Rectangle(box.Rect.Right + 10, box.Rect.Y + 2, 20, box.Rect.Height);
|
||||||
rect = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds;
|
Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
|
|
||||||
|
bool paused = false;
|
||||||
|
|
||||||
while (Timing.Accumulator >= Timing.Step)
|
while (Timing.Accumulator >= Timing.Step)
|
||||||
{
|
{
|
||||||
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
|
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
|
||||||
@@ -302,8 +304,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
PlayerInput.Update(Timing.Step);
|
PlayerInput.Update(Timing.Step);
|
||||||
|
|
||||||
bool paused = false;
|
|
||||||
|
|
||||||
if (titleScreenOpen)
|
if (titleScreenOpen)
|
||||||
{
|
{
|
||||||
if (TitleScreen.LoadState >= 100.0f &&
|
if (TitleScreen.LoadState >= 100.0f &&
|
||||||
@@ -342,7 +342,7 @@ namespace Barotrauma
|
|||||||
Timing.Accumulator -= Timing.Step;
|
Timing.Accumulator -= Timing.Step;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timing.Alpha = Timing.Accumulator / Timing.Step;
|
if (!paused) Timing.Alpha = Timing.Accumulator / Timing.Step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
class CargoManager
|
class CargoManager
|
||||||
{
|
{
|
||||||
private List<MapEntityPrefab> purchasedItems;
|
private List<ItemPrefab> purchasedItems;
|
||||||
|
|
||||||
public CargoManager()
|
public CargoManager()
|
||||||
{
|
{
|
||||||
purchasedItems = new List<MapEntityPrefab>();
|
purchasedItems = new List<ItemPrefab>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddItem(MapEntityPrefab item)
|
public void AddItem(ItemPrefab item)
|
||||||
{
|
{
|
||||||
purchasedItems.Add(item);
|
purchasedItems.Add(item);
|
||||||
}
|
}
|
||||||
@@ -35,11 +35,11 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MapEntityPrefab prefab in purchasedItems)
|
foreach (ItemPrefab prefab in purchasedItems)
|
||||||
{
|
{
|
||||||
Vector2 position = new Vector2(
|
Vector2 position = new Vector2(
|
||||||
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
||||||
Rand.Range(cargoRoom.Rect.Y - cargoRoom.Rect.Height, cargoRoom.Rect.Y));
|
cargoRoom.Rect.Y - cargoRoom.Rect.Height + prefab.Size.Y/2);
|
||||||
|
|
||||||
new Item(prefab as ItemPrefab, position, wp.Submarine);
|
new Item(prefab as ItemPrefab, position, wp.Submarine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,18 +241,20 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
|
||||||
if (subsToLeaveBehind == null || leavingSub == null)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Leaving submarine not selected -> selecting the closest one");
|
|
||||||
|
|
||||||
leavingSub = GetLeavingSub();
|
|
||||||
|
|
||||||
subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool success = CrewManager.characters.Any(c => !c.IsDead);
|
bool success = CrewManager.characters.Any(c => !c.IsDead);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
if (subsToLeaveBehind == null || leavingSub == null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Leaving submarine not selected -> selecting the closest one");
|
||||||
|
|
||||||
|
leavingSub = GetLeavingSub();
|
||||||
|
|
||||||
|
subsToLeaveBehind = GetSubsToLeaveBehind(leavingSub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GameMain.GameSession.EndShift("");
|
GameMain.GameSession.EndShift("");
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
|
|||||||
@@ -336,10 +336,12 @@ namespace Barotrauma
|
|||||||
new XElement("Gamesession"));
|
new XElement("Gamesession"));
|
||||||
|
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
doc.Root.Add(new XAttribute("savetime", now.Hour + ":" + now.Minute + ", " + now.ToShortDateString()));
|
doc.Root.Add(new XAttribute("savetime", now.ToShortTimeString() + ", " + now.ToShortDateString()));
|
||||||
|
|
||||||
doc.Root.Add(new XAttribute("submarine", submarine==null ? "" : submarine.Name));
|
doc.Root.Add(new XAttribute("submarine", submarine==null ? "" : submarine.Name));
|
||||||
|
|
||||||
|
doc.Root.Add(new XAttribute("mapseed", Map.Seed));
|
||||||
|
|
||||||
((SinglePlayerMode)gameMode).Save(doc.Root);
|
((SinglePlayerMode)gameMode).Save(doc.Root);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ namespace Barotrauma
|
|||||||
MergeSlots();
|
MergeSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime, bool subInventory = false)
|
||||||
{
|
{
|
||||||
base.Update(deltaTime);
|
base.Update(deltaTime);
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ namespace Barotrauma.Items.Components
|
|||||||
item.body.CollisionCategories = Physics.CollisionProjectile;
|
item.body.CollisionCategories = Physics.CollisionProjectile;
|
||||||
item.body.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall | Physics.CollisionLevel;
|
item.body.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall | Physics.CollisionLevel;
|
||||||
|
|
||||||
|
IsActive = true;
|
||||||
|
|
||||||
if (stickJoint == null || !doesStick) return;
|
if (stickJoint == null || !doesStick) return;
|
||||||
|
|
||||||
if (stickTarget != null)
|
if (stickTarget != null)
|
||||||
@@ -111,6 +113,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
|
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||||
|
|
||||||
if (stickJoint != null && stickJoint.JointTranslation < 0.01f)
|
if (stickJoint != null && stickJoint.JointTranslation < 0.01f)
|
||||||
{
|
{
|
||||||
if (stickTarget != null)
|
if (stickTarget != null)
|
||||||
@@ -174,6 +178,8 @@ namespace Barotrauma.Items.Components
|
|||||||
ApplyStatusEffects(ActionType.OnUse, 1.0f);
|
ApplyStatusEffects(ActionType.OnUse, 1.0f);
|
||||||
ApplyStatusEffects(ActionType.OnImpact, 1.0f);
|
ApplyStatusEffects(ActionType.OnImpact, 1.0f);
|
||||||
|
|
||||||
|
IsActive = false;
|
||||||
|
|
||||||
item.body.FarseerBody.OnCollision -= OnProjectileCollision;
|
item.body.FarseerBody.OnCollision -= OnProjectileCollision;
|
||||||
|
|
||||||
item.body.FarseerBody.IsBullet = false;
|
item.body.FarseerBody.IsBullet = false;
|
||||||
|
|||||||
@@ -63,9 +63,10 @@ namespace Barotrauma
|
|||||||
protected int selectedSlot = -1;
|
protected int selectedSlot = -1;
|
||||||
|
|
||||||
protected InventorySlot[] slots;
|
protected InventorySlot[] slots;
|
||||||
|
|
||||||
public Item[] Items;
|
public Item[] Items;
|
||||||
|
|
||||||
|
private bool isSubInventory;
|
||||||
|
|
||||||
public bool Locked;
|
public bool Locked;
|
||||||
|
|
||||||
public Vector2 CenterPos
|
public Vector2 CenterPos
|
||||||
@@ -234,9 +235,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update(float deltaTime)
|
public virtual void Update(float deltaTime, bool subInventory = false)
|
||||||
{
|
{
|
||||||
if (slots == null) CreateSlots();
|
if (slots == null || isSubInventory != subInventory)
|
||||||
|
{
|
||||||
|
CreateSlots();
|
||||||
|
isSubInventory = subInventory;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
@@ -261,17 +266,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Draw(SpriteBatch spriteBatch)
|
public virtual void Draw(SpriteBatch spriteBatch, bool subInventory = false)
|
||||||
{
|
{
|
||||||
string toolTip = "";
|
string toolTip = "";
|
||||||
|
|
||||||
if (slots == null) CreateSlots();
|
if (slots == null || isSubInventory != subInventory) return;
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
if (slots[i].Disabled) continue;
|
if (slots[i].Disabled) continue;
|
||||||
|
|
||||||
//don't draw the slot if dragged an item out of it
|
//don't draw the item if it's being dragged out of the slot
|
||||||
bool drawItem = draggingItem == null || draggingItem != Items[i] || slots[i].IsHighlighted;
|
bool drawItem = draggingItem == null || draggingItem != Items[i] || slots[i].IsHighlighted;
|
||||||
|
|
||||||
DrawSlot(spriteBatch, slots[i], Items[i], drawItem);
|
DrawSlot(spriteBatch, slots[i], Items[i], drawItem);
|
||||||
@@ -373,9 +378,26 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (container.Inventory.slots == null) container.Inventory.CreateSlots();
|
if (container.Inventory.slots == null) container.Inventory.CreateSlots();
|
||||||
|
|
||||||
|
int itemCapacity = container.Capacity;
|
||||||
|
|
||||||
|
var slot = slots[slotIndex];
|
||||||
|
Rectangle containerRect = new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
||||||
|
slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10);
|
||||||
|
|
||||||
|
Rectangle subRect = slot.Rect;
|
||||||
|
subRect.Height = 40;
|
||||||
|
|
||||||
|
for (int i = 0; i < itemCapacity; i++)
|
||||||
|
{
|
||||||
|
subRect.Y = subRect.Y - subRect.Height - 10;
|
||||||
|
container.Inventory.slots[i].Rect = subRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.Inventory.isSubInventory = true;
|
||||||
|
|
||||||
slots[slotIndex].State = GUIComponent.ComponentState.Hover;
|
slots[slotIndex].State = GUIComponent.ComponentState.Hover;
|
||||||
|
|
||||||
container.Inventory.Update(deltaTime);
|
container.Inventory.Update(deltaTime, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSubInventory(SpriteBatch spriteBatch, int slotIndex)
|
public void DrawSubInventory(SpriteBatch spriteBatch, int slotIndex)
|
||||||
@@ -386,8 +408,7 @@ namespace Barotrauma
|
|||||||
var container = item.GetComponent<ItemContainer>();
|
var container = item.GetComponent<ItemContainer>();
|
||||||
if (container == null) return;
|
if (container == null) return;
|
||||||
|
|
||||||
if (container.Inventory.slots == null) container.Inventory.CreateSlots();
|
if (container.Inventory.slots == null || !container.Inventory.isSubInventory) return;
|
||||||
|
|
||||||
|
|
||||||
int itemCapacity = container.Capacity;
|
int itemCapacity = container.Capacity;
|
||||||
|
|
||||||
@@ -401,19 +422,10 @@ namespace Barotrauma
|
|||||||
Rectangle containerRect = new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
Rectangle containerRect = new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
||||||
slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10);
|
slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10);
|
||||||
|
|
||||||
Rectangle subRect = slot.Rect;
|
|
||||||
subRect.Height = 40;
|
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle(containerRect.X, containerRect.Y, containerRect.Width, containerRect.Height - slot.Rect.Height - 5), Color.Black * 0.8f, true);
|
GUI.DrawRectangle(spriteBatch, new Rectangle(containerRect.X, containerRect.Y, containerRect.Width, containerRect.Height - slot.Rect.Height - 5), Color.Black * 0.8f, true);
|
||||||
GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
|
GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
|
||||||
|
|
||||||
for (int i = 0; i < itemCapacity; i++)
|
container.Inventory.Draw(spriteBatch, true);
|
||||||
{
|
|
||||||
subRect.Y = subRect.Y - subRect.Height - 10;
|
|
||||||
container.Inventory.slots[i].Rect = subRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.Inventory.Draw(spriteBatch);
|
|
||||||
|
|
||||||
if (!containerRect.Contains(PlayerInput.MousePosition))
|
if (!containerRect.Contains(PlayerInput.MousePosition))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -703,6 +703,8 @@ namespace Barotrauma
|
|||||||
inWater = IsInWater();
|
inWater = IsInWater();
|
||||||
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
|
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
|
||||||
|
|
||||||
|
isHighlighted = false;
|
||||||
|
|
||||||
if (body == null || !body.Enabled) return;
|
if (body == null || !body.Enabled) return;
|
||||||
|
|
||||||
if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f)
|
if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f)
|
||||||
@@ -881,7 +883,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!editing || (body != null && !body.Enabled))
|
if (!editing || (body != null && !body.Enabled))
|
||||||
{
|
{
|
||||||
isHighlighted = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ namespace Barotrauma
|
|||||||
Item.UpdateHulls();
|
Item.UpdateHulls();
|
||||||
Gap.UpdateHulls();
|
Gap.UpdateHulls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surface = rect.Y - rect.Height + Volume / rect.Width;
|
||||||
|
Pressure = surface;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +319,9 @@ namespace Barotrauma
|
|||||||
Item.UpdateHulls();
|
Item.UpdateHulls();
|
||||||
Gap.UpdateHulls();
|
Gap.UpdateHulls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surface = rect.Y - rect.Height + Volume / rect.Width;
|
||||||
|
Pressure = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Remove()
|
public override void Remove()
|
||||||
@@ -402,17 +408,13 @@ namespace Barotrauma
|
|||||||
float strongestFlow = 0.0f;
|
float strongestFlow = 0.0f;
|
||||||
foreach (Gap gap in ConnectedGaps)
|
foreach (Gap gap in ConnectedGaps)
|
||||||
{
|
{
|
||||||
float gapFlow = gap.LerpedFlowForce.Length();
|
if (gap.IsRoomToRoom)
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
var asd = MapEntity.FindEntityByID(gap.ID);
|
|
||||||
|
|
||||||
if (asd != gap)
|
|
||||||
{
|
{
|
||||||
int adslkmfdlasfk = 9;
|
//only the first linked hull plays the flow sound
|
||||||
|
if (gap.linkedTo[1] == this) continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
float gapFlow = gap.LerpedFlowForce.Length();
|
||||||
|
|
||||||
if (gapFlow > strongestFlow)
|
if (gapFlow > strongestFlow)
|
||||||
{
|
{
|
||||||
@@ -420,8 +422,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strongestFlow > 1.0f)
|
||||||
if (strongestFlow>0.1f)
|
|
||||||
{
|
{
|
||||||
soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f);
|
soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f);
|
||||||
soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f);
|
soundVolume = MathHelper.Clamp(soundVolume, 0.0f, 1.0f);
|
||||||
@@ -438,8 +439,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentFlowSound = flowSound;
|
currentFlowSound = flowSound;
|
||||||
|
soundIndex = currentFlowSound.Loop(soundIndex, soundVolume, WorldPosition, Math.Min(strongestFlow*5.0f, 2000.0f));
|
||||||
soundIndex = currentFlowSound.Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -492,11 +492,9 @@ namespace Barotrauma
|
|||||||
waveVel[i] = waveVel[i] * -0.5f;
|
waveVel[i] = waveVel[i] * -0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//acceleration
|
//acceleration
|
||||||
float a = -WaveStiffness * waveY[i] - waveVel[i] * WaveDampening;
|
float a = -WaveStiffness * waveY[i] - waveVel[i] * WaveDampening;
|
||||||
waveVel[i] = waveVel[i] + a;
|
waveVel[i] = waveVel[i] + a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 2; j++)
|
for (int j = 0; j < 2; j++)
|
||||||
@@ -517,15 +515,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//interpolate the position of the rendered surface towards the "target surface"
|
||||||
|
surface = Math.Max(MathHelper.Lerp(surface, surfaceY, deltaTime*10.0f), rect.Y - rect.Height);
|
||||||
|
|
||||||
if (volume < FullVolume)
|
if (volume < FullVolume)
|
||||||
{
|
{
|
||||||
LethalPressure -= 10.0f * deltaTime;
|
LethalPressure -= 10.0f * deltaTime;
|
||||||
if (Volume == 0.0f)
|
if (Volume == 0.0f)
|
||||||
{
|
{
|
||||||
|
//wait for the surface to be lerped back to bottom and the waves to settle until disabling update
|
||||||
|
if (surface > rect.Y - rect.Height + 1) return;
|
||||||
for (int i = 1; i < waveY.Length - 1; i++)
|
for (int i = 1; i < waveY.Length - 1; i++)
|
||||||
{
|
{
|
||||||
if (waveY[i] > 0.1f) return;
|
if (waveY[i] > 0.1f) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
update = false;
|
update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,7 +569,7 @@ namespace Barotrauma
|
|||||||
if (!Visible)
|
if (!Visible)
|
||||||
{
|
{
|
||||||
drawRect =
|
drawRect =
|
||||||
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Vector2(drawRect.X, -drawRect.Y),
|
new Vector2(drawRect.X, -drawRect.Y),
|
||||||
@@ -586,11 +590,11 @@ namespace Barotrauma
|
|||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Vector2(drawRect.X, -drawRect.Y),
|
new Vector2(drawRect.X, -drawRect.Y),
|
||||||
new Vector2(rect.Width, rect.Height),
|
new Vector2(rect.Width, rect.Height),
|
||||||
Color.Blue,false,0, (int)Math.Max((1.5f / Screen.Selected.Cam.Zoom), 1.0f));
|
Color.Blue, false, 0, (int)Math.Max((1.5f / Screen.Selected.Cam.Zoom), 1.0f));
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
|
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
|
||||||
Color.Red*((100.0f-OxygenPercentage)/400.0f), true,0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
Color.Red * ((100.0f - OxygenPercentage) / 400.0f), true, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||||
|
|
||||||
if (GameMain.DebugDraw)
|
if (GameMain.DebugDraw)
|
||||||
{
|
{
|
||||||
@@ -605,18 +609,10 @@ namespace Barotrauma
|
|||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Vector2(drawRect.X + 5, -drawRect.Y + 5),
|
new Vector2(drawRect.X + 5, -drawRect.Y + 5),
|
||||||
new Vector2(rect.Width - 10, rect.Height - 10),
|
new Vector2(rect.Width - 10, rect.Height - 10),
|
||||||
isHighlighted ? Color.LightBlue*0.5f : Color.Red*0.5f, true,0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
isHighlighted ? Color.LightBlue * 0.5f : Color.Red * 0.5f, true, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetSurfaceY()
|
|
||||||
{
|
|
||||||
float top = rect.Y + Submarine.DrawPosition.Y;
|
|
||||||
float bottom = top - rect.Height;
|
|
||||||
|
|
||||||
return bottom + Volume / rect.Width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Render(GraphicsDevice graphicsDevice, Camera cam)
|
public void Render(GraphicsDevice graphicsDevice, Camera cam)
|
||||||
{
|
{
|
||||||
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
|
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
|
||||||
@@ -626,10 +622,7 @@ namespace Barotrauma
|
|||||||
//calculate where the surface should be based on the water volume
|
//calculate where the surface should be based on the water volume
|
||||||
float top = rect.Y + submarinePos.Y;
|
float top = rect.Y + submarinePos.Y;
|
||||||
float bottom = top - rect.Height;
|
float bottom = top - rect.Height;
|
||||||
float surfaceY = bottom + Volume / rect.Width;
|
|
||||||
|
|
||||||
//interpolate the position of the rendered surface towards the "target surface"
|
|
||||||
surface = surface + ((surfaceY - submarinePos.Y) - surface) / 10.0f;
|
|
||||||
float drawSurface = surface + submarinePos.Y;
|
float drawSurface = surface + submarinePos.Y;
|
||||||
|
|
||||||
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||||
|
|||||||
@@ -814,6 +814,11 @@ namespace Barotrauma
|
|||||||
WrappingWall.UpdateWallShift(Submarine.MainSub.WorldPosition, wrappingWalls);
|
WrappingWall.UpdateWallShift(Submarine.MainSub.WorldPosition, wrappingWalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Hull.renderer != null)
|
||||||
|
{
|
||||||
|
Hull.renderer.ScrollWater((float)deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.Update(deltaTime);
|
renderer.Update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -309,6 +309,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
crackColor = Color.Red;
|
crackColor = Color.Red;
|
||||||
}
|
}
|
||||||
|
else if (highlightedLocation != currentLocation &&
|
||||||
|
(connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(currentLocation)))
|
||||||
|
{
|
||||||
|
crackColor = Color.Red * 0.5f;
|
||||||
|
}
|
||||||
else if (!connection.Passed)
|
else if (!connection.Passed)
|
||||||
{
|
{
|
||||||
crackColor *= 0.2f;
|
crackColor *= 0.2f;
|
||||||
|
|||||||
@@ -986,7 +986,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
for (int i = 0; i < extraCargo[s]; i++)
|
for (int i = 0; i < extraCargo[s]; i++)
|
||||||
{
|
{
|
||||||
Item.Spawner.QueueItem(itemPrefab, position, sub, false);
|
Item.Spawner.QueueItem(itemPrefab, position + (Vector2.UnitX * itemPrefab.Size.Y/2), sub, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Barotrauma.Particles
|
|||||||
|
|
||||||
public readonly float VelocityMin, VelocityMax;
|
public readonly float VelocityMin, VelocityMax;
|
||||||
|
|
||||||
|
public readonly float ScaleMin, ScaleMax;
|
||||||
|
|
||||||
public readonly float ParticleAmount;
|
public readonly float ParticleAmount;
|
||||||
|
|
||||||
public ParticleEmitterPrefab(XElement element)
|
public ParticleEmitterPrefab(XElement element)
|
||||||
@@ -37,6 +39,17 @@ namespace Barotrauma.Particles
|
|||||||
AngleMin = MathHelper.ToRadians(AngleMin);
|
AngleMin = MathHelper.ToRadians(AngleMin);
|
||||||
AngleMax = MathHelper.ToRadians(AngleMax);
|
AngleMax = MathHelper.ToRadians(AngleMax);
|
||||||
|
|
||||||
|
if (element.Attribute("scalemin")==null)
|
||||||
|
{
|
||||||
|
ScaleMin = 1.0f;
|
||||||
|
ScaleMax = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ScaleMin = ToolBox.GetAttributeFloat(element,"scalemin",1.0f);
|
||||||
|
ScaleMax = Math.Max(ScaleMin, ToolBox.GetAttributeFloat(element, "scalemax", 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
if (element.Attribute("velocity") == null)
|
if (element.Attribute("velocity") == null)
|
||||||
{
|
{
|
||||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
|
VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
|
||||||
@@ -58,7 +71,12 @@ namespace Barotrauma.Particles
|
|||||||
float angle = Rand.Range(AngleMin, AngleMax);
|
float angle = Rand.Range(AngleMin, AngleMax);
|
||||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax);
|
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax);
|
||||||
|
|
||||||
GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, 0.0f, hullGuess);
|
var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, 0.0f, hullGuess);
|
||||||
|
|
||||||
|
if (particle!=null)
|
||||||
|
{
|
||||||
|
particle.Size *= Rand.Range(ScaleMin, ScaleMax);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,13 +166,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
cam.UpdateTransform(true);
|
cam.UpdateTransform(true);
|
||||||
|
|
||||||
if (Hull.renderer != null)
|
|
||||||
{
|
|
||||||
Hull.renderer.ScrollWater((float)deltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
//damageStencil = TextureLoader.FromFile("Content/Map/background.png");
|
|
||||||
|
|
||||||
DrawMap(graphics, spriteBatch);
|
DrawMap(graphics, spriteBatch);
|
||||||
|
|
||||||
spriteBatch.Begin();
|
spriteBatch.Begin();
|
||||||
|
|||||||
@@ -330,10 +330,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GUIComponent child = selectedItemList.children[i];
|
GUIComponent child = selectedItemList.children[i];
|
||||||
|
|
||||||
MapEntityPrefab ep = child.UserData as MapEntityPrefab;
|
ItemPrefab ip = child.UserData as ItemPrefab;
|
||||||
if (ep == null) continue;
|
if (ip == null) continue;
|
||||||
|
|
||||||
gameMode.CargoManager.AddItem(ep);
|
gameMode.CargoManager.AddItem(ip);
|
||||||
|
|
||||||
selectedItemList.RemoveChild(child);
|
selectedItemList.RemoveChild(child);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,16 +417,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
string saveTime = ToolBox.GetAttributeString(doc.Root, "savetime", "unknown");
|
string saveTime = ToolBox.GetAttributeString(doc.Root, "savetime", "unknown");
|
||||||
|
|
||||||
XElement modeElement = null;
|
string mapseed = ToolBox.GetAttributeString(doc.Root, "mapseed", "unknown");
|
||||||
foreach (XElement element in doc.Root.Elements())
|
|
||||||
{
|
|
||||||
if (element.Name.ToString().ToLowerInvariant() != "gamemode") continue;
|
|
||||||
|
|
||||||
modeElement = element;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
string mapseed = ToolBox.GetAttributeString(modeElement, "mapseed", "unknown");
|
|
||||||
|
|
||||||
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 0, 200, 230), Color.Black*0.4f, GUI.Style, menuTabs[(int)Tab.LoadGame]);
|
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 0, 200, 230), Color.Black*0.4f, GUI.Style, menuTabs[(int)Tab.LoadGame]);
|
||||||
saveFileFrame.UserData = "savefileframe";
|
saveFileFrame.UserData = "savefileframe";
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Barotrauma.Sounds
|
|||||||
private static readonly int[] alBuffers = new int[DefaultSourceCount];
|
private static readonly int[] alBuffers = new int[DefaultSourceCount];
|
||||||
private static int lowpassFilterId;
|
private static int lowpassFilterId;
|
||||||
|
|
||||||
|
private static readonly Sound[] soundsPlaying = new Sound[DefaultSourceCount];
|
||||||
|
|
||||||
private static AudioContext AC;
|
private static AudioContext AC;
|
||||||
|
|
||||||
private static OggStreamer oggStreamer;
|
private static OggStreamer oggStreamer;
|
||||||
@@ -47,112 +49,33 @@ namespace Barotrauma.Sounds
|
|||||||
|
|
||||||
LowPassHFGain = 1.0f;
|
LowPassHFGain = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//public SoundManager(int bufferCount = DefaultSourceCount)
|
|
||||||
//{
|
|
||||||
// Stopwatch sw = new Stopwatch();
|
|
||||||
// sw.Start();
|
|
||||||
|
|
||||||
// alSourceId = AL.GenSource();
|
|
||||||
// //AL.Source(alSourceId, ALSourcei.Buffer, alBufferId);
|
|
||||||
|
|
||||||
// Volume = 1;
|
|
||||||
|
|
||||||
// if (ALHelper.Efx.IsInitialized)
|
|
||||||
// {
|
|
||||||
// alFilterId = ALHelper.Efx.GenFilter();
|
|
||||||
// ALHelper.Efx.Filter(alFilterId, EfxFilteri.FilterType, (int)EfxFilterType.Lowpass);
|
|
||||||
// ALHelper.Efx.Filter(alFilterId, EfxFilterf.LowpassGain, 1);
|
|
||||||
// LowPassHFGain = 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// sw.Stop();
|
|
||||||
// System.Diagnostics.Debug.WriteLine("oggsource: "+sw.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
// public static int Play(Sound sound, float volume = 1.0f)
|
|
||||||
// {
|
|
||||||
// return Play(sound, volume, new Vector2(0.0f, 0.0f));
|
|
||||||
//}
|
|
||||||
|
|
||||||
public static int Play(Sound sound, float volume = 1.0f)
|
public static int Play(Sound sound, float volume = 1.0f)
|
||||||
{
|
{
|
||||||
return Play(sound, Vector2.Zero, volume, 0.0f);
|
return Play(sound, Vector2.Zero, volume, 0.0f);
|
||||||
//for (int i = 2; i < DefaultSourceCount; i++)
|
|
||||||
//{
|
|
||||||
// AL.SourceStop(alSources[i]);
|
|
||||||
// AL.Source(alSources[i], ALSourceb.Looping, false);
|
|
||||||
// System.Diagnostics.Debug.WriteLine(i + ": " + AL.GetSourceState(alSources[i]));
|
|
||||||
// System.Diagnostics.Debug.WriteLine(AL.GetSourceType(alSources[i]));
|
|
||||||
//}
|
|
||||||
|
|
||||||
//for (int i = 1; i < DefaultSourceCount; i++)
|
|
||||||
//{
|
|
||||||
// //find a source that's free to use (not playing or paused)
|
|
||||||
// if (AL.GetSourceState(alSources[i]) == ALSourceState.Playing
|
|
||||||
// || AL.GetSourceState(alSources[i]) == ALSourceState.Paused) continue;
|
|
||||||
|
|
||||||
// //if (position!=Vector2.Zero)
|
|
||||||
// // position /= 1000.0f;
|
|
||||||
|
|
||||||
// alBuffers[i]=sound.AlBufferId;
|
|
||||||
// AL.Source(alSources[i], ALSourceb.Looping, false);
|
|
||||||
// AL.Source(alSources[i], ALSource3f.Position, 0.0f, 0.0f, 0.0f);
|
|
||||||
// AL.Source(alSources[i], ALSourcei.Buffer, sound.AlBufferId);
|
|
||||||
// AL.Source(alSources[i], ALSourcef.Gain, volume);
|
|
||||||
// //AL.Source(alSources[i], ALSource3f.Position, position.X, position.Y, 0.0f);
|
|
||||||
// AL.SourcePlay(alSources[i]);
|
|
||||||
|
|
||||||
// //sound.sourceIndex = i;
|
|
||||||
|
|
||||||
// return i;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int Play(Sound sound, Vector2 position, float volume = 1.0f, float lowPassGain = 0.0f, bool loop=false)
|
public static int Play(Sound sound, Vector2 position, float volume = 1.0f, float lowPassGain = 0.0f, bool loop=false)
|
||||||
{
|
{
|
||||||
//for (int i = 2; i < DefaultSourceCount; i++)
|
|
||||||
//{
|
|
||||||
// AL.SourceStop(alSources[i]);
|
|
||||||
// AL.Source(alSources[i], ALSourceb.Looping, false);
|
|
||||||
// System.Diagnostics.Debug.WriteLine(i + ": " + AL.GetSourceState(alSources[i]));
|
|
||||||
// System.Diagnostics.Debug.WriteLine(AL.GetSourceType(alSources[i]));
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 1; i < DefaultSourceCount; i++)
|
for (int i = 1; i < DefaultSourceCount; i++)
|
||||||
{
|
{
|
||||||
//find a source that's free to use (not playing or paused)
|
//find a source that's free to use (not playing or paused)
|
||||||
if (OpenTK.Audio.OpenAL.AL.GetSourceState(alSources[i]) == OpenTK.Audio.OpenAL.ALSourceState.Playing
|
if (OpenTK.Audio.OpenAL.AL.GetSourceState(alSources[i]) == OpenTK.Audio.OpenAL.ALSourceState.Playing
|
||||||
|| OpenTK.Audio.OpenAL.AL.GetSourceState(alSources[i]) == OpenTK.Audio.OpenAL.ALSourceState.Paused) continue;
|
|| OpenTK.Audio.OpenAL.AL.GetSourceState(alSources[i]) == OpenTK.Audio.OpenAL.ALSourceState.Paused) continue;
|
||||||
|
|
||||||
//if (position!=Vector2.Zero)
|
soundsPlaying[i] = sound;
|
||||||
// position /= 1000.0f;
|
|
||||||
|
|
||||||
alBuffers[i] = sound.AlBufferId;
|
alBuffers[i] = sound.AlBufferId;
|
||||||
OpenTK.Audio.OpenAL.AL.Source(alSources[i], OpenTK.Audio.OpenAL.ALSourceb.Looping, loop);
|
OpenTK.Audio.OpenAL.AL.Source(alSources[i], OpenTK.Audio.OpenAL.ALSourceb.Looping, loop);
|
||||||
|
|
||||||
OpenTK.Audio.OpenAL.AL.Source(alSources[i], OpenTK.Audio.OpenAL.ALSourcei.Buffer, sound.AlBufferId);
|
OpenTK.Audio.OpenAL.AL.Source(alSources[i], OpenTK.Audio.OpenAL.ALSourcei.Buffer, sound.AlBufferId);
|
||||||
|
|
||||||
|
|
||||||
UpdateSoundPosition(i, position, volume);
|
UpdateSoundPosition(i, position, volume);
|
||||||
|
|
||||||
//AL.Source(alSources[i], ALSource3f.Position, position.X, position.Y, 0.0f);
|
|
||||||
OpenTK.Audio.OpenAL.AL.SourcePlay(alSources[i]);
|
OpenTK.Audio.OpenAL.AL.SourcePlay(alSources[i]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//sound.sourceIndex = i;
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,44 +97,17 @@ namespace Barotrauma.Sounds
|
|||||||
if (sourceIndex<1)
|
if (sourceIndex<1)
|
||||||
{
|
{
|
||||||
sourceIndex = Play(sound, position, volume, 0.0f, true);
|
sourceIndex = Play(sound, position, volume, 0.0f, true);
|
||||||
//if (sourceIndex>0)
|
|
||||||
//{
|
|
||||||
// AL.Source(alSources[sourceIndex], ALSourceb.Looping, true);
|
|
||||||
// AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateSoundPosition(sourceIndex, position, volume);
|
UpdateSoundPosition(sourceIndex, position, volume);
|
||||||
|
|
||||||
//position /= 1000.0f;
|
|
||||||
|
|
||||||
//OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSource3f.Position, position.X, position.Y, 0.0f);
|
|
||||||
AL.Source(alSources[sourceIndex], ALSourceb.Looping, true);
|
AL.Source(alSources[sourceIndex], ALSourceb.Looping, true);
|
||||||
//AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ALHelper.Check();
|
ALHelper.Check();
|
||||||
return sourceIndex;
|
return sourceIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static int Loop(int sourceIndex, float volume = 1.0f)
|
|
||||||
//{
|
|
||||||
|
|
||||||
// if (sourceIndex > 0 && alSources[sourceIndex]>0)
|
|
||||||
// {
|
|
||||||
// ALSourceState state = AL.GetSourceState(alSources[sourceIndex]);
|
|
||||||
// ALHelper.Check();
|
|
||||||
// if (state == ALSourceState.Playing) return sourceIndex;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int newSourceIndex = Play(sound, volume);
|
|
||||||
// AL.Source(alSources[sourceIndex], ALSourceb.Looping, true);
|
|
||||||
|
|
||||||
// return sourceIndex;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public static void Pause(int sourceIndex)
|
public static void Pause(int sourceIndex)
|
||||||
{
|
{
|
||||||
if (AL.GetSourceState(alSources[sourceIndex]) != ALSourceState.Playing)
|
if (AL.GetSourceState(alSources[sourceIndex]) != ALSourceState.Playing)
|
||||||
@@ -239,9 +135,21 @@ namespace Barotrauma.Sounds
|
|||||||
{
|
{
|
||||||
AL.SourceStop(alSources[sourceIndex]);
|
AL.SourceStop(alSources[sourceIndex]);
|
||||||
AL.Source(alSources[sourceIndex], ALSourceb.Looping, false);
|
AL.Source(alSources[sourceIndex], ALSourceb.Looping, false);
|
||||||
|
|
||||||
|
soundsPlaying[sourceIndex] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Sound GetPlayingSound(int sourceIndex)
|
||||||
|
{
|
||||||
|
if (sourceIndex < 1 || sourceIndex>alSources.Count-1) return null;
|
||||||
|
|
||||||
|
if (AL.GetSourceState(alSources[sourceIndex]) != ALSourceState.Playing) return null;
|
||||||
|
|
||||||
|
return soundsPlaying[sourceIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool IsPlaying(int sourceIndex)
|
public static bool IsPlaying(int sourceIndex)
|
||||||
{
|
{
|
||||||
if (sourceIndex < 1 || sourceIndex>alSources.Count-1) return false;
|
if (sourceIndex < 1 || sourceIndex>alSources.Count-1) return false;
|
||||||
@@ -249,14 +157,23 @@ namespace Barotrauma.Sounds
|
|||||||
return (state == ALSourceState.Playing);
|
return (state == ALSourceState.Playing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsLooping(int sourceIndex)
|
||||||
|
{
|
||||||
|
if (sourceIndex < 1 || sourceIndex > alSources.Count - 1) return false;
|
||||||
|
|
||||||
|
bool isLooping;
|
||||||
|
|
||||||
|
OpenTK.Audio.OpenAL.AL.GetSource(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSourceb.Looping, out isLooping);
|
||||||
|
|
||||||
|
return isLooping;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Volume(int sourceIndex, float volume)
|
public static void Volume(int sourceIndex, float volume)
|
||||||
{
|
{
|
||||||
AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume * MasterVolume);
|
AL.Source(alSources[sourceIndex], ALSourcef.Gain, volume * MasterVolume);
|
||||||
ALHelper.Check();
|
ALHelper.Check();
|
||||||
}
|
}
|
||||||
|
|
||||||
//int alFilterId;
|
|
||||||
|
|
||||||
static float lowPassHfGain;
|
static float lowPassHfGain;
|
||||||
public static float LowPassHFGain
|
public static float LowPassHFGain
|
||||||
{
|
{
|
||||||
@@ -281,16 +198,6 @@ namespace Barotrauma.Sounds
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//float volume;
|
|
||||||
//public float Volume
|
|
||||||
//{
|
|
||||||
// get { return volume; }
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// AL.Source(alSourceId, ALSourcef.Gain, volume = value);
|
|
||||||
// ALHelper.Check();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public static void UpdateSoundPosition(int sourceIndex, Vector2 position, float baseVolume = 1.0f)
|
public static void UpdateSoundPosition(int sourceIndex, Vector2 position, float baseVolume = 1.0f)
|
||||||
{
|
{
|
||||||
@@ -301,9 +208,7 @@ namespace Barotrauma.Sounds
|
|||||||
position = Vector2.Zero;
|
position = Vector2.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resume(sourceIndex);
|
position /= 1000.0f;
|
||||||
|
|
||||||
position/= 1000.0f;
|
|
||||||
|
|
||||||
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSourcef.Gain, baseVolume * MasterVolume);
|
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSourcef.Gain, baseVolume * MasterVolume);
|
||||||
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSource3f.Position, position.X, position.Y, 0.0f);
|
OpenTK.Audio.OpenAL.AL.Source(alSources[sourceIndex], OpenTK.Audio.OpenAL.ALSource3f.Position, position.X, position.Y, 0.0f);
|
||||||
@@ -313,8 +218,6 @@ namespace Barotrauma.Sounds
|
|||||||
ALHelper.Efx.Filter(lowpassFilterId, OpenTK.Audio.OpenAL.EfxFilterf.LowpassGainHF, lowPassGain);
|
ALHelper.Efx.Filter(lowpassFilterId, OpenTK.Audio.OpenAL.EfxFilterf.LowpassGainHF, lowPassGain);
|
||||||
ALHelper.Efx.BindFilterToSource(alSources[sourceIndex], lowpassFilterId);
|
ALHelper.Efx.BindFilterToSource(alSources[sourceIndex], lowpassFilterId);
|
||||||
ALHelper.Check();
|
ALHelper.Check();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OggStream StartStream(string file, float volume = 1.0f)
|
public static OggStream StartStream(string file, float volume = 1.0f)
|
||||||
|
|||||||
Reference in New Issue
Block a user