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">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Map\iceWall.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Map\locationNames.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -15,7 +15,7 @@
<!-- lower yaw -->
<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"/>
<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>
<!-- 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.W)) moveCam.Y += moveSpeed;
if (Submarine.Loaded!=null)
{
moveCam += FarseerPhysics.ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity*deltaTime);
}
moveCam = moveCam * deltaTime * 60.0f;
}
@@ -192,6 +192,7 @@ namespace Barotrauma
raycastTimer = RaycastInterval;
}
steeringManager.SteeringAvoid(deltaTime, 1.0f);
steeringManager.SteeringSeek(attackSimPosition);
//check if any of the limbs is close enough to attack the target
@@ -322,7 +323,7 @@ namespace Barotrauma
attackTimer += deltaTime;
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;
}
@@ -218,7 +218,7 @@ namespace Barotrauma
//a node that hasn't been searched yet
if (nextNode.state==0)
{
nextNode.H = Vector2.DistanceSquared(nextNode.Position,end.Position);
nextNode.H = Vector2.Distance(nextNode.Position,end.Position);
if (GetNodePenalty != null)
{
@@ -144,11 +144,14 @@ namespace Barotrauma
avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - obstaclePosition);
}
else
else if (closestBody.UserData is 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;
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)
{
character.Health -= (impact - l.impactTolerance * 0.1f);
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;
}
+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;
//DamageSoundType damageSoundType = DamageSoundType.None;
@@ -139,15 +139,15 @@ namespace Barotrauma
if (particleEmitterPrefab != null)
{
particleEmitterPrefab.Emit(position);
particleEmitterPrefab.Emit(worldPosition);
}
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;
CharacterList.Add(this);
@@ -741,7 +741,7 @@ namespace Barotrauma
{
Limb head = AnimController.GetLimb(LimbType.Head);
Lights.LightManager.ViewPos = WorldPosition;
Lights.LightManager.ViewPos = DrawPosition;
if (!DisableControls)
{
@@ -1010,7 +1010,7 @@ namespace Barotrauma
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, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true);
}
@@ -1028,17 +1028,16 @@ namespace Barotrauma
if (soundStates[i] != state) continue;
if (n == selectedSound && sounds[i]!=null)
{
sounds[i].Play(1.0f, 2000.0f,
AnimController.Limbs[0].body.FarseerBody);
sounds[i].Play(1.0f, 2000.0f, AnimController.Limbs[0].WorldPosition);
return;
}
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)
@@ -1103,7 +1102,7 @@ namespace Barotrauma
// 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++)
{
+1 -1
View File
@@ -215,7 +215,7 @@ namespace Barotrauma
if (explosion != null) explosion.Explode(entity.WorldPosition);
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++)
{
+10 -10
View File
@@ -66,18 +66,18 @@ namespace Barotrauma
}
}
try
{
//try
//{
Coroutines[i].MoveNext();
}
// }
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message);
#endif
Coroutines.RemoveAt(i);
}
// catch (Exception e)
// {
//#if DEBUG
// DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message);
//#endif
// Coroutines.RemoveAt(i);
// }
}
}
+3
View File
@@ -287,6 +287,9 @@ namespace Barotrauma
commands[1] = commands[1].ToLower();
Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLower() == commands[1]);
break;
case "godmode":
Submarine.Loaded.GodMode = !Submarine.Loaded.GodMode;
break;
case "heal":
if (Character.Controlled != null)
{
+1 -1
View File
@@ -113,7 +113,7 @@ namespace Barotrauma
{
guiFrame.Update(deltaTime);
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.I))
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.C))
{
commander.ToggleGUIFrame();
}
+2 -2
View File
@@ -262,7 +262,7 @@ namespace Barotrauma.Items.Components
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);
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);
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")
{
bool newState = (signal!="0");
if (isOpen!=newState) PlaySound(ActionType.OnUse, item.Position);
if (isOpen!=newState) PlaySound(ActionType.OnUse, item.WorldPosition);
isOpen = newState;
}
@@ -236,6 +236,8 @@ namespace Barotrauma.Items.Components
AnimController ac = picker.AnimController;
item.Submarine = picker.Submarine;
//item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
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 (attack!=null) attack.DoDamage(user, target, item.Position, 1.0f);
if (attack!=null) attack.DoDamage(user, target, item.WorldPosition, 1.0f);
RestoreCollision();
hitting = false;
@@ -322,6 +322,8 @@ namespace Barotrauma.Items.Components
if (itemSound.Loop)
{
loopingSound = itemSound;
loopingSoundIndex = loopingSound.Sound.Loop(loopingSoundIndex, GetSoundVolume(loopingSound), position, loopingSound.Range);
}
else
{
@@ -163,7 +163,7 @@ namespace Barotrauma.Items.Components
if (item.body == null)
{
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;
}
else
@@ -61,6 +61,7 @@ namespace Barotrauma.Items.Components
{
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);
}
}
@@ -169,7 +169,7 @@ namespace Barotrauma.Items.Components
{
item.SendSignal("1", "signal_out");
PlaySound(ActionType.OnUse, item.Position);
PlaySound(ActionType.OnUse, item.WorldPosition);
return true;
}
@@ -115,162 +115,160 @@ namespace Barotrauma.Items.Components
float radius = rect.Width / 2.0f;
float simScale = 1.5f;
if (Level.Loaded != null)
{
List<VoronoiCell> cells = Level.Loaded.GetCells(item.WorldPosition, 7);
return;
foreach (VoronoiCell cell in cells)
{
//if (Level.Loaded != null)
//{
// List<VoronoiCell> cells = Level.Loaded.GetCells(Submarine.Loaded.Position, 7);
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 (VoronoiCell cell in cells)
// {
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);
// foreach (GraphEdge edge in cell.edges)
// {
// //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;
Vector2 point1 = (edge.point1);
Vector2 point2 = (edge.point2);
// float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center + Level.Loaded.Position));
// facingDot = MathHelper.Clamp(facingDot, -1.0f, 1.0f);
float length = (point1 - point2).Length();
for (float x = 0; x < length; x += Rand.Range(600.0f, 800.0f))
{
Vector2 point = point1 + Vector2.Normalize(point2 - point1) * x;
// Vector2 point1 = (edge.point1 + Level.Loaded.Position);
// Vector2 point2 = (edge.point2 + Level.Loaded.Position);
float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
// float length = (point1 - point2).Length();
// 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 alpha = Rand.Range(1.5f, 2.0f);
// for (float z = 0; z<radius-pointDist;z+=step)
// {
// var blip = new RadarBlip(
// point + Rand.Vector(150.0f) - Level.Loaded.Position + Vector2.Normalize(point) * z / displayScale,
// alpha);
float step = 5.0f * (Math.Abs(facingDot) + 1.0f);
float alpha = Rand.Range(1.5f, 2.0f);
for (float z = 0; z < radius - pointDist; z += step)
{
// radarBlips.Add(blip);
// step += 0.5f;
// alpha -= (z == 0) ? 0.5f : 0.1f;
// }
// }
// }
// }
var blip = new RadarBlip(
point + Rand.Vector(150.0f) + Vector2.Normalize(point-item.WorldPosition) * z / displayScale,
alpha);
// for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
// {
// Vector2 start = Submarine.Loaded.HullVertices[i] * simScale;
// start.Y = -start.Y;
// Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * simScale;
// end.Y = -end.Y;
radarBlips.Add(blip);
step += 0.5f;
alpha -= (z == 0) ? 0.5f : 0.1f;
}
// Vector2 diff = end - start;
// for (float x = 0; x < diff.Length(); x+=4.0f )
// {
// GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
// }
// }
}
}
}
//}
for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
{
Vector2 start = (Submarine.Loaded.HullVertices[i] - ConvertUnits.ToSimUnits(item.Position - Submarine.HiddenSubPosition)) * simScale;
start.Y = -start.Y;
Vector2 end = (Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] - ConvertUnits.ToSimUnits(item.Position - Submarine.HiddenSubPosition)) * simScale;
end.Y = -end.Y;
//foreach (Character c in Character.CharacterList)
//{
// if (c.AnimController.CurrentHull != null) continue;
Vector2 diff = end - start;
for (float x = 0; x < diff.Length(); x += 4.0f)
{
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
}
}
// foreach (Limb limb in c.AnimController.Limbs)
// {
// Vector2 pos = limb.Position;
// float pointDist = pos.Length() * displayScale;
}
// if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull != null) continue;
foreach (Limb limb in c.AnimController.Limbs)
{
float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
// if (pointDist > radius) continue;
// if (pointDist > prevPingRadius && pointDist < pingRadius)
// {
// var blip = new RadarBlip(pos - Level.Loaded.Position, 1.0f);
// radarBlips.Add(blip);
// }
// }
//}
if (pointDist > radius) continue;
if (pointDist > prevPingRadius && pointDist < pingRadius)
{
var blip = new RadarBlip(limb.WorldPosition, 1.0f);
radarBlips.Add(blip);
}
}
}
//foreach (RadarBlip radarBlip in radarBlips)
//{
// DrawBlip(spriteBatch,radarBlip, center, Color.Green * radarBlip.FadeTimer, radius);
//}
foreach (RadarBlip radarBlip in radarBlips)
{
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;
//if (screenOverlay!=null)
//{
// screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
//}
////prevPingRadius = pingRadius;
//if (GameMain.GameSession == null) return;
if (GameMain.GameSession == null) return;
//DrawMarker(spriteBatch,
// (GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
// (Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
DrawMarker(spriteBatch,
(GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
(Level.Loaded.StartPosition), displayScale, center, (rect.Width * 0.55f));
//DrawMarker(spriteBatch,
// (GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
// (Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
DrawMarker(spriteBatch,
(GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
(Level.Loaded.EndPosition), displayScale, center, (rect.Width * 0.55f));
//if (GameMain.GameSession.Quest != null)
//{
// var quest = GameMain.GameSession.Quest;
if (GameMain.GameSession.Quest != null)
{
var quest = GameMain.GameSession.Quest;
// if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
// {
// DrawMarker(spriteBatch,
// quest.RadarLabel,
// quest.RadarPosition, displayScale, center, (rect.Width * 0.55f));
// }
//}
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
{
DrawMarker(spriteBatch,
quest.RadarLabel,
quest.RadarPosition, displayScale, center, (rect.Width * 0.55f));
}
}
//if (!GameMain.DebugDraw) return;
if (!GameMain.DebugDraw) return;
//var steering = item.GetComponent<Steering>();
//if (steering == null || steering.SteeringPath == null) return;
var steering = item.GetComponent<Steering>();
if (steering == null || steering.SteeringPath == null) return;
//Vector2 prevPos = Vector2.Zero;
Vector2 prevPos = Vector2.Zero;
//foreach (WayPoint wp in steering.SteeringPath.Nodes)
//{
// Vector2 pos = (wp.Position - Submarine.Loaded.Position) * displayScale;
// if (pos.Length() > radius) continue;
foreach (WayPoint wp in steering.SteeringPath.Nodes)
{
Vector2 pos = (wp.Position - item.WorldPosition) * displayScale;
if (pos.Length() > radius) continue;
// pos.Y = -pos.Y;
// pos += center;
pos.Y = -pos.Y;
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)
// {
// GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green);
// }
if (prevPos != Vector2.Zero)
{
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)
{
Vector2 pos = (blip.Position) * displayScale;
Vector2 pos = (blip.Position-item.WorldPosition) * displayScale;
pos.Y = -pos.Y;
if (pos.Length() > radius)
@@ -41,7 +41,7 @@ namespace Barotrauma.Items.Components
{
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
steeringPath = pathFinder.FindPath(
ConvertUnits.ToSimUnits(Submarine.Loaded.Position),
ConvertUnits.ToSimUnits(item.WorldPosition),
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
}
}
@@ -160,31 +160,31 @@ namespace Barotrauma.Items.Components
{
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)
{
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.Position);
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
bool nextVisible = true;
for (int x = -1; x < 2; x += 2)
{
for (int y = -1; y < 2; y += 2)
{
Vector2 cornerPos =
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
//bool nextVisible = true;
//for (int x = -1; x < 2; x += 2)
//{
// for (int y = -1; y < 2; y += 2)
// {
// Vector2 cornerPos =
// 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;
x = 2;
y = 2;
}
}
// nextVisible = false;
// x = 2;
// y = 2;
// }
//}
if (nextVisible) steeringPath.SkipToNextNode();
//if (nextVisible) steeringPath.SkipToNextNode();
autopilotRayCastTimer = AutopilotRayCastInterval;
}
@@ -193,8 +193,8 @@ namespace Barotrauma.Items.Components
{
float prediction = 5.0f;
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity) * prediction;
Vector2 targetSpeed = ((steeringPath.CurrentNode.Position - Submarine.Loaded.Position) - futurePosition);
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction;
Vector2 targetSpeed = ((steeringPath.CurrentNode.WorldPosition - item.WorldPosition) - futurePosition);
targetSpeed = Vector2.Normalize(targetSpeed);
TargetVelocity = targetSpeed * 100.0f;
@@ -62,7 +62,7 @@ namespace Barotrauma.Items.Components
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);
for (int i = 0; i < 10; i++)
@@ -169,11 +169,11 @@ namespace Barotrauma.Items.Components
Structure structure;
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)
{
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)
{
base.Update(deltaTime, cam);
if (item.CurrentHull != null)
{
//light.Submarine = item.CurrentHull.Submarine;
}
if (item.container != null)
{
@@ -107,7 +111,7 @@ namespace Barotrauma.Items.Components
if (item.body != null)
{
light.Position = ConvertUnits.ToDisplayUnits(item.body.SimPosition);
light.Position = item.WorldPosition;
}
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 (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;
}
else
@@ -314,7 +314,11 @@ namespace Barotrauma.Items.Components
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 ||
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) > 10.0f)
@@ -322,7 +326,7 @@ namespace Barotrauma.Items.Components
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)
{
@@ -165,7 +165,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
PlaySound(ActionType.OnWearing, picker.Position);
PlaySound(ActionType.OnWearing, picker.WorldPosition);
if (containedItems == null) return;
for (int j = 0; j<containedItems.Length; j++)
+12 -7
View File
@@ -549,7 +549,7 @@ namespace Barotrauma
{
ic.Update(deltaTime, cam);
ic.PlaySound(ActionType.OnActive, Position);
ic.PlaySound(ActionType.OnActive, WorldPosition);
//ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
}
else
@@ -605,7 +605,7 @@ namespace Barotrauma
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
{
@@ -645,13 +645,18 @@ namespace Barotrauma
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)
{
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,
new Vector2(transformedTrigger.X, -transformedTrigger.Y),
rectWorldPos,
new Vector2(transformedTrigger.Width, transformedTrigger.Height),
Color.Green);
}
@@ -659,8 +664,8 @@ namespace Barotrauma
foreach (MapEntity e in linkedTo)
{
GUI.DrawLine(spriteBatch,
new Vector2(rect.X + rect.Width / 2, -rect.Y + rect.Height / 2),
new Vector2(e.Rect.X + e.Rect.Width / 2, -e.Rect.Y + e.Rect.Height / 2),
new Vector2(WorldPosition.X, -WorldPosition.Y),
new Vector2(e.WorldPosition.X, -e.WorldPosition.Y),
Color.Red*0.3f);
}
}
@@ -1002,7 +1007,7 @@ namespace Barotrauma
{
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);
+11 -11
View File
@@ -89,8 +89,8 @@ namespace Barotrauma
public override bool Contains(Vector2 position)
{
return (Submarine.RectContains(rect, position) &&
!Submarine.RectContains(new Rectangle(rect.X + 4, rect.Y - 4, rect.Width - 8, rect.Height - 8), position));
return (Submarine.RectContains(WorldRect, position) &&
!Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -5), position));
}
private void FindHulls()
@@ -142,7 +142,7 @@ namespace Barotrauma
{
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 + 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;
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)
{
@@ -160,11 +160,11 @@ namespace Barotrauma
{
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
{
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++)
{
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
{
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)
{
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),
Color.Red);
}
@@ -200,7 +200,7 @@ namespace Barotrauma
int index = (int)Math.Floor(flowForce.Length() / 100.0f);
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;
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, 0.05f);
+22 -19
View File
@@ -156,7 +156,7 @@ namespace Barotrauma
surface = rect.Y - rect.Height;
aiTarget = new AITarget(this);
aiTarget.SightRange = (rect.Width + rect.Height)*10.0f;
aiTarget.SightRange = (rect.Width + rect.Height)*5.0f;
hullList.Add(this);
@@ -170,8 +170,8 @@ namespace Barotrauma
public override bool Contains(Vector2 position)
{
return (Submarine.RectContains(rect, position) &&
!Submarine.RectContains(new Rectangle(rect.X + 8, rect.Y - 8, rect.Width - 16, rect.Height - 16), position));
return (Submarine.RectContains(WorldRect, position) &&
!Submarine.RectContains(MathUtils.ExpandRect(WorldRect, -8), position));
}
public int GetWaveIndex(Vector2 position)
@@ -353,25 +353,28 @@ namespace Barotrauma
{
if (!editing && !GameMain.DebugDraw) return;
GUI.DrawRectangle(spriteBatch,
new Vector2(rect.X, -rect.Y),
new Vector2(rect.Width, rect.Height),
isHighlighted ? Color.Green : Color.Blue);
Rectangle drawRect =
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
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);
spriteBatch.DrawString(GUI.Font, "Pressure: " + ((int)pressure - rect.Y).ToString() +
" - Oxygen: "+((int)OxygenPercentage), new Vector2(rect.X+10, -rect.Y+10), Color.Black);
spriteBatch.DrawString(GUI.Font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black);
" - Oxygen: " + ((int)OxygenPercentage), new Vector2(drawRect.X + 10, -drawRect.Y + 10), 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,
new Vector2(rect.X - 5, -rect.Y - 5),
new Vector2(rect.Width + 10, rect.Height + 10),
Color.Red);
new Vector2(drawRect.X + 5, -drawRect.Y + 5),
new Vector2(rect.Width - 10, rect.Height - 10),
isHighlighted ? Color.LightBlue*0.5f : Color.Red*0.5f, true);
}
}
@@ -380,13 +383,13 @@ namespace Barotrauma
if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return;
//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 surfaceY = bottom + Volume / rect.Width;
//interpolate the position of the rendered surface towards the "target surface"
surface = surface + ((surfaceY - Submarine.Position.Y) - surface) / 10.0f;
float drawSurface = surface + Submarine.Position.Y;
surface = surface + ((surfaceY - Submarine.DrawPosition.Y) - surface) / 10.0f;
float drawSurface = surface + Submarine.DrawPosition.Y;
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];
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);
}
@@ -424,7 +427,7 @@ namespace Barotrauma
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);
start = Math.Max(start, 0);
+161 -13
View File
@@ -6,6 +6,7 @@ using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Voronoi2;
@@ -324,7 +325,12 @@ namespace Barotrauma
wrappingWalls[side, i] = new WrappingWall(pathCells, cells, borders.Height * 0.5f,
(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>();
//bodies = new List<Body>();
@@ -639,7 +645,7 @@ namespace Barotrauma
VoronoiCell adjacentCell = ge.AdjacentCell(cell);
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.point2)) bodyPoints.Add(ge.point2);
@@ -651,15 +657,14 @@ namespace Barotrauma
continue;
}
var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
for (int i = 0; i < triangles.Count; i++)
{
foreach (Vector2 vertex in triangles[i])
{
verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 0.0f), vertex/1000.0f));
}
}
//var triangles = MathUtils.TriangulateConvexHull(tempVertices, cell.Center);
//for (int i = 0; i < triangles.Count; i++)
//{
// foreach (Vector2 vertex in triangles[i])
// {
// verticeList.Add(new VertexPositionTexture(new Vector3(vertex, 0.0f), vertex/1000.0f));
// }
//}
if (bodyPoints.Count < 2) continue;
@@ -679,7 +684,7 @@ namespace Barotrauma
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);
@@ -701,9 +706,152 @@ namespace Barotrauma
bodies.Add(edgeBody);
}
verticeList = GenerateWallShapes(cells);
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)
//{
// Vector2 amount = pos - Position;
@@ -27,7 +27,7 @@ namespace Barotrauma
basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true;
basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceSurface.png");
basicEffect.Texture = TextureLoader.FromFile("Content/Map/iceWall.png");
}
this.level = level;
@@ -73,12 +73,12 @@ namespace Barotrauma
{
for (int i = 0; i < 2; i++)
{
basicEffect.World = Matrix.CreateTranslation(
new Vector3(-Submarine.Loaded.Position + level.WrappingWalls[side, i].Offset, 0.0f)) *
cam.ShaderTransform *
Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
// basicEffect.World = Matrix.CreateTranslation(
// new Vector3(-Submarine.Loaded.Position + level.WrappingWalls[side, i].Offset, 0.0f)) *
// cam.ShaderTransform *
// Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
basicEffect.CurrentTechnique.Passes[0].Apply();
// basicEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives(
PrimitiveType.TriangleList,
@@ -180,6 +180,11 @@ namespace Voronoi2
public bool isSolid;
public Vector2 Center
{
get { return (point1 + point2) / 2.0f; }
}
public VoronoiCell AdjacentCell(VoronoiCell cell)
{
if (cell1==cell)
@@ -95,8 +95,15 @@ namespace Barotrauma
vertices[3] = vertices[0] + Vector2.UnitY * wallSectionSize.Y;
VoronoiCell wallCell = new VoronoiCell(vertices);
wallCell.edges[0].cell1 = wallCell;
wallCell.edges[1].cell1 = wallCell;
wallCell.edges[2].cell1 = wallCell;
wallCell.edges[3].cell1 = wallCell;
wallCell.edges[0].isSolid = true;
wallCell.edges[2].isSolid = true;
if (i > 1)
{
wallCell.edges[1].cell2 = cells[i - 2];
+10 -4
View File
@@ -249,7 +249,7 @@ namespace Barotrauma.Lights
if (!Enabled) return;
CachedShadow cachedShadow = null;
if (cachedShadows.TryGetValue(light, out cachedShadow))
if (cachedShadows.TryGetValue(light, out cachedShadow) && false)
{
if (light.Position == cachedShadow.LightPos ||
Vector2.DistanceSquared(light.WorldPosition, cachedShadow.LightPos) < 1.0f)
@@ -269,9 +269,15 @@ namespace Barotrauma.Lights
}
else
{
CalculateShadowVertices(light.Position, los);
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.WorldPosition);
cachedShadows.Add(light, cachedShadow);
Vector2 lightPos = light.WorldPosition;
if (light.Submarine!=null && parentEntity != null && parentEntity.Submarine == light.Submarine)
{
lightPos = light.Position;
}
CalculateShadowVertices(lightPos, los);
// cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.WorldPosition);
// cachedShadows.Add(light, cachedShadow);
}
DrawShadows(graphicsDevice, cam, transform, los);
+1 -1
View File
@@ -128,7 +128,7 @@ namespace Barotrauma.Lights
//draw the light shape
//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);
spriteBatch.End();
}
+1 -1
View File
@@ -101,7 +101,7 @@ namespace Barotrauma.Lights
{
Vector2 center = new Vector2(LightTexture.Width / 2, LightTexture.Height / 2);
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()
+1 -1
View File
@@ -154,7 +154,7 @@ namespace Barotrauma
public virtual bool Contains(Vector2 position)
{
return (Submarine.RectContains(rect, position));
return (Submarine.RectContains(WorldRect, position));
}
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 (!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;
int i = FindSectionIndex(transformedPos);
+2 -2
View File
@@ -101,7 +101,7 @@ namespace Barotrauma
public override Vector2 Position
{
get { return subBody.Position - HiddenSubPosition; }
get { return subBody==null ? Vector2.Zero : subBody.Position - HiddenSubPosition; }
}
public new Vector2 DrawPosition
@@ -616,7 +616,6 @@ namespace Barotrauma
XDocument doc = OpenDoc(filePath);
if (doc == null) return;
subBody = new SubmarineBody(this);
foreach (XElement element in doc.Root.Elements())
{
@@ -650,6 +649,7 @@ namespace Barotrauma
}
subBody = new SubmarineBody(this);
subBody.SetPosition(HiddenSubPosition);
loaded = this;
+4 -3
View File
@@ -225,7 +225,7 @@ namespace Barotrauma
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 drag = speedLength * speedLength * dragCoefficient * mass;
@@ -259,9 +259,9 @@ namespace Barotrauma
float neutralPercentage = 0.07f;
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)
@@ -417,6 +417,7 @@ namespace Barotrauma
Vector2 lastContactPoint = worldPoints[0];
normal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
float impact = Vector2.Dot(Velocity, -normal);
+6 -4
View File
@@ -84,18 +84,20 @@ namespace Barotrauma
{
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;
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);
foreach (MapEntity e in linkedTo)
{
GUI.DrawLine(spriteBatch,
new Vector2(pos.X, -pos.Y),
new Vector2(e.Position.X + e.Rect.Width / 2, -e.Position.Y + e.Rect.Height / 2),
new Vector2(drawRect.X, -drawRect.Y),
new Vector2(e.DrawPosition.X, -e.DrawPosition.Y),
Color.Green);
}
}
+1
View File
@@ -74,6 +74,7 @@ namespace Barotrauma.Particles
spriteIndex = Rand.Int(prefab.Sprites.Count);
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;
this.position = position;
+6 -6
View File
@@ -234,6 +234,12 @@ namespace Barotrauma
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,
BlendState.AlphaBlend,
null, null, null, null,
@@ -325,12 +331,6 @@ namespace Barotrauma
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
//----------------------------------------------------------------------------------------
+9 -9
View File
@@ -103,7 +103,7 @@ namespace Barotrauma
if (volume <= 0.0f) return -1;
alSourceId = SoundManager.Play(this, relativePos, volume);
alSourceId = SoundManager.Play(this, relativePos/100.0f, volume);
return alSourceId;
@@ -112,16 +112,16 @@ namespace Barotrauma
//return UpdatePosition(newIndex, position, range, volume);
}
public int Play(float volume, float range, Body body)
{
//Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position);
//bodyPosition.Y = -bodyPosition.Y;
//public int Play(float volume, float range, Body body)
//{
// //Vector2 bodyPosition = ConvertUnits.ToDisplayUnits(body.Position);
// //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)
{
@@ -198,7 +198,7 @@ namespace Barotrauma
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.Play();
yield return CoroutineStatus.Running;
waterAmbiences[0] = Sound.Load("Content/Sounds/Water/WaterAmbience1.ogg", false);
yield return CoroutineStatus.Running;
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;
PlayDamageSound(damageType, damage, bodyPosition);
+5
View File
@@ -247,6 +247,11 @@ namespace Barotrauma
this.center = center;
}
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;
Binary file not shown.