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
+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++)