- 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:
@@ -62,10 +62,12 @@ namespace Barotrauma
|
||||
{
|
||||
var item = character.Inventory.Items[i];
|
||||
if (item == null || CharacterInventory.limbSlots[i]==LimbSlot.Any) continue;
|
||||
var statusHUD = item.GetComponent<StatusHUD>();
|
||||
if (statusHUD == null) continue;
|
||||
|
||||
statusHUD.DrawHUD(spriteBatch, character);
|
||||
//var statusHUD = item.GetComponent<StatusHUD>();
|
||||
//if (statusHUD == null) continue;
|
||||
foreach (ItemComponent ic in item.components)
|
||||
{
|
||||
if (ic.DrawHudWhenEquipped) ic.DrawHUD(spriteBatch, character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Barotrauma
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire
|
||||
Always, OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire, InWater
|
||||
}
|
||||
|
||||
class Item : MapEntity, IDamageable, IPropertyObject
|
||||
@@ -646,7 +646,7 @@ namespace Barotrauma
|
||||
ic.WasUsed = false;
|
||||
|
||||
if (Container != null) ic.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
||||
|
||||
|
||||
if (!ic.IsActive) continue;
|
||||
|
||||
if (condition > 0.0f)
|
||||
@@ -660,7 +660,11 @@ namespace Barotrauma
|
||||
{
|
||||
ic.UpdateBroken(deltaTime, cam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inWater = IsInWater();
|
||||
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
|
||||
|
||||
if (body == null || !body.Enabled) return;
|
||||
|
||||
@@ -681,8 +685,6 @@ namespace Barotrauma
|
||||
|
||||
body.MoveToTargetPosition();
|
||||
|
||||
inWater = IsInWater();
|
||||
|
||||
if (!inWater || Container != null || body == null) return;
|
||||
|
||||
if (body.LinearVelocity != Vector2.Zero && body.LinearVelocity.Length() > 1000.0f)
|
||||
@@ -692,7 +694,6 @@ namespace Barotrauma
|
||||
|
||||
ApplyWaterForces();
|
||||
|
||||
//TODO: make sure items stay in sync between clients before letting flowing water move items
|
||||
if(CurrentHull != null) CurrentHull.ApplyFlowForces(deltaTime, this);
|
||||
|
||||
}
|
||||
|
||||
@@ -156,35 +156,34 @@ namespace Barotrauma
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition;
|
||||
|
||||
var cells = level.GetCells(GameMain.GameScreen.Cam.WorldViewCenter, 2);
|
||||
foreach (VoronoiCell cell in cells)
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(cell.Center.X - 10.0f, -cell.Center.Y-10.0f), new Vector2(20.0f, 20.0f), Color.Cyan, true);
|
||||
var cells = level.GetCells(GameMain.GameScreen.Cam.WorldViewCenter, 2);
|
||||
foreach (VoronoiCell cell in cells)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(cell.Center.X - 10.0f, -cell.Center.Y-10.0f), new Vector2(20.0f, 20.0f), Color.Cyan, true);
|
||||
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
|
||||
new Vector2(cell.Center.X, -cell.Center.Y),
|
||||
Color.White);
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(cell.edges[0].point1.X, -cell.edges[0].point1.Y),
|
||||
new Vector2(cell.Center.X, -cell.Center.Y),
|
||||
Color.White);
|
||||
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
//GUI.DrawLine(spriteBatch,
|
||||
// new Vector2(edge.point1.X, -edge.point1.Y),
|
||||
// new Vector2(cell.Center.X, -cell.Center.Y),
|
||||
// Color.White);
|
||||
foreach (GraphEdge edge in cell.edges)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
|
||||
new Vector2(edge.point2.X, -edge.point2.Y), Color.White);
|
||||
}
|
||||
|
||||
GUI.DrawLine(spriteBatch, new Vector2(edge.point1.X, -edge.point1.Y),
|
||||
new Vector2(edge.point2.X, -edge.point2.Y), Color.White);
|
||||
}
|
||||
|
||||
foreach (Vector2 point in cell.bodyVertices)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(point.X, -point.Y), new Vector2(10.0f, 10.0f), Color.White, true);
|
||||
}
|
||||
foreach (Vector2 point in cell.bodyVertices)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(point.X, -point.Y), new Vector2(10.0f, 10.0f), Color.White, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition;
|
||||
|
||||
if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 512) return;
|
||||
|
||||
pos.X = GameMain.GameScreen.Cam.WorldView.X -512.0f;
|
||||
@@ -197,8 +196,6 @@ namespace Barotrauma
|
||||
Color.White, 0.0f,
|
||||
Vector2.Zero,
|
||||
SpriteEffects.None, 0.0f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user