Progress + prettier ice walls

This commit is contained in:
Regalis
2015-12-12 13:44:05 +02:00
parent 78bccca4af
commit 17e8a2171f
49 changed files with 479 additions and 273 deletions
+3
View File
@@ -591,6 +591,9 @@
<Content Include="Content\Map\iceSurface.png"> <Content Include="Content\Map\iceSurface.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Map\iceWall.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Map\locationNames.txt"> <Content Include="Content\Map\locationNames.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -15,7 +15,7 @@
<!-- lower yaw --> <!-- lower yaw -->
<limb id = "1" radius="20" height="240" impacttolerance="50.0"> <limb id = "1" radius="20" height="240" impacttolerance="50.0">
<sprite texture="Content/Characters/Coelanth/coelanth.png" sourcerect="425,1,101,309" depth="0.025" origin="0.5,0.5"/> <sprite texture="Content/Characters/Coelanth/coelanth.png" sourcerect="425,1,101,309" depth="0.025" origin="0.5,0.5"/>
<attack type="PinchCCW" range="250" duration="0.5" damage="200" bleedingdamage="50" structuredamage="150" damagetype="slash"/> <attack type="PinchCCW" range="300" duration="0.5" damage="200" bleedingdamage="50" structuredamage="150" damagetype="slash"/>
</limb> </limb>
<!-- body --> <!-- body -->
Binary file not shown.

After

Width:  |  Height:  |  Size: 632 KiB

+5
View File
@@ -174,6 +174,11 @@ namespace Barotrauma
if (PlayerInput.KeyDown(Keys.S)) moveCam.Y -= moveSpeed; if (PlayerInput.KeyDown(Keys.S)) moveCam.Y -= moveSpeed;
if (PlayerInput.KeyDown(Keys.W)) moveCam.Y += moveSpeed; if (PlayerInput.KeyDown(Keys.W)) moveCam.Y += moveSpeed;
if (Submarine.Loaded!=null)
{
moveCam += FarseerPhysics.ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity*deltaTime);
}
moveCam = moveCam * deltaTime * 60.0f; moveCam = moveCam * deltaTime * 60.0f;
} }
@@ -192,6 +192,7 @@ namespace Barotrauma
raycastTimer = RaycastInterval; raycastTimer = RaycastInterval;
} }
steeringManager.SteeringAvoid(deltaTime, 1.0f);
steeringManager.SteeringSeek(attackSimPosition); steeringManager.SteeringSeek(attackSimPosition);
//check if any of the limbs is close enough to attack the target //check if any of the limbs is close enough to attack the target
@@ -322,7 +323,7 @@ namespace Barotrauma
attackTimer += deltaTime; attackTimer += deltaTime;
limb.body.ApplyTorque(limb.Mass * 50.0f * Character.AnimController.Dir * dir); limb.body.ApplyTorque(limb.Mass * 50.0f * Character.AnimController.Dir * dir);
limb.attack.DoDamage(Character, damageTarget, limb.SimPosition, deltaTime, (limb.soundTimer <= 0.0f)); limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, deltaTime, (limb.soundTimer <= 0.0f));
limb.soundTimer = Limb.SoundInterval; limb.soundTimer = Limb.SoundInterval;
} }
@@ -218,7 +218,7 @@ namespace Barotrauma
//a node that hasn't been searched yet //a node that hasn't been searched yet
if (nextNode.state==0) if (nextNode.state==0)
{ {
nextNode.H = Vector2.DistanceSquared(nextNode.Position,end.Position); nextNode.H = Vector2.Distance(nextNode.Position,end.Position);
if (GetNodePenalty != null) if (GetNodePenalty != null)
{ {
@@ -144,11 +144,14 @@ namespace Barotrauma
avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - obstaclePosition); avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - obstaclePosition);
} }
else else if (closestBody.UserData is Item)
{ {
Item item = closestBody.UserData as Item; Item item = closestBody.UserData as Item;
if (item != null) avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - item.SimPosition); avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - item.SimPosition);
}
else
{
avoidSteering = Vector2.Normalize(host.SimPosition - Submarine.LastPickedPosition);
} }
} }
@@ -388,14 +388,14 @@ 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.body.FarseerBody); if (impact > 0.8f && l.HitSound != null && l.soundTimer <= 0.0f) l.HitSound.Play(volume, impact * 100.0f, l.WorldPosition);
if (impact > l.impactTolerance) if (impact > l.impactTolerance)
{ {
character.Health -= (impact - l.impactTolerance * 0.1f); character.Health -= (impact - l.impactTolerance * 0.1f);
strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance); strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance);
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, l.body.FarseerBody); SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, l.body);
if (Character.Controlled == character) GameMain.GameScreen.Cam.Shake = strongestImpact; if (Character.Controlled == character) GameMain.GameScreen.Cam.Shake = strongestImpact;
} }
+4 -4
View File
@@ -122,7 +122,7 @@ namespace Barotrauma
} }
public AttackResult DoDamage(IDamageable attacker, IDamageable target, Vector2 position, float deltaTime, bool playSound = true) public AttackResult DoDamage(IDamageable attacker, IDamageable target, Vector2 worldPosition, float deltaTime, bool playSound = true)
{ {
float damageAmount = 0.0f; float damageAmount = 0.0f;
//DamageSoundType damageSoundType = DamageSoundType.None; //DamageSoundType damageSoundType = DamageSoundType.None;
@@ -139,15 +139,15 @@ namespace Barotrauma
if (particleEmitterPrefab != null) if (particleEmitterPrefab != null)
{ {
particleEmitterPrefab.Emit(position); particleEmitterPrefab.Emit(worldPosition);
} }
if (sound != null) if (sound != null)
{ {
sound.Play(1.0f, 500.0f, position); sound.Play(1.0f, 500.0f, worldPosition);
} }
return target.AddDamage(attacker, position, this, deltaTime, playSound); return target.AddDamage(attacker, worldPosition, this, deltaTime, playSound);
} }
} }
+7 -8
View File
@@ -448,7 +448,7 @@ namespace Barotrauma
} }
} }
AnimController.FindHull(null, false); AnimController.FindHull(null);
if (AnimController.CurrentHull != null) Submarine = AnimController.CurrentHull.Submarine; if (AnimController.CurrentHull != null) Submarine = AnimController.CurrentHull.Submarine;
CharacterList.Add(this); CharacterList.Add(this);
@@ -741,7 +741,7 @@ namespace Barotrauma
{ {
Limb head = AnimController.GetLimb(LimbType.Head); Limb head = AnimController.GetLimb(LimbType.Head);
Lights.LightManager.ViewPos = WorldPosition; Lights.LightManager.ViewPos = DrawPosition;
if (!DisableControls) if (!DisableControls)
{ {
@@ -1010,7 +1010,7 @@ namespace Barotrauma
AnimController.DebugDraw(spriteBatch); AnimController.DebugDraw(spriteBatch);
} }
Vector2 healthBarPos = new Vector2(WorldPosition.X - 50, -WorldPosition.Y - 100.0f); Vector2 healthBarPos = new Vector2(DrawPosition.X - 50, -DrawPosition.Y - 100.0f);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false); GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true); GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true);
} }
@@ -1028,17 +1028,16 @@ namespace Barotrauma
if (soundStates[i] != state) continue; if (soundStates[i] != state) continue;
if (n == selectedSound && sounds[i]!=null) if (n == selectedSound && sounds[i]!=null)
{ {
sounds[i].Play(1.0f, 2000.0f, sounds[i].Play(1.0f, 2000.0f, AnimController.Limbs[0].WorldPosition);
AnimController.Limbs[0].body.FarseerBody);
return; return;
} }
n++; n++;
} }
} }
public virtual AttackResult AddDamage(IDamageable attacker, Vector2 simPosition, Attack attack, float deltaTime, bool playSound = false) public virtual AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
{ {
return AddDamage(simPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound); return AddDamage(worldPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound);
} }
public AttackResult AddDamage(Vector2 simPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound) public AttackResult AddDamage(Vector2 simPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound)
@@ -1103,7 +1102,7 @@ namespace Barotrauma
// limb.Damage = 100.0f; // limb.Damage = 100.0f;
} }
SoundPlayer.PlayDamageSound(DamageSoundType.Implode, 50.0f, AnimController.RefLimb.body.FarseerBody); SoundPlayer.PlayDamageSound(DamageSoundType.Implode, 50.0f, AnimController.RefLimb.body);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
+1 -1
View File
@@ -215,7 +215,7 @@ namespace Barotrauma
if (explosion != null) explosion.Explode(entity.WorldPosition); if (explosion != null) explosion.Explode(entity.WorldPosition);
if (Fire) new FireSource(ConvertUnits.ToDisplayUnits(entity.SimPosition)); if (Fire) new FireSource(ConvertUnits.ToDisplayUnits(entity.SimPosition));
if (sound != null) sound.Play(1.0f, 1000.0f, ConvertUnits.ToDisplayUnits(entity.SimPosition)); if (sound != null) sound.Play(1.0f, 1000.0f, entity.WorldPosition);
for (int i = 0; i < propertyNames.Count(); i++) for (int i = 0; i < propertyNames.Count(); i++)
{ {
+10 -10
View File
@@ -66,18 +66,18 @@ namespace Barotrauma
} }
} }
try //try
{ //{
Coroutines[i].MoveNext(); Coroutines[i].MoveNext();
} // }
catch (Exception e) // catch (Exception e)
{ // {
#if DEBUG //#if DEBUG
DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message); // DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message);
#endif //#endif
Coroutines.RemoveAt(i); // Coroutines.RemoveAt(i);
} // }
} }
} }
+3
View File
@@ -287,6 +287,9 @@ namespace Barotrauma
commands[1] = commands[1].ToLower(); commands[1] = commands[1].ToLower();
Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLower() == commands[1]); Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLower() == commands[1]);
break; break;
case "godmode":
Submarine.Loaded.GodMode = !Submarine.Loaded.GodMode;
break;
case "heal": case "heal":
if (Character.Controlled != null) if (Character.Controlled != null)
{ {
+1 -1
View File
@@ -113,7 +113,7 @@ namespace Barotrauma
{ {
guiFrame.Update(deltaTime); guiFrame.Update(deltaTime);
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.I)) if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.C))
{ {
commander.ToggleGUIFrame(); commander.ToggleGUIFrame();
} }
+2 -2
View File
@@ -262,7 +262,7 @@ namespace Barotrauma.Items.Components
if (Math.Sign(l.SimPosition.X - item.SimPosition.X) != dir) if (Math.Sign(l.SimPosition.X - item.SimPosition.X) != dir)
{ {
l.body.SetTransform(new Vector2(item.SimPosition.X + dir * simSize.X*1.2f, item.SimPosition.Y), l.body.Rotation); l.body.SetTransform(new Vector2(item.SimPosition.X + dir * simSize.X*1.2f, item.SimPosition.Y), l.body.Rotation);
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, 1.0f, l.body.FarseerBody); SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, 1.0f, l.body);
//c.AddDamage(item.SimPosition, DamageType.Blunt, 1.0f, 0.0f, 0.0f, true); //c.AddDamage(item.SimPosition, DamageType.Blunt, 1.0f, 0.0f, 0.0f, true);
l.body.ApplyLinearImpulse(new Vector2(dir * 0.5f, isOpen ? 0.0f : -1.0f)); l.body.ApplyLinearImpulse(new Vector2(dir * 0.5f, isOpen ? 0.0f : -1.0f));
@@ -358,7 +358,7 @@ namespace Barotrauma.Items.Components
else if (connection.Name == "set_state") else if (connection.Name == "set_state")
{ {
bool newState = (signal!="0"); bool newState = (signal!="0");
if (isOpen!=newState) PlaySound(ActionType.OnUse, item.Position); if (isOpen!=newState) PlaySound(ActionType.OnUse, item.WorldPosition);
isOpen = newState; isOpen = newState;
} }
@@ -236,6 +236,8 @@ namespace Barotrauma.Items.Components
AnimController ac = picker.AnimController; AnimController ac = picker.AnimController;
item.Submarine = picker.Submarine;
//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);
@@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components
if (target == null) return false; if (target == null) return false;
if (attack!=null) attack.DoDamage(user, target, item.Position, 1.0f); if (attack!=null) attack.DoDamage(user, target, item.WorldPosition, 1.0f);
RestoreCollision(); RestoreCollision();
hitting = false; hitting = false;
@@ -322,6 +322,8 @@ namespace Barotrauma.Items.Components
if (itemSound.Loop) if (itemSound.Loop)
{ {
loopingSound = itemSound; loopingSound = itemSound;
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range);
} }
else else
{ {
@@ -163,7 +163,7 @@ namespace Barotrauma.Items.Components
if (item.body == null) if (item.body == null)
{ {
transformedItemPos = new Vector2(item.Rect.X, item.Rect.Y); transformedItemPos = new Vector2(item.Rect.X, item.Rect.Y);
if (item.Submarine != null) transformedItemPos += item.Submarine.Position; if (item.Submarine != null) transformedItemPos += item.Submarine.DrawPosition;
transformedItemPos = transformedItemPos + itemPos; transformedItemPos = transformedItemPos + itemPos;
} }
else else
@@ -61,6 +61,7 @@ namespace Barotrauma.Items.Components
{ {
base.Draw(spriteBatch, editing); base.Draw(spriteBatch, editing);
textBlock.Rect = new Rectangle(item.WorldRect.X, -(item.WorldRect.Y - item.Rect.Height/2), item.Rect.Width, item.Rect.Height);
textBlock.Draw(spriteBatch); textBlock.Draw(spriteBatch);
} }
} }
@@ -169,7 +169,7 @@ namespace Barotrauma.Items.Components
{ {
item.SendSignal("1", "signal_out"); item.SendSignal("1", "signal_out");
PlaySound(ActionType.OnUse, item.Position); PlaySound(ActionType.OnUse, item.WorldPosition);
return true; return true;
} }
@@ -116,161 +116,159 @@ namespace Barotrauma.Items.Components
float simScale = 1.5f; float simScale = 1.5f;
return; if (Level.Loaded != null)
{
List<VoronoiCell> cells = Level.Loaded.GetCells(item.WorldPosition, 7);
//if (Level.Loaded != null) foreach (VoronoiCell cell in cells)
//{ {
// List<VoronoiCell> cells = Level.Loaded.GetCells(Submarine.Loaded.Position, 7);
// foreach (VoronoiCell cell in cells) foreach (GraphEdge edge in cell.edges)
// { {
//if (!edge.isSolid) continue;
float cellDot = Vector2.Dot(cell.Center - item.WorldPosition, (edge.point1 + edge.point2) / 2.0f - cell.Center);
//if (cellDot > 0) continue;
// foreach (GraphEdge edge in cell.edges) float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center-item.WorldPosition));
// { facingDot = 1.0f;// MathHelper.Clamp(facingDot, -1.0f, 1.0f);
// //if (!edge.isSolid) continue;
// float cellDot = Vector2.Dot(cell.Center + Level.Loaded.Position, (edge.point1 + edge.point2) / 2.0f - cell.Center);
// if (cellDot > 0) continue;
// float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center + Level.Loaded.Position)); Vector2 point1 = (edge.point1);
// facingDot = MathHelper.Clamp(facingDot, -1.0f, 1.0f); Vector2 point2 = (edge.point2);
// Vector2 point1 = (edge.point1 + Level.Loaded.Position); float length = (point1 - point2).Length();
// Vector2 point2 = (edge.point2 + Level.Loaded.Position); for (float x = 0; x < length; x += Rand.Range(600.0f, 800.0f))
{
Vector2 point = point1 + Vector2.Normalize(point2 - point1) * x;
// float length = (point1 - point2).Length(); float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
// for (float x=0; x<length; x+=Rand.Range(600.0f, 800.0f))
// {
// Vector2 point = point1 + Vector2.Normalize(point2 - point1) * x;
// float pointDist = point.Length() * displayScale; if (pointDist > radius) continue;
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
// if (pointDist > radius) continue;
// if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
// float step = 5.0f * (Math.Abs(facingDot)+1.0f); float step = 5.0f * (Math.Abs(facingDot) + 1.0f);
// float alpha = Rand.Range(1.5f, 2.0f); float alpha = Rand.Range(1.5f, 2.0f);
// for (float z = 0; z<radius-pointDist;z+=step) for (float z = 0; z < radius - pointDist; z += step)
// { {
// var blip = new RadarBlip( var blip = new RadarBlip(
// point + Rand.Vector(150.0f) - Level.Loaded.Position + Vector2.Normalize(point) * z / displayScale, point + Rand.Vector(150.0f) + Vector2.Normalize(point-item.WorldPosition) * z / displayScale,
// alpha); alpha);
// radarBlips.Add(blip); radarBlips.Add(blip);
// step += 0.5f; step += 0.5f;
// alpha -= (z == 0) ? 0.5f : 0.1f; alpha -= (z == 0) ? 0.5f : 0.1f;
// } }
// } }
// } }
// } }
// for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++) for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
// { {
// Vector2 start = Submarine.Loaded.HullVertices[i] * simScale; Vector2 start = (Submarine.Loaded.HullVertices[i] - ConvertUnits.ToSimUnits(item.Position - Submarine.HiddenSubPosition)) * simScale;
// start.Y = -start.Y; start.Y = -start.Y;
// Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * simScale; Vector2 end = (Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] - ConvertUnits.ToSimUnits(item.Position - Submarine.HiddenSubPosition)) * simScale;
// end.Y = -end.Y; end.Y = -end.Y;
// Vector2 diff = end - start; Vector2 diff = end - start;
// for (float x = 0; x < diff.Length(); x+=4.0f ) for (float x = 0; x < diff.Length(); x += 4.0f)
// { {
// GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green); GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
// } }
// } }
//} }
//foreach (Character c in Character.CharacterList) foreach (Character c in Character.CharacterList)
//{ {
// if (c.AnimController.CurrentHull != null) continue; if (c.AnimController.CurrentHull != null) continue;
// foreach (Limb limb in c.AnimController.Limbs) foreach (Limb limb in c.AnimController.Limbs)
// { {
// Vector2 pos = limb.Position; float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
// float pointDist = pos.Length() * displayScale;
// if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue; if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
// if (pointDist > radius) continue; if (pointDist > radius) continue;
// if (pointDist > prevPingRadius && pointDist < pingRadius) if (pointDist > prevPingRadius && pointDist < pingRadius)
// { {
// var blip = new RadarBlip(pos - Level.Loaded.Position, 1.0f); var blip = new RadarBlip(limb.WorldPosition, 1.0f);
// radarBlips.Add(blip); radarBlips.Add(blip);
// } }
// } }
//} }
//foreach (RadarBlip radarBlip in radarBlips) foreach (RadarBlip radarBlip in radarBlips)
//{ {
// DrawBlip(spriteBatch,radarBlip, center, Color.Green * radarBlip.FadeTimer, radius); DrawBlip(spriteBatch, radarBlip, center, Color.Green * radarBlip.FadeTimer, radius);
//} }
prevPingRadius = pingRadius;
if (screenOverlay != null)
{
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width / screenOverlay.size.X);
}
//prevPingRadius = pingRadius; //prevPingRadius = pingRadius;
//if (screenOverlay!=null) if (GameMain.GameSession == null) return;
//{
// screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
//}
////prevPingRadius = pingRadius;
//if (GameMain.GameSession == null) return;
//DrawMarker(spriteBatch, DrawMarker(spriteBatch,
// (GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name, (GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
// (Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); (Level.Loaded.StartPosition), displayScale, center, (rect.Width * 0.55f));
//DrawMarker(spriteBatch, DrawMarker(spriteBatch,
// (GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name, (GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
// (Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); (Level.Loaded.EndPosition), displayScale, center, (rect.Width * 0.55f));
//if (GameMain.GameSession.Quest != null) if (GameMain.GameSession.Quest != null)
//{ {
// var quest = GameMain.GameSession.Quest; var quest = GameMain.GameSession.Quest;
// if (!string.IsNullOrWhiteSpace(quest.RadarLabel)) if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
// { {
// DrawMarker(spriteBatch, DrawMarker(spriteBatch,
// quest.RadarLabel, quest.RadarLabel,
// quest.RadarPosition, displayScale, center, (rect.Width * 0.55f)); quest.RadarPosition, displayScale, center, (rect.Width * 0.55f));
// } }
//} }
//if (!GameMain.DebugDraw) return; if (!GameMain.DebugDraw) return;
//var steering = item.GetComponent<Steering>(); var steering = item.GetComponent<Steering>();
//if (steering == null || steering.SteeringPath == null) return; if (steering == null || steering.SteeringPath == null) return;
//Vector2 prevPos = Vector2.Zero; Vector2 prevPos = Vector2.Zero;
//foreach (WayPoint wp in steering.SteeringPath.Nodes) foreach (WayPoint wp in steering.SteeringPath.Nodes)
//{ {
// Vector2 pos = (wp.Position - Submarine.Loaded.Position) * displayScale; Vector2 pos = (wp.Position - item.WorldPosition) * displayScale;
// if (pos.Length() > radius) continue; if (pos.Length() > radius) continue;
// pos.Y = -pos.Y; pos.Y = -pos.Y;
// pos += center; pos += center;
// GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X -3 / 2, (int)pos.Y - 3, 6, 6), (steering.SteeringPath.CurrentNode==wp) ? Color.LightGreen : Color.Green, false); GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 3 / 2, (int)pos.Y - 3, 6, 6), (steering.SteeringPath.CurrentNode == wp) ? Color.LightGreen : Color.Green, false);
// if (prevPos!=Vector2.Zero) if (prevPos != Vector2.Zero)
// { {
// GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green); GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green);
// } }
// prevPos = pos; prevPos = pos;
//} }
//voltage = 0.0f; voltage = 0.0f;
} }
private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius) private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius)
{ {
Vector2 pos = (blip.Position) * displayScale;
Vector2 pos = (blip.Position-item.WorldPosition) * displayScale;
pos.Y = -pos.Y; pos.Y = -pos.Y;
if (pos.Length() > radius) if (pos.Length() > radius)
@@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components
{ {
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false); if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
steeringPath = pathFinder.FindPath( steeringPath = pathFinder.FindPath(
ConvertUnits.ToSimUnits(Submarine.Loaded.Position), ConvertUnits.ToSimUnits(item.WorldPosition),
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition)); ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
} }
} }
@@ -160,31 +160,31 @@ namespace Barotrauma.Items.Components
{ {
autopilotRayCastTimer -= deltaTime; autopilotRayCastTimer -= deltaTime;
steeringPath.CheckProgress(ConvertUnits.ToSimUnits(Submarine.Loaded.Position), 10.0f); steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f);
if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null) if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null)
{ {
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.Position); Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
bool nextVisible = true; //bool nextVisible = true;
for (int x = -1; x < 2; x += 2) //for (int x = -1; x < 2; x += 2)
{ //{
for (int y = -1; y < 2; y += 2) // for (int y = -1; y < 2; y += 2)
{ // {
Vector2 cornerPos = // Vector2 cornerPos =
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f; // new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
cornerPos = ConvertUnits.ToSimUnits(cornerPos*1.2f); // cornerPos = ConvertUnits.ToSimUnits(cornerPos*1.2f);
if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue; // if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue;
nextVisible = false; // nextVisible = false;
x = 2; // x = 2;
y = 2; // y = 2;
} // }
} //}
if (nextVisible) steeringPath.SkipToNextNode(); //if (nextVisible) steeringPath.SkipToNextNode();
autopilotRayCastTimer = AutopilotRayCastInterval; autopilotRayCastTimer = AutopilotRayCastInterval;
} }
@@ -193,8 +193,8 @@ namespace Barotrauma.Items.Components
{ {
float prediction = 5.0f; float prediction = 5.0f;
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity) * prediction; Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction;
Vector2 targetSpeed = ((steeringPath.CurrentNode.Position - Submarine.Loaded.Position) - futurePosition); Vector2 targetSpeed = ((steeringPath.CurrentNode.WorldPosition - item.WorldPosition) - futurePosition);
targetSpeed = Vector2.Normalize(targetSpeed); targetSpeed = Vector2.Normalize(targetSpeed);
TargetVelocity = targetSpeed * 100.0f; TargetVelocity = targetSpeed * 100.0f;
@@ -62,7 +62,7 @@ namespace Barotrauma.Items.Components
if (pt.item.Condition<=0.0f && prevCondition > 0.0f) if (pt.item.Condition<=0.0f && prevCondition > 0.0f)
{ {
sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, pt.item.Position); sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, pt.item.WorldPosition);
Vector2 baseVel = Rand.Vector(300.0f); Vector2 baseVel = Rand.Vector(300.0f);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
@@ -169,11 +169,11 @@ namespace Barotrauma.Items.Components
Structure structure; Structure structure;
if ((limb = (f2.Body.UserData as Limb)) != null) if ((limb = (f2.Body.UserData as Limb)) != null)
{ {
attackResult = attack.DoDamage(User, limb.character, item.SimPosition, 1.0f); attackResult = attack.DoDamage(User, limb.character, item.WorldPosition, 1.0f);
} }
else if ((structure = (f2.Body.UserData as Structure)) != null) else if ((structure = (f2.Body.UserData as Structure)) != null)
{ {
attackResult = attack.DoDamage(User, structure, item.SimPosition, 1.0f); attackResult = attack.DoDamage(User, structure, item.WorldPosition, 1.0f);
} }
} }
@@ -98,6 +98,10 @@ namespace Barotrauma.Items.Components
public override void Update(float deltaTime, Camera cam) public override void Update(float deltaTime, Camera cam)
{ {
base.Update(deltaTime, cam); base.Update(deltaTime, cam);
if (item.CurrentHull != null)
{
//light.Submarine = item.CurrentHull.Submarine;
}
if (item.container != null) if (item.container != null)
{ {
@@ -107,7 +111,7 @@ namespace Barotrauma.Items.Components
if (item.body != null) if (item.body != null)
{ {
light.Position = ConvertUnits.ToDisplayUnits(item.body.SimPosition); light.Position = item.WorldPosition;
} }
if (powerConsumption == 0.0f) if (powerConsumption == 0.0f)
@@ -121,7 +125,7 @@ namespace Barotrauma.Items.Components
if (Rand.Range(0.0f, 1.0f) < 0.05f && voltage < Rand.Range(0.0f, minVoltage)) if (Rand.Range(0.0f, 1.0f) < 0.05f && voltage < Rand.Range(0.0f, minVoltage))
{ {
if (voltage > 0.1f) sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 400.0f, item.Position); if (voltage > 0.1f) sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 400.0f, item.WorldPosition);
lightBrightness = 0.0f; lightBrightness = 0.0f;
} }
else else
@@ -314,7 +314,11 @@ namespace Barotrauma.Items.Components
for (int i = 1; i < Nodes.Count; i++) for (int i = 1; i < Nodes.Count; i++)
{ {
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 3, (int)-Nodes[i].Y - 3, 6, 6), Color.Red, true, 0.0f); Vector2 worldPos = Nodes[i];
if (item.Submarine != null) worldPos += item.Submarine.Position;
worldPos.Y = -worldPos.Y;
GUI.DrawRectangle(spriteBatch, worldPos+new Vector2(-3,3), new Vector2(6, 6), Color.Red, true, 0.0f);
if (GUIComponent.MouseOn != null || if (GUIComponent.MouseOn != null ||
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) > 10.0f) Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) > 10.0f)
@@ -322,7 +326,7 @@ namespace Barotrauma.Items.Components
continue; continue;
} }
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 10, (int)-Nodes[i].Y - 10, 20, 20), Color.Red, false, 0.0f); GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-10, 10), new Vector2(20, 20), Color.Red, false, 0.0f);
if (selectedNodeIndex == null && !MapEntity.SelectedAny) if (selectedNodeIndex == null && !MapEntity.SelectedAny)
{ {
@@ -165,7 +165,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker); ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
PlaySound(ActionType.OnWearing, picker.Position); PlaySound(ActionType.OnWearing, picker.WorldPosition);
if (containedItems == null) return; if (containedItems == null) return;
for (int j = 0; j<containedItems.Length; j++) for (int j = 0; j<containedItems.Length; j++)
+12 -7
View File
@@ -549,7 +549,7 @@ namespace Barotrauma
{ {
ic.Update(deltaTime, cam); ic.Update(deltaTime, cam);
ic.PlaySound(ActionType.OnActive, Position); ic.PlaySound(ActionType.OnActive, WorldPosition);
//ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null); //ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
} }
else else
@@ -605,7 +605,7 @@ namespace Barotrauma
if (prefab.ResizeHorizontal || prefab.ResizeVertical) if (prefab.ResizeHorizontal || prefab.ResizeVertical)
{ {
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X+rect.Width/2, -DrawPosition.Y-rect.Height/2), new Vector2(rect.Width, rect.Height), color); prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X-rect.Width/2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), color);
} }
else else
{ {
@@ -645,13 +645,18 @@ namespace Barotrauma
return; return;
} }
GUI.DrawRectangle(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), Color.Green); GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), Color.Green);
foreach (Rectangle t in prefab.Triggers) foreach (Rectangle t in prefab.Triggers)
{ {
Rectangle transformedTrigger = TransformTrigger(t); Rectangle transformedTrigger = TransformTrigger(t);
Vector2 rectWorldPos = new Vector2(transformedTrigger.X, transformedTrigger.Y);
if (Submarine!=null) rectWorldPos += Submarine.Position;
rectWorldPos.Y = -rectWorldPos.Y;
GUI.DrawRectangle(spriteBatch, GUI.DrawRectangle(spriteBatch,
new Vector2(transformedTrigger.X, -transformedTrigger.Y), rectWorldPos,
new Vector2(transformedTrigger.Width, transformedTrigger.Height), new Vector2(transformedTrigger.Width, transformedTrigger.Height),
Color.Green); Color.Green);
} }
@@ -659,8 +664,8 @@ namespace Barotrauma
foreach (MapEntity e in linkedTo) foreach (MapEntity e in linkedTo)
{ {
GUI.DrawLine(spriteBatch, GUI.DrawLine(spriteBatch,
new Vector2(rect.X + rect.Width / 2, -rect.Y + rect.Height / 2), new Vector2(WorldPosition.X, -WorldPosition.Y),
new Vector2(e.Rect.X + e.Rect.Width / 2, -e.Rect.Y + e.Rect.Height / 2), new Vector2(e.WorldPosition.X, -e.WorldPosition.Y),
Color.Red*0.3f); Color.Red*0.3f);
} }
} }
@@ -1002,7 +1007,7 @@ namespace Barotrauma
{ {
ic.WasUsed = true; ic.WasUsed = true;
ic.PlaySound(ActionType.OnUse, body==null ? Position : ConvertUnits.ToDisplayUnits(body.SimPosition)); ic.PlaySound(ActionType.OnUse, WorldPosition);
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character); ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character);
+11 -11
View File
@@ -89,8 +89,8 @@ namespace Barotrauma
public override bool Contains(Vector2 position) public override bool Contains(Vector2 position)
{ {
return (Submarine.RectContains(rect, position) && return (Submarine.RectContains(WorldRect, position) &&
!Submarine.RectContains(new Rectangle(rect.X + 4, rect.Y - 4, rect.Width - 8, rect.Height - 8), position)); !Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -5), position));
} }
private void FindHulls() private void FindHulls()
@@ -142,7 +142,7 @@ namespace Barotrauma
{ {
if (GameMain.DebugDraw) if (GameMain.DebugDraw)
{ {
Vector2 center = new Vector2(rect.X + rect.Width / 2.0f, -(rect.Y - rect.Width / 2.0f)); Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Width / 2.0f));
GUI.DrawLine(sb, center, center + flowForce/10.0f, Color.Red); GUI.DrawLine(sb, center, center + flowForce/10.0f, Color.Red);
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange); GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange);
@@ -152,7 +152,7 @@ namespace Barotrauma
Color clr = (open == 0.0f) ? Color.Red : Color.Cyan; Color clr = (open == 0.0f) ? Color.Red : Color.Cyan;
GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr*0.5f, true); GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y, rect.Width, rect.Height), clr * 0.5f, true);
if (isHorizontal) if (isHorizontal)
{ {
@@ -160,11 +160,11 @@ namespace Barotrauma
{ {
if (linkedTo[i].Rect.Center.X > rect.Center.X) if (linkedTo[i].Rect.Center.X > rect.Center.X)
{ {
GUI.DrawRectangle(sb, new Rectangle(rect.Right, -rect.Y, 10, rect.Height), Color.Green * 0.3f, true); GUI.DrawRectangle(sb, new Rectangle(WorldRect.Right, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
} }
else else
{ {
GUI.DrawRectangle(sb, new Rectangle(rect.X - 10, -rect.Y, 10, rect.Height), Color.Green * 0.3f, true); GUI.DrawRectangle(sb, new Rectangle(WorldRect.X - 10, -WorldRect.Y, 10, rect.Height), Color.Green * 0.3f, true);
} }
} }
} }
@@ -172,13 +172,13 @@ namespace Barotrauma
{ {
for (int i = 0; i < linkedTo.Count; i++) for (int i = 0; i < linkedTo.Count; i++)
{ {
if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height/2.0f > rect.Y) if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > WorldRect.Y)
{ {
GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y - 10, rect.Width, 10), Color.Green * 0.3f, true); GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y - 10, rect.Width, 10), Color.Green * 0.3f, true);
} }
else else
{ {
GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y + rect.Height, rect.Width, 10), Color.Green * 0.3f, true); GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y + rect.Height, rect.Width, 10), Color.Green * 0.3f, true);
} }
} }
} }
@@ -186,7 +186,7 @@ namespace Barotrauma
if (isSelected) if (isSelected)
{ {
GUI.DrawRectangle(sb, GUI.DrawRectangle(sb,
new Vector2(rect.X - 5, -rect.Y - 5), new Vector2(WorldRect.X - 5, -WorldRect.Y - 5),
new Vector2(rect.Width + 10, rect.Height + 10), new Vector2(rect.Width + 10, rect.Height + 10),
Color.Red); Color.Red);
} }
@@ -200,7 +200,7 @@ namespace Barotrauma
int index = (int)Math.Floor(flowForce.Length() / 100.0f); int index = (int)Math.Floor(flowForce.Length() / 100.0f);
index = Math.Min(index,2); index = Math.Min(index,2);
soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, Position, 2000.0f); soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
flowForce = Vector2.Zero; flowForce = Vector2.Zero;
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f); lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f);
+22 -19
View File
@@ -156,7 +156,7 @@ namespace Barotrauma
surface = rect.Y - rect.Height; surface = rect.Y - rect.Height;
aiTarget = new AITarget(this); aiTarget = new AITarget(this);
aiTarget.SightRange = (rect.Width + rect.Height)*10.0f; aiTarget.SightRange = (rect.Width + rect.Height)*5.0f;
hullList.Add(this); hullList.Add(this);
@@ -170,8 +170,8 @@ namespace Barotrauma
public override bool Contains(Vector2 position) public override bool Contains(Vector2 position)
{ {
return (Submarine.RectContains(rect, position) && return (Submarine.RectContains(WorldRect, position) &&
!Submarine.RectContains(new Rectangle(rect.X + 8, rect.Y - 8, rect.Width - 16, rect.Height - 16), position)); !Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -8), position));
} }
public int GetWaveIndex(Vector2 position) public int GetWaveIndex(Vector2 position)
@@ -353,25 +353,28 @@ namespace Barotrauma
{ {
if (!editing && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return;
GUI.DrawRectangle(spriteBatch, Rectangle drawRect =
new Vector2(rect.X, -rect.Y), Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
new Vector2(rect.Width, rect.Height),
isHighlighted ? Color.Green : Color.Blue);
GUI.DrawRectangle(spriteBatch, GUI.DrawRectangle(spriteBatch,
new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), new Vector2(drawRect.X, -drawRect.Y),
new Vector2(rect.Width, rect.Height),
Color.Blue);
GUI.DrawRectangle(spriteBatch,
new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height),
Color.Red*((100.0f-OxygenPercentage)/400.0f), true); Color.Red*((100.0f-OxygenPercentage)/400.0f), true);
spriteBatch.DrawString(GUI.Font, "Pressure: " + ((int)pressure - rect.Y).ToString() + spriteBatch.DrawString(GUI.Font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
" - Oxygen: "+((int)OxygenPercentage), new Vector2(rect.X+10, -rect.Y+10), Color.Black); " - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 10, -drawRect.Y + 10), Color.Black);
spriteBatch.DrawString(GUI.Font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black); spriteBatch.DrawString(GUI.Font, volume + " / " + FullVolume, new Vector2(drawRect.X + 10, -drawRect.Y + 30), Color.Black);
if (isSelected && editing) if ((isSelected || isHighlighted) && editing)
{ {
GUI.DrawRectangle(spriteBatch, GUI.DrawRectangle(spriteBatch,
new Vector2(rect.X - 5, -rect.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),
Color.Red); isHighlighted ? Color.LightBlue*0.5f : Color.Red*0.5f, true);
} }
} }
@@ -380,13 +383,13 @@ namespace Barotrauma
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return; if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
//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+Submarine.Position.Y; float top = rect.Y+Submarine.DrawPosition.Y;
float bottom = top - rect.Height; float bottom = top - rect.Height;
float surfaceY = bottom + Volume / rect.Width; float surfaceY = bottom + Volume / rect.Width;
//interpolate the position of the rendered surface towards the "target surface" //interpolate the position of the rendered surface towards the "target surface"
surface = surface + ((surfaceY - Submarine.Position.Y) - surface) / 10.0f; surface = surface + ((surfaceY - Submarine.DrawPosition.Y) - surface) / 10.0f;
float drawSurface = surface + Submarine.Position.Y; float drawSurface = surface + Submarine.DrawPosition.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;
@@ -407,7 +410,7 @@ namespace Barotrauma
Vector2[] uvCoords = new Vector2[4]; Vector2[] uvCoords = new Vector2[4];
for (int i = 0; i < 4; i++ ) for (int i = 0; i < 4; i++ )
{ {
corners[i] += new Vector3(Submarine.Loaded.Position, 0.0f); corners[i] += new Vector3(Submarine.DrawPosition, 0.0f);
uvCoords[i] = Vector2.Transform(new Vector2(corners[i].X, -corners[i].Y), transform); uvCoords[i] = Vector2.Transform(new Vector2(corners[i].X, -corners[i].Y), transform);
} }
@@ -424,7 +427,7 @@ namespace Barotrauma
return; return;
} }
float x = rect.X+Submarine.Position.X; float x = rect.X + Submarine.DrawPosition.X;
int start = (int)Math.Floor((cam.WorldView.X - x) / WaveWidth); int start = (int)Math.Floor((cam.WorldView.X - x) / WaveWidth);
start = Math.Max(start, 0); start = Math.Max(start, 0);
+161 -13
View File
@@ -6,6 +6,7 @@ using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Voronoi2; using Voronoi2;
@@ -324,7 +325,12 @@ namespace Barotrauma
wrappingWalls[side, i] = new WrappingWall(pathCells, cells, borders.Height * 0.5f, wrappingWalls[side, i] = new WrappingWall(pathCells, cells, borders.Height * 0.5f,
(side == 0 ? -1 : 1) * (i == 0 ? 1 : 2)); (side == 0 ? -1 : 1) * (i == 0 ? 1 : 2));
wrappingWalls[side, i].Vertices = GeneratePolygons(wrappingWalls[side, i].Cells, new List<VoronoiCell>()); wrappingWalls[side, i].Vertices = GeneratePolygons(wrappingWalls[side, i].Cells, new List<VoronoiCell>(), false);
//wrappingWalls[side, i].Cells[0].edges[1].isSolid = false;
//wrappingWalls[side, i].Cells[0].edges[3].isSolid = false;
//wrappingWalls[side, i].Cells[wrappingWalls[side, i].Cells.Count-1].edges[1].isSolid = false;
//wrappingWalls[side, i].Cells[wrappingWalls[side, i].Cells.Count - 1].edges[3].isSolid = false;
} }
} }
@@ -616,7 +622,7 @@ namespace Barotrauma
} }
private VertexPositionTexture[] GeneratePolygons(List<VoronoiCell> cells, List<VoronoiCell> emptyCells) private VertexPositionTexture[] GeneratePolygons(List<VoronoiCell> cells, List<VoronoiCell> emptyCells, bool setSolid=true)
{ {
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>(); List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
//bodies = new List<Body>(); //bodies = new List<Body>();
@@ -639,7 +645,7 @@ namespace Barotrauma
VoronoiCell adjacentCell = ge.AdjacentCell(cell); VoronoiCell adjacentCell = ge.AdjacentCell(cell);
if (adjacentCell!=null && cells.Contains(adjacentCell)) continue; if (adjacentCell!=null && cells.Contains(adjacentCell)) continue;
ge.isSolid = true; if (setSolid) ge.isSolid = true;
if (!bodyPoints.Contains(ge.point1)) bodyPoints.Add(ge.point1); if (!bodyPoints.Contains(ge.point1)) bodyPoints.Add(ge.point1);
if (!bodyPoints.Contains(ge.point2)) bodyPoints.Add(ge.point2); if (!bodyPoints.Contains(ge.point2)) bodyPoints.Add(ge.point2);
@@ -651,15 +657,14 @@ namespace Barotrauma
continue; continue;
} }
var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center); //var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
for (int i = 0; i < triangles.Count; i++) //for (int i = 0; i < triangles.Count; i++)
{ //{
foreach (Vector2 vertex in triangles[i]) // foreach (Vector2 vertex in triangles[i])
{ // {
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 0.0f), vertex/1000.0f)); // verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 0.0f), vertex/1000.0f));
} // }
} //}
if (bodyPoints.Count < 2) continue; if (bodyPoints.Count < 2) continue;
@@ -679,7 +684,7 @@ namespace Barotrauma
bodyPoints[i] = ConvertUnits.ToSimUnits(bodyPoints[i]); bodyPoints[i] = ConvertUnits.ToSimUnits(bodyPoints[i]);
} }
triangles = MathUtils.TriangulateConvexHull(bodyPoints, cell.Center); var triangles = MathUtils.TriangulateConvexHull(bodyPoints, cell.Center);
Body edgeBody = new Body(GameMain.World); Body edgeBody = new Body(GameMain.World);
@@ -701,9 +706,152 @@ namespace Barotrauma
bodies.Add(edgeBody); bodies.Add(edgeBody);
} }
verticeList = GenerateWallShapes(cells);
return verticeList.ToArray(); return verticeList.ToArray();
} }
private List<VertexPositionTexture> GenerateWallShapes(List<VoronoiCell> cells)
{
float wallThickness = 500.0f;
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
foreach (VoronoiCell cell in cells)
{
if (cell.body == null) continue;
foreach (GraphEdge edge in cell.edges)
{
if (edge.cell1 != null && edge.cell1.body == null) edge.cell1 = null;
if (edge.cell2 != null && edge.cell2.body == null) edge.cell2 = null;
//CompareCCW compare = new CompareCCW(cell.Center);
//if (compare.Compare(edge.point1, edge.point2) == -1)
//{
// var temp = edge.point1;
// edge.point1 = edge.point2;
// edge.point2 = temp;
//}
}
}
foreach (VoronoiCell cell in cells)
{
if (cell.body == null) continue;
foreach (GraphEdge edge in cell.edges)
{
if (!edge.isSolid) continue;
GraphEdge leftEdge = null, rightEdge = null;
foreach (GraphEdge edge2 in cell.edges)
{
if (edge == edge2) continue;
if (edge.point1 == edge2.point1 ||
edge.point1 == edge2.point2)
{
leftEdge = edge2;
}
else if(edge.point2 == edge2.point2 || edge.point2 == edge2.point1)
{
rightEdge = edge2;
}
}
Vector2 leftNormal = Vector2.Zero, rightNormal = Vector2.Zero;
if (leftEdge == null)
{
leftNormal = GetEdgeNormal(edge, cell);
}
else
{
leftNormal = (leftEdge.isSolid) ?
Vector2.Normalize(GetEdgeNormal(leftEdge) + GetEdgeNormal(edge, cell)) :
Vector2.Normalize(leftEdge.Center - edge.point1);
}
if (rightEdge == null)
{
rightNormal = GetEdgeNormal(edge, cell);
}
else
{
rightNormal = (rightEdge.isSolid) ?
Vector2.Normalize(GetEdgeNormal(rightEdge) + GetEdgeNormal(edge, cell)) :
Vector2.Normalize(rightEdge.Center - edge.point2);
}
for (int i = 0; i < 2; i++)
{
Vector2[] verts = new Vector2[3];
VertexPositionTexture[] vertPos = new VertexPositionTexture[3];
if (i==0)
{
verts[0] = edge.point1;
verts[1] = edge.point2;
verts[2] = edge.point1 + leftNormal * wallThickness;
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), Vector2.Zero);
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(0, 0.5f));
}
else
{
verts[0] = edge.point1 + leftNormal * wallThickness;
verts[1] = edge.point2;
verts[2] = edge.point2 + rightNormal * wallThickness;
vertPos[0] = new VertexPositionTexture(new Vector3(verts[0], 0.0f), new Vector2(0.0f, 0.5f));
vertPos[1] = new VertexPositionTexture(new Vector3(verts[1], 0.0f), Vector2.UnitX);
vertPos[2] = new VertexPositionTexture(new Vector3(verts[2], 0.0f), new Vector2(1.0f, 0.5f));
}
var comparer = new CompareCCW((verts[0] + verts[1] + verts[2]) / 3.0f);
Array.Sort(verts, vertPos, comparer);
for (int j = 0; j<3; j++)
{
verticeList.Add(vertPos[j]);
}
}
}
}
return verticeList;
}
private Vector2 GetEdgeNormal(GraphEdge edge, VoronoiCell cell = null)
{
if (cell == null) cell = edge.AdjacentCell(null);
if (cell == null) return Vector2.UnitX;
CompareCCW compare = new CompareCCW(cell.Center);
if (compare.Compare(edge.point1, edge.point2) == -1)
{
var temp = edge.point1;
edge.point1 = edge.point2;
edge.point2 = temp;
}
Vector2 normal = Vector2.Zero;
normal = Vector2.Normalize(edge.point2 - edge.point1);
Vector2 diffToCell = Vector2.Normalize(cell.Center - edge.point2);
normal = new Vector2(-normal.Y, normal.X);
if (Vector2.Dot(normal, diffToCell) < 0)
{
normal = -normal;
}
return normal;
}
//public void SetPosition(Vector2 pos) //public void SetPosition(Vector2 pos)
//{ //{
// Vector2 amount = pos - Position; // Vector2 amount = pos - Position;
@@ -27,7 +27,7 @@ namespace Barotrauma
basicEffect.VertexColorEnabled = false; basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true; basicEffect.TextureEnabled = true;
basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceSurface.png"); basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceWall.png");
} }
this.level = level; this.level = level;
@@ -73,12 +73,12 @@ namespace Barotrauma
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
basicEffect.World = Matrix.CreateTranslation( // basicEffect.World = Matrix.CreateTranslation(
new Vector3(-Submarine.Loaded.Position + level.WrappingWalls[side, i].Offset, 0.0f)) * // new Vector3(-Submarine.Loaded.Position + level.WrappingWalls[side, i].Offset, 0.0f)) *
cam.ShaderTransform * // cam.ShaderTransform *
Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; // Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
basicEffect.CurrentTechnique.Passes[0].Apply(); // basicEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives( graphicsDevice.DrawUserPrimitives(
PrimitiveType.TriangleList, PrimitiveType.TriangleList,
@@ -180,6 +180,11 @@ namespace Voronoi2
public bool isSolid; public bool isSolid;
public Vector2 Center
{
get { return (point1 + point2) / 2.0f; }
}
public VoronoiCell AdjacentCell(VoronoiCell cell) public VoronoiCell AdjacentCell(VoronoiCell cell)
{ {
if (cell1==cell) if (cell1==cell)
@@ -95,8 +95,15 @@ namespace Barotrauma
vertices[3] = vertices[0] + Vector2.UnitY * wallSectionSize.Y; vertices[3] = vertices[0] + Vector2.UnitY * wallSectionSize.Y;
VoronoiCell wallCell = new VoronoiCell(vertices); VoronoiCell wallCell = new VoronoiCell(vertices);
wallCell.edges[0].cell1 = wallCell;
wallCell.edges[1].cell1 = wallCell; wallCell.edges[1].cell1 = wallCell;
wallCell.edges[2].cell1 = wallCell;
wallCell.edges[3].cell1 = wallCell; wallCell.edges[3].cell1 = wallCell;
wallCell.edges[0].isSolid = true;
wallCell.edges[2].isSolid = true;
if (i > 1) if (i > 1)
{ {
wallCell.edges[1].cell2 = cells[i - 2]; wallCell.edges[1].cell2 = cells[i - 2];
+10 -4
View File
@@ -249,7 +249,7 @@ namespace Barotrauma.Lights
if (!Enabled) return; if (!Enabled) return;
CachedShadow cachedShadow = null; CachedShadow cachedShadow = null;
if (cachedShadows.TryGetValue(light, out cachedShadow)) if (cachedShadows.TryGetValue(light, out cachedShadow) && false)
{ {
if (light.Position == cachedShadow.LightPos || if (light.Position == cachedShadow.LightPos ||
Vector2.DistanceSquared(light.WorldPosition, cachedShadow.LightPos) < 1.0f) Vector2.DistanceSquared(light.WorldPosition, cachedShadow.LightPos) < 1.0f)
@@ -269,9 +269,15 @@ namespace Barotrauma.Lights
} }
else else
{ {
CalculateShadowVertices(light.Position, los); Vector2 lightPos = light.WorldPosition;
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.WorldPosition); if (light.Submarine!=null && parentEntity != null && parentEntity.Submarine == light.Submarine)
cachedShadows.Add(light, cachedShadow); {
lightPos = light.Position;
}
CalculateShadowVertices(lightPos, los);
// cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.WorldPosition);
// cachedShadows.Add(light, cachedShadow);
} }
DrawShadows(graphicsDevice, cam, transform, los); DrawShadows(graphicsDevice, cam, transform, los);
+1 -1
View File
@@ -128,7 +128,7 @@ namespace Barotrauma.Lights
//draw the light shape //draw the light shape
//where Alpha is 0, nothing will be written //where Alpha is 0, nothing will be written
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, Matrix.CreateTranslation(new Vector3(Submarine.Loaded.DrawPosition.X, -Submarine.Loaded.DrawPosition.Y, 0.0f)) * cam.Transform); spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
light.Draw(spriteBatch); light.Draw(spriteBatch);
spriteBatch.End(); spriteBatch.End();
} }
+1 -1
View File
@@ -101,7 +101,7 @@ namespace Barotrauma.Lights
{ {
Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2); Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2);
float scale = range / (lightTexture.Width / 2.0f); float scale = range / (lightTexture.Width / 2.0f);
spriteBatch.Draw(lightTexture, new Vector2(Position.X, -Position.Y), null, color, 0, center, scale, SpriteEffects.None, 1); spriteBatch.Draw(lightTexture, new Vector2(WorldPosition.X, -WorldPosition.Y), null, color, 0, center, scale, SpriteEffects.None, 1);
} }
public void Remove() public void Remove()
+1 -1
View File
@@ -154,7 +154,7 @@ namespace Barotrauma
public virtual bool Contains(Vector2 position) public virtual bool Contains(Vector2 position)
{ {
return (Submarine.RectContains(rect, position)); return (Submarine.RectContains(WorldRect, position));
} }
protected void InsertToList() protected void InsertToList()
+1 -1
View File
@@ -431,7 +431,7 @@ namespace Barotrauma
if (Submarine.Loaded != null && Submarine.Loaded.GodMode) return new AttackResult(0.0f, 0.0f); if (Submarine.Loaded != null && Submarine.Loaded.GodMode) return new AttackResult(0.0f, 0.0f);
if (!prefab.HasBody || prefab.IsPlatform) return new AttackResult(0.0f, 0.0f); if (!prefab.HasBody || prefab.IsPlatform) return new AttackResult(0.0f, 0.0f);
Vector2 transformedPos = ConvertUnits.ToDisplayUnits(position); Vector2 transformedPos = position;
if (Submarine != null) transformedPos -= Submarine.Position; if (Submarine != null) transformedPos -= Submarine.Position;
int i = FindSectionIndex(transformedPos); int i = FindSectionIndex(transformedPos);
+2 -2
View File
@@ -101,7 +101,7 @@ namespace Barotrauma
public override Vector2 Position public override Vector2 Position
{ {
get { return subBody.Position - HiddenSubPosition; } get { return subBody==null ? Vector2.Zero : subBody.Position - HiddenSubPosition; }
} }
public new Vector2 DrawPosition public new Vector2 DrawPosition
@@ -616,7 +616,6 @@ namespace Barotrauma
XDocument doc = OpenDoc(filePath); XDocument doc = OpenDoc(filePath);
if (doc == null) return; if (doc == null) return;
subBody = new SubmarineBody(this);
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
@@ -650,6 +649,7 @@ namespace Barotrauma
} }
subBody = new SubmarineBody(this);
subBody.SetPosition(HiddenSubPosition); subBody.SetPosition(HiddenSubPosition);
loaded = this; loaded = this;
+4 -3
View File
@@ -225,7 +225,7 @@ namespace Barotrauma
if (body.LinearVelocity.LengthSquared() > 0.000001f) if (body.LinearVelocity.LengthSquared() > 0.000001f)
{ {
float dragCoefficient = 0.00001f; float dragCoefficient = 0.01f;
float speedLength = (body.LinearVelocity == Vector2.Zero) ? 0.0f : body.LinearVelocity.Length(); float speedLength = (body.LinearVelocity == Vector2.Zero) ? 0.0f : body.LinearVelocity.Length();
float drag = speedLength * speedLength * dragCoefficient * mass; float drag = speedLength * speedLength * dragCoefficient * mass;
@@ -259,9 +259,9 @@ namespace Barotrauma
float neutralPercentage = 0.07f; float neutralPercentage = 0.07f;
float buoyancy = Math.Max(neutralPercentage - waterPercentage, -neutralPercentage*2.0f); float buoyancy = Math.Max(neutralPercentage - waterPercentage, -neutralPercentage*2.0f);
buoyancy *= mass * 30.0f; buoyancy *= mass;
return new Vector2(0.0f, buoyancy); return new Vector2(0.0f, buoyancy*10.0f);
} }
public void ApplyForce(Vector2 force) public void ApplyForce(Vector2 force)
@@ -417,6 +417,7 @@ namespace Barotrauma
Vector2 lastContactPoint = worldPoints[0]; Vector2 lastContactPoint = worldPoints[0];
normal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
float impact = Vector2.Dot(Velocity, -normal); float impact = Vector2.Dot(Velocity, -normal);
+6 -4
View File
@@ -84,18 +84,20 @@ namespace Barotrauma
{ {
if (!editing && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return;
Point pos = new Point((int)Position.X, (int)Position.Y); Rectangle drawRect =
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
Color clr = (isSelected) ? Color.Red : Color.LightGreen; Color clr = (isSelected) ? Color.Red : Color.LightGreen;
GUI.DrawRectangle(spriteBatch, new Rectangle(pos.X - rect.Width / 2, -pos.Y - rect.Height / 2, rect.Width, rect.Height), clr, true); GUI.DrawRectangle(spriteBatch, new Rectangle(drawRect.X, -drawRect.Y, rect.Width, rect.Height), clr, true);
//spriteBatch.DrawString(GUI.SmallFont, Position.ToString(), new Vector2(Position.X, -Position.Y), Color.White); //spriteBatch.DrawString(GUI.SmallFont, Position.ToString(), new Vector2(Position.X, -Position.Y), Color.White);
foreach (MapEntity e in linkedTo) foreach (MapEntity e in linkedTo)
{ {
GUI.DrawLine(spriteBatch, GUI.DrawLine(spriteBatch,
new Vector2(pos.X, -pos.Y), new Vector2(drawRect.X, -drawRect.Y),
new Vector2(e.Position.X + e.Rect.Width / 2, -e.Position.Y + e.Rect.Height / 2), new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
Color.Green); Color.Green);
} }
} }
+1
View File
@@ -74,6 +74,7 @@ namespace Barotrauma.Particles
spriteIndex = Rand.Int(prefab.Sprites.Count); spriteIndex = Rand.Int(prefab.Sprites.Count);
currentHull = Hull.FindHull(position, hullGuess); currentHull = Hull.FindHull(position, hullGuess);
if (currentHull != null && currentHull.Submarine != null) speed += ConvertUnits.ToDisplayUnits(currentHull.Submarine.Velocity);
//if (currentHull == null) position = Submarine.Loaded == null ? position : position + Submarine.Loaded.Position; //if (currentHull == null) position = Submarine.Loaded == null ? position : position + Submarine.Loaded.Position;
this.position = position; this.position = position;
+6 -6
View File
@@ -234,6 +234,12 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
{
GameMain.GameSession.Level.Render(graphics, cam);
//GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
spriteBatch.Begin(SpriteSortMode.BackToFront, spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend, BlendState.AlphaBlend,
null, null, null, null, null, null, null, null,
@@ -325,12 +331,6 @@ namespace Barotrauma
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform); Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
{
GameMain.GameSession.Level.Render(graphics, cam);
//GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
}
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
//3. draw the sections of the map that are on top of the water //3. draw the sections of the map that are on top of the water
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
+9 -9
View File
@@ -103,7 +103,7 @@ namespace Barotrauma
if (volume <= 0.0f) return -1; if (volume <= 0.0f) return -1;
alSourceId = SoundManager.Play(this, relativePos, volume); alSourceId = SoundManager.Play(this, relativePos/100.0f, volume);
return alSourceId; return alSourceId;
@@ -112,16 +112,16 @@ namespace Barotrauma
//return UpdatePosition(newIndex, position, range, volume); //return UpdatePosition(newIndex, position, range, volume);
} }
public int Play(float volume, float range, Body body) //public int Play(float volume, float range, Body body)
{ //{
//Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position); // //Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position);
//bodyPosition.Y = -bodyPosition.Y; // //bodyPosition.Y = -bodyPosition.Y;
alSourceId = Play(volume, range, ConvertUnits.ToDisplayUnits(body.Position)); // alSourceId = Play(volume, range, ConvertUnits.ToDisplayUnits(body.Position));
return alSourceId; // return alSourceId;
} //}
private float GetVolume(Vector2 relativePosition, float range, float baseVolume) private float GetVolume(Vector2 relativePosition, float range, float baseVolume)
{ {
@@ -198,7 +198,7 @@ namespace Barotrauma
return sourceIndex; return sourceIndex;
} }
return SoundManager.Loop(this, sourceIndex, relativePos, volume); return SoundManager.Loop(this, sourceIndex, relativePos/100.0f, volume);
} }
+2 -4
View File
@@ -76,10 +76,8 @@ namespace Barotrauma
startDrone = Sound.Load("Content/Sounds/startDrone.ogg", false); startDrone = Sound.Load("Content/Sounds/startDrone.ogg", false);
startDrone.Play(); startDrone.Play();
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
waterAmbiences[0] = Sound.Load("Content/Sounds/Water/WaterAmbience1.ogg", false); waterAmbiences[0] = Sound.Load("Content/Sounds/Water/WaterAmbience1.ogg", false);
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
waterAmbiences[1] = Sound.Load("Content/Sounds/Water/WaterAmbience2.ogg", false); waterAmbiences[1] = Sound.Load("Content/Sounds/Water/WaterAmbience2.ogg", false);
@@ -276,9 +274,9 @@ namespace Barotrauma
} }
} }
public static void PlayDamageSound(DamageSoundType damageType, float damage, Body body) public static void PlayDamageSound(DamageSoundType damageType, float damage, PhysicsBody body)
{ {
Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position); Vector2 bodyPosition = body.DrawPosition;
bodyPosition.Y = -bodyPosition.Y; bodyPosition.Y = -bodyPosition.Y;
PlayDamageSound(damageType, damage, bodyPosition); PlayDamageSound(damageType, damage, bodyPosition);
+5
View File
@@ -247,6 +247,11 @@ namespace Barotrauma
this.center = center; this.center = center;
} }
public int Compare(Vector2 a, Vector2 b) public int Compare(Vector2 a, Vector2 b)
{
return Compare(a, b, center);
}
public static int Compare(Vector2 a, Vector2 b, Vector2 center)
{ {
if (a.X - center.X >= 0 && b.X - center.X < 0) return -1; if (a.X - center.X >= 0 && b.X - center.X < 0) return -1;
if (a.X - center.X < 0 && b.X - center.X >= 0) return 1; if (a.X - center.X < 0 && b.X - center.X >= 0) return 1;
Binary file not shown.