Merge pull request #188 from Crystalwarrior/moStuff

Motion detectors, ducts, more chem effects and chems, fabricator/deconstructor overhaul, more footsteps, clown hitsounds...
This commit is contained in:
Joonas Rikkonen
2018-01-09 12:11:15 +02:00
committed by GitHub
69 changed files with 1411 additions and 539 deletions
@@ -1,4 +1,5 @@
using FarseerPhysics;
using Barotrauma.Items.Components;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
@@ -20,7 +21,12 @@ namespace Barotrauma
if (impact > 3.0f && limb.HitSound != null && limb.SoundTimer <= 0.0f)
{
limb.SoundTimer = Limb.SoundInterval;
limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
SoundPlayer.PlaySound(limb.HitSound, volume, impact * 100.0f, limb.WorldPosition);
foreach(WearableSprite wearable in limb.WearingItems)
{
if (limb.type == wearable.Limb && wearable.Sound != null)
SoundPlayer.PlaySound(wearable.Sound, volume, impact * 100.0f, limb.WorldPosition);
}
}
}
else if (body.UserData is Limb || body == Collider.FarseerBody)
@@ -29,7 +35,7 @@ namespace Barotrauma
{
if (impact > ImpactTolerance)
{
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, Collider);
SoundPlayer.PlayDamageSound("LimbBlunt", strongestImpact, Collider);
}
}
@@ -19,7 +19,7 @@ namespace Barotrauma
private Sound hitSound;
public Sound HitSound
public string HitSound
{
get { return hitSound; }
}
@@ -34,7 +34,7 @@ namespace Barotrauma
LightSource = new LightSource(subElement);
break;
case "sound":
hitSound = Sound.Load(subElement.GetAttributeString("file", ""));
hitSound = subElement.GetAttributeString("file", "");
break;
}
}
@@ -26,7 +26,7 @@ namespace Barotrauma
{
bool singleplayer = GameMain.NetworkMember == null;
bool gameOver = gameSession.CrewManager.GetCharacters().All(c => c.IsDead);
bool gameOver = gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsUnconscious);
bool progress = Submarine.MainSub.AtEndPosition;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f, null);
@@ -36,19 +36,23 @@ namespace Barotrauma
int y = 0;
if (singleplayer)
if (!singleplayer)
{
string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :
(progress ? "RoundSummaryProgress" : "RoundSummaryReturn"));
summaryText = summaryText
.Replace("[sub]", Submarine.MainSub.Name)
.Replace("[location]", GameMain.GameSession.StartLocation.Name);
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, "", innerFrame, true);
y += infoText.Rect.Height;
//Game over if everyone dead or didn't progress
gameOver = gameOver || !progress;
SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround";
}
string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :
(progress ? "RoundSummaryProgress" : "RoundSummaryReturn"));
summaryText = summaryText
.Replace("[sub]", Submarine.MainSub.Name)
.Replace("[location]", GameMain.GameSession.StartLocation.Name);
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, "", innerFrame, true);
y += infoText.Rect.Height;
if (!string.IsNullOrWhiteSpace(endMessage))
{
var endText = new GUITextBlock(new Rectangle(0, y, 0, 30), endMessage, "", innerFrame, true);
@@ -143,6 +143,10 @@ namespace Barotrauma
{
wasPut = character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true);
}
else if (character.SelectedBy != null && Character.Controlled == character.SelectedBy && character.SelectedBy.Inventory != null)
{
wasPut = character.SelectedBy.Inventory.TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true);
}
else //doubleclicked and no other inventory is selected
{
//not equipped -> attempt to equip
@@ -111,9 +111,9 @@ namespace Barotrauma.Items.Components
if (!inadequateSkills.Any())
{
text = "Required items:\n";
foreach (Tuple<ItemPrefab, int> ip in targetItem.RequiredItems)
foreach (Tuple<ItemPrefab, int, float, bool> ip in targetItem.RequiredItems)
{
text += " - " + ip.Item1.Name + " x" + ip.Item2 + "\n";
text += " - " + ip.Item1.Name + " x" + ip.Item2 + (ip.Item3 < 1.0f ? ", " + ip.Item3 * 100 + "% condition\n" : "\n");
}
text += "Required time: " + targetItem.RequiredTime + " s";
}
@@ -127,6 +127,7 @@ namespace Barotrauma.Items.Components
if (target.IsDead)
{
texts.Add("Deceased");
texts.Add("Cause of Death: " + target.CauseOfDeath.ToString());
}
else
{
@@ -87,6 +87,10 @@ namespace Barotrauma
DebugConsole.ThrowError("File \"" + file + "\" not found!");
return null;
}
Sound dupe = Sound.loadedSounds.Find(s => s.filePath == file);
if (dupe != null)
return dupe;
return new Sound(file, destroyOnGameEnd);
}
@@ -100,6 +104,9 @@ namespace Barotrauma
{
newSound.baseVolume = element.GetAttributeFloat("volume", 1.0f);
newSound.range = element.GetAttributeFloat("range", 1000.0f);
Sound dupe = Sound.loadedSounds.Find(s => s.filePath == filePath && s.baseVolume == newSound.baseVolume && s.range == newSound.range);
if (dupe != null)
return dupe;
}
return newSound;
@@ -10,26 +10,19 @@ using System.Xml.Linq;
namespace Barotrauma
{
public enum DamageSoundType
{
None,
StructureBlunt, StructureSlash,
LimbBlunt, LimbSlash, LimbArmor
}
public struct DamageSound
{
//the range of inflicted damage where the sound can be played
//(10.0f, 30.0f) would be played when the inflicted damage is between 10 and 30
public readonly Vector2 damageRange;
public readonly DamageSoundType damageType;
public readonly string damageType;
public readonly Sound sound;
public readonly string requiredTag;
public DamageSound(Sound sound, Vector2 damageRange, DamageSoundType damageType, string requiredTag = "")
public DamageSound(Sound sound, Vector2 damageRange, string damageType, string requiredTag = "")
{
this.sound = sound;
this.damageRange = damageRange;
@@ -161,8 +154,7 @@ namespace Barotrauma
Sound damageSound = Sound.Load(subElement.GetAttributeString("file", ""), false);
if (damageSound == null) continue;
DamageSoundType damageSoundType = DamageSoundType.None;
Enum.TryParse<DamageSoundType>(subElement.GetAttributeString("damagesoundtype", "None"), false, out damageSoundType);
string damageSoundType = subElement.GetAttributeString("damagesoundtype", "None");
damageSounds.Add(new DamageSound(
damageSound,
@@ -271,7 +263,7 @@ namespace Barotrauma
public static Sound GetSound(string soundTag)
{
var matchingSounds = miscSounds[soundTag].ToList();
if (matchingSounds.Count == 0) return null;
if (matchingSounds.Count == 0) return Sound.Load(soundTag);
return matchingSounds[Rand.Int(matchingSounds.Count)];
}
@@ -442,14 +434,14 @@ namespace Barotrauma
SplashSounds[splashIndex].Play(1.0f, 800.0f, worldPosition);
}
public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body)
public static void PlayDamageSound(string damageType, float damage, PhysicsBody body)
{
Vector2 bodyPosition = body.DrawPosition;
PlayDamageSound(damageType, damage, bodyPosition, 800.0f);
}
public static void PlayDamageSound(DamageSoundType damageType, float damage, Vector2 position, float range = 2000.0f, List<string> tags = null)
public static void PlayDamageSound(string damageType, float damage, Vector2 position, float range = 2000.0f, List<string> tags = null)
{
damage = MathHelper.Clamp(damage+Rand.Range(-10.0f, 10.0f), 0.0f, 100.0f);
var sounds = damageSounds.FindAll(s =>