- handheld sonar

- junction boxes, sonar monitors, navigation terminals and engines break down if they're underwater long enough
- reactor cools down if it's underwater
- job-specific gear are grouped by job in separate .xml files
This commit is contained in:
Regalis
2016-04-09 14:31:59 +03:00
parent c7545d5816
commit c5685db0aa
29 changed files with 524 additions and 393 deletions

View File

@@ -111,6 +111,13 @@ namespace Barotrauma.Items.Components
set { canBePicked = value; }
}
[HasDefaultValue(false, false)]
public bool DrawHudWhenEquipped
{
get;
private set;
}
[HasDefaultValue(false, false)]
public bool CanBeSelected
{

View File

@@ -3,8 +3,6 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Voronoi2;
@@ -16,7 +14,7 @@ namespace Barotrauma.Items.Components
private float pingState;
private Sprite pingCircle, screenOverlay;
private readonly Sprite pingCircle, screenOverlay;
private GUITickBox isActiveTickBox;
@@ -30,6 +28,13 @@ namespace Barotrauma.Items.Components
set { range = MathHelper.Clamp(value, 0.0f, 100000.0f); }
}
[HasDefaultValue(false, false)]
public bool DetectSubmarineWalls
{
get;
set;
}
public Radar(Item item, XElement element)
: base(item, element)
{
@@ -71,7 +76,7 @@ namespace Barotrauma.Items.Components
if (radarBlips[i].FadeTimer <= 0.0f) radarBlips.RemoveAt(i);
}
if (voltage >= minVoltage)
if (voltage >= minVoltage || powerConsumption <= 0.0f)
{
pingState = pingState + deltaTime * 0.5f;
if (pingState>1.0f)
@@ -87,7 +92,7 @@ namespace Barotrauma.Items.Components
pingState = 0.0f;
}
voltage -= deltaTime;
Voltage -= deltaTime;
}
public override bool Use(float deltaTime, Character character = null)
@@ -101,7 +106,7 @@ namespace Barotrauma.Items.Components
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return;
if (voltage < minVoltage && powerConsumption > 0.0f) return;
int radius = GuiFrame.Rect.Height / 2 - 30;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
@@ -113,23 +118,59 @@ namespace Barotrauma.Items.Components
if (!IsActive) return;
float pingRadius = (rect.Width / 2) * pingState;
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f-pingState), 0.0f, (rect.Width/pingCircle.size.X)*pingState);
float pingRadius = (rect.Width / 2.0f) * pingState;
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f - pingState), 0.0f, (rect.Width / pingCircle.size.X) * pingState);
float radius = rect.Width / 2.0f;
float displayScale = radius/range;
float displayScale = radius / range;
if (DetectSubmarineWalls)
{
for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
{
Vector2 start = ConvertUnits.ToDisplayUnits(Submarine.Loaded.HullVertices[i]);
Vector2 end = ConvertUnits.ToDisplayUnits(Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count]);
if (item.CurrentHull!=null)
{
start += Rand.Vector(500.0f);
end += Rand.Vector(500.0f);
}
CreateBlipsForLine(
start + Submarine.Loaded.WorldPosition,
end + Submarine.Loaded.WorldPosition,
radius, displayScale, 2.0f);
}
}
else
{
float simScale = ConvertUnits.ToSimUnits(displayScale);
Vector2 offset = ConvertUnits.ToSimUnits(Submarine.Loaded.WorldPosition - item.WorldPosition);
for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
{
Vector2 start = (Submarine.Loaded.HullVertices[i] + offset) * simScale;
start.Y = -start.Y;
Vector2 end = (Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
}
}
float simScale = 1.5f;
if (Level.Loaded != null)
if (Level.Loaded != null && (item.CurrentHull==null || !DetectSubmarineWalls))
{
List<VoronoiCell> cells = Level.Loaded.GetCells(item.WorldPosition, 7);
foreach (VoronoiCell cell in cells)
{
foreach (GraphEdge edge in cell.edges)
{
if (!edge.isSolid) continue;
@@ -140,59 +181,15 @@ namespace Barotrauma.Items.Components
Vector2.Normalize(edge.point1 - edge.point2),
Vector2.Normalize(cell.Center-item.WorldPosition));
//if (Math.Abs(facingDot) > 0.5f) continue;
//facingDot = 1.0f;// MathHelper.Clamp(facingDot, -1.0f, 1.0f);
float length = (edge.point1 - edge.point2).Length();
for (float x = 0; x < length; x += Rand.Range(300.0f, 400.0f))
{
Vector2 point = edge.point1 + Vector2.Normalize(edge.point2 - edge.point1) * x;
point += cell.Translation;
float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
if (pointDist > radius) continue;
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
float step = 3.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) + Vector2.Normalize(point-item.WorldPosition) * z / displayScale,
alpha);
radarBlips.Add(blip);
step += 0.5f;
alpha -= (z == 0) ? 0.5f : 0.1f;
}
}
CreateBlipsForLine(edge.point1 + cell.Translation, edge.point2+cell.Translation, radius, displayScale, 3.0f * (Math.Abs(facingDot) + 1.0f));
}
}
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;
Vector2 diff = end - start;
for (float x = 0; x < diff.Length(); x += 4.0f)
{
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
}
}
}
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.CurrentHull != null) continue;
if (DetectSubmarineWalls && c.AnimController.CurrentHull == null && item.CurrentHull != null) continue;
foreach (Limb limb in c.AnimController.Limbs)
{
@@ -272,7 +269,42 @@ namespace Barotrauma.Items.Components
prevPos = pos;
}
}
private void CreateBlipsForLine(Vector2 point1, Vector2 point2, float radius, float displayScale, float step)
{
float pingRadius = radius * pingState;
float length = (point1 - point2).Length();
Vector2 lineDir = (point2 - point1) / length;
for (float x = 0; x < length; x += Rand.Range(300.0f, 400.0f))
{
Vector2 point = point1 + lineDir * x;
//point += cell.Translation;
float pointDist = Vector2.Distance(item.WorldPosition, point) * displayScale;
if (pointDist > radius) continue;
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
//float step = 3.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) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
alpha);
radarBlips.Add(blip);
step += 0.5f;
alpha -= (z == 0) ? 0.5f : 0.1f;
}
}
}
private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius)

View File

@@ -225,7 +225,7 @@ namespace Barotrauma.Items.Components
fissionRate = Math.Min(fissionRate, AvailableFuel);
float heat = 100 * fissionRate * (AvailableFuel/2000.0f);
float heat = 80 * fissionRate * (AvailableFuel/2000.0f);
float heatDissipation = 50 * coolingRate + Math.Max(ExtraCooling, 5.0f);
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
@@ -288,9 +288,12 @@ namespace Barotrauma.Items.Components
}
else if (autoTemp)
{
fissionRate = Math.Min(load / 200.0f, shutDownTemp);
//float target = Math.Min(targetTemp, load);
CoolingRate = coolingRate + (temperature - Math.Min(load, shutDownTemp) + deltaTemp)*0.1f;
//take deltaTemp into account to slow down the change in temperature when getting closer to the desired value
float target = temperature + deltaTemp * 100.0f;
//-1.0f in order to gradually turn down both rates when the target temperature is reached
FissionRate += (MathHelper.Clamp(load - target, -10.0f, 10.0f) - 1.0f) * deltaTime;
CoolingRate += (MathHelper.Clamp(target - load, -5.0f, 5.0f) - 1.0f) * deltaTime;
}
//fission rate can't be lowered below a certain amount if the core is too hot