Quests, new sounds, explosives, bugfixes, asdfasdf
This commit is contained in:
@@ -50,7 +50,11 @@ namespace Subsurface.Items.Components
|
||||
: base(item, element)
|
||||
{
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
public float CurrentVolume
|
||||
{
|
||||
get { return Math.Abs((force / 100.0f) * (voltage / minVoltage)); }
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
@@ -68,7 +72,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Game1.particleManager.CreateParticle("bubbles", item.SimPosition,
|
||||
Game1.ParticleManager.CreateParticle("bubbles", item.SimPosition,
|
||||
-currForce/500.0f + new Vector2(Rand.Range(-1.0f, 1.0f), Rand.Range(-0.5f, 0.5f)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
@@ -16,6 +18,16 @@ namespace Subsurface.Items.Components
|
||||
|
||||
Hull hull1, hull2;
|
||||
|
||||
private float FlowPercentage
|
||||
{
|
||||
get { return flowPercentage; }
|
||||
set
|
||||
{
|
||||
if (float.IsNaN(flowPercentage)) return;
|
||||
flowPercentage = MathHelper.Clamp(value,-100.0f,100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
[HasDefaultValue(100.0f, false)]
|
||||
public float MaxFlow
|
||||
{
|
||||
@@ -26,7 +38,7 @@ namespace Subsurface.Items.Components
|
||||
public Pump(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
//maxFlow = ToolBox.GetAttributeFloat(element, "maxflow", 100.0f);
|
||||
flowPercentage = 100.0f;
|
||||
|
||||
item.linkedTo.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{ GetHulls(); };
|
||||
@@ -34,7 +46,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
currPowerConsumption = powerConsumption;
|
||||
currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f);
|
||||
|
||||
if (voltage < minVoltage) return;
|
||||
|
||||
@@ -56,52 +68,17 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
hull1.Volume += deltaVolume;
|
||||
if (hull2 != null) hull2.Volume -= deltaVolume;
|
||||
if (hull1.Volume > hull1.FullVolume) hull1.Pressure += 0.5f;
|
||||
|
||||
if (hull2 != null)
|
||||
{
|
||||
hull2.Volume -= deltaVolume;
|
||||
if (hull2.Volume > hull1.FullVolume) hull2.Pressure += 0.5f;
|
||||
}
|
||||
|
||||
voltage = 0.0f;
|
||||
}
|
||||
|
||||
//public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
//{
|
||||
// int width = 300, height = 200;
|
||||
// int x = Game1.GraphicsWidth / 2 - width / 2;
|
||||
// int y = Game1.GraphicsHeight / 2 - height / 2;
|
||||
|
||||
// GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
|
||||
|
||||
// spriteBatch.DrawString(GUI.font, "Pumping direction: " + ((flowIn) ? "in" : "out"), new Vector2(x + 30, y + 30), Color.White);
|
||||
// if (GUI.DrawButton(spriteBatch, new Rectangle(x + 30, y + 50, 80, 40), "TOGGLE")) flowIn = !flowIn;
|
||||
|
||||
// if (GUI.DrawButton(spriteBatch, new Rectangle(x + 30, y + 150, 100, 40), (isActive) ? "TURN OFF" : "TURN ON")) IsActive = !isActive;
|
||||
|
||||
//}
|
||||
|
||||
//public override bool Pick(Character activator = null)
|
||||
//{
|
||||
// //isActive = !isActive;
|
||||
|
||||
// hull1 = null;
|
||||
// hull2 = null;
|
||||
|
||||
// foreach (MapEntity e in item.linkedTo)
|
||||
// {
|
||||
// Hull hull = e as Hull;
|
||||
// if (hull == null) continue;
|
||||
|
||||
// if (hull1 == null)
|
||||
// {
|
||||
// hull1 = hull;
|
||||
// }
|
||||
// else if (hull2 == null && hull != hull1)
|
||||
// {
|
||||
// hull2 = hull;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return true;
|
||||
//}
|
||||
|
||||
|
||||
private void GetHulls()
|
||||
{
|
||||
hull1 = null;
|
||||
@@ -124,34 +101,33 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
//public override void OnMapLoaded()
|
||||
//{
|
||||
// hull1 = null;
|
||||
// hull2 = null;
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
// foreach (MapEntity e in item.linkedTo)
|
||||
// {
|
||||
// Hull hull = e as Hull;
|
||||
// if (hull == null) continue;
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
// if (hull1 == null)
|
||||
// {
|
||||
// hull1 = hull;
|
||||
// }
|
||||
// else if (hull2 == null && hull != hull1)
|
||||
// {
|
||||
// hull2 = hull;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 20, y + 20, 100, 40), ((isActive) ? "TURN OFF" : "TURN ON")))
|
||||
{
|
||||
targetLevel = null;
|
||||
isActive = !isActive;
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Flow percentage: " + (int)flowPercentage + " %", new Vector2(x + 20, y + 80), Color.White);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "+", true)) FlowPercentage += 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "-", true)) FlowPercentage -= 1.0f;
|
||||
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
{
|
||||
base.ReceiveSignal(signal, connection, sender, power);
|
||||
|
||||
isActive = true;
|
||||
|
||||
|
||||
if (connection.Name == "toggle")
|
||||
{
|
||||
isActive = !isActive;
|
||||
@@ -176,8 +152,6 @@ namespace Subsurface.Items.Components
|
||||
targetLevel = MathHelper.Clamp(tempTarget, 0.0f, 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message)
|
||||
@@ -193,13 +167,13 @@ namespace Subsurface.Items.Components
|
||||
|
||||
try
|
||||
{
|
||||
newFlow = MathHelper.Clamp(message.ReadFloat(), -100.0f, 100.0f);
|
||||
newFlow = message.ReadFloat();
|
||||
newActive = message.ReadBoolean();
|
||||
}
|
||||
|
||||
catch { return; }
|
||||
|
||||
flowPercentage = newFlow;
|
||||
FlowPercentage = newFlow;
|
||||
isActive = newActive;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
|
||||
float scale = 0.015f;
|
||||
float displayScale = ConvertUnits.ToDisplayUnits(scale);
|
||||
|
||||
if (Level.Loaded != null)
|
||||
{
|
||||
@@ -109,12 +110,11 @@ namespace Subsurface.Items.Components
|
||||
center + (edges[i][1] - offset) * scale, Color.White);
|
||||
}
|
||||
|
||||
scale = ConvertUnits.ToDisplayUnits(scale);
|
||||
for (int i = 0; i < Submarine.Loaded.HullVertices.Count; i++)
|
||||
{
|
||||
Vector2 start = Submarine.Loaded.HullVertices[i] * scale;
|
||||
Vector2 start = Submarine.Loaded.HullVertices[i] * displayScale;
|
||||
start.Y = -start.Y;
|
||||
Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * scale;
|
||||
Vector2 end = Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] * displayScale;
|
||||
end.Y = -end.Y;
|
||||
|
||||
GUI.DrawLine(spriteBatch, center + start, center + end, Color.White);
|
||||
@@ -127,7 +127,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (c.SimPosition != Vector2.Zero && c.SimPosition.Length() < 7 * Level.GridCellWidth)
|
||||
{
|
||||
int width = (int)Math.Min(c.Mass / 5, 30);
|
||||
int width = (int)MathHelper.Clamp(c.Mass / 20, 1, 10);
|
||||
|
||||
Vector2 pos = c.Position * scale;
|
||||
pos.Y = -pos.Y;
|
||||
@@ -141,6 +141,74 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
|
||||
}
|
||||
|
||||
//if (Level.Loaded != null)
|
||||
//{
|
||||
|
||||
// for (int i = 0; i < 2; i++)
|
||||
// {
|
||||
// Vector2 targetPos = (i == 0) ? Level.Loaded.StartPosition : Level.Loaded.EndPosition;
|
||||
// targetPos += Level.Loaded.Position;
|
||||
|
||||
// float dist = targetPos.Length();
|
||||
|
||||
// targetPos.Y = -targetPos.Y;
|
||||
// Vector2 markerPos = Vector2.Normalize(targetPos) * (rect.Width * 0.55f);
|
||||
// markerPos += center;
|
||||
|
||||
// GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen);
|
||||
|
||||
// string label;
|
||||
// if (Game1.GameSession.Map!=null)
|
||||
// {
|
||||
// label = (i == 0) ? Game1.GameSession.Map.CurrentLocation.Name : Game1.GameSession.Map.SelectedLocation.Name;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// label = (i == 0) ? "Start" : "End";
|
||||
// }
|
||||
|
||||
// spriteBatch.DrawString(GUI.SmallFont, label, new Vector2(markerPos.X + 10, markerPos.Y), Color.LightGreen);
|
||||
// spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||
// }
|
||||
|
||||
DrawMarker(spriteBatch,
|
||||
(Game1.GameSession.Map == null) ? "Start" : Game1.GameSession.Map.CurrentLocation.Name,
|
||||
Level.Loaded.StartPosition + Level.Loaded.Position, center, (rect.Width * 0.55f));
|
||||
|
||||
DrawMarker(spriteBatch,
|
||||
(Game1.GameSession.Map == null) ? "End" : Game1.GameSession.Map.SelectedLocation.Name,
|
||||
Level.Loaded.EndPosition + Level.Loaded.Position, center, (rect.Width * 0.55f));
|
||||
|
||||
if (Game1.GameSession.Map != null && Game1.GameSession.Map.SelectedConnection.Quest!=null)
|
||||
{
|
||||
var quest = Game1.GameSession.Map.SelectedConnection.Quest;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
|
||||
{
|
||||
DrawMarker(spriteBatch,
|
||||
quest.RadarLabel,
|
||||
quest.RadarPosition, center, (rect.Width * 0.55f));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, Vector2 center, float radius)
|
||||
{
|
||||
//position += Level.Loaded.Position;
|
||||
|
||||
float dist = position.Length();
|
||||
|
||||
position.Y = -position.Y;
|
||||
Vector2 markerPos = center + Vector2.Normalize(position) * radius;
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen);
|
||||
|
||||
spriteBatch.DrawString(GUI.SmallFont, label, new Vector2(markerPos.X + 10, markerPos.Y), Color.LightGreen);
|
||||
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||
|
||||
}
|
||||
|
||||
private void UpdateRendertarget()
|
||||
|
||||
@@ -101,6 +101,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
meltDownTemp = 9000.0f;
|
||||
|
||||
shutDownTemp = 500.0f;
|
||||
|
||||
powerPerTemp = 1.0f;
|
||||
|
||||
isActive = true;
|
||||
@@ -227,39 +229,14 @@ namespace Subsurface.Items.Components
|
||||
|
||||
new RepairTask(item, 60.0f, "Reactor meltdown!");
|
||||
item.Condition = 0.0f;
|
||||
fissionRate = 0.0f;
|
||||
coolingRate = 0.0f;
|
||||
//fissionRate = 0.0f;
|
||||
//coolingRate = 0.0f;
|
||||
|
||||
new Explosion(item.SimPosition, 6.0f, 500.0f, 600.0f, 10.0f, 2.0f).Explode();
|
||||
|
||||
//List<Structure> structureList = new List<Structure>();
|
||||
|
||||
//float dist = 600.0f;
|
||||
//foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
//{
|
||||
// Structure structure = entity as Structure;
|
||||
// if (structure == null) continue;
|
||||
|
||||
// if (structure.HasBody && Vector2.Distance(structure.Position, item.Position)<dist*3.0f)
|
||||
// {
|
||||
// structureList.Add(structure);
|
||||
// }
|
||||
//}
|
||||
|
||||
//foreach (Structure structure in structureList)
|
||||
//{
|
||||
// for (int i = 0; i < structure.SectionCount; i++)
|
||||
// {
|
||||
// float damage = dist - Vector2.Distance(structure.SectionPosition(i), item.Position);
|
||||
// if (damage > 0.0f) structure.AddDamage(i, damage);
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (item.currentHull!=null)
|
||||
//{
|
||||
// item.currentHull.WaveVel[item.currentHull.GetWaveIndex(item.SimPosition)] = 100.0f;
|
||||
//}
|
||||
//PlaySound(ActionType.OnFailure, item.Position);
|
||||
//item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, null);
|
||||
|
||||
//new Explosion(item.SimPosition, 6.0f, 500.0f, 600.0f, 10.0f, 2.0f).Explode();
|
||||
|
||||
if (item.ContainedItems!=null)
|
||||
{
|
||||
foreach (Item containedItem in item.ContainedItems)
|
||||
@@ -274,11 +251,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
{
|
||||
if (picker == null) return false;
|
||||
|
||||
//picker.SelectedConstruction = (picker.SelectedConstruction==item) ? null : item;
|
||||
|
||||
return true;
|
||||
return (picker != null);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
@@ -331,10 +304,10 @@ namespace Subsurface.Items.Components
|
||||
|
||||
y = y - 260;
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Autotemp: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
|
||||
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON"))) autoTemp = !autoTemp;
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Max temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
|
||||
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true)) shutDownTemp += 100.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true)) shutDownTemp -= 100.0f;
|
||||
|
||||
@@ -378,7 +351,7 @@ namespace Subsurface.Items.Components
|
||||
Vector2 lastPoint = new Vector2(x,
|
||||
y + height - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
|
||||
|
||||
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.Red);
|
||||
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.White);
|
||||
}
|
||||
|
||||
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message)
|
||||
|
||||
@@ -12,12 +12,33 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
class Steering : ItemComponent
|
||||
{
|
||||
Vector2 currVelocity;
|
||||
Vector2 targetVelocity;
|
||||
private Vector2 currVelocity;
|
||||
private Vector2 targetVelocity;
|
||||
|
||||
bool autoPilot;
|
||||
private bool autoPilot;
|
||||
|
||||
SteeringPath steeringPath;
|
||||
private SteeringPath steeringPath;
|
||||
|
||||
private static PathFinder pathFinder;
|
||||
|
||||
bool AutoPilot
|
||||
{
|
||||
get { return autoPilot; }
|
||||
set
|
||||
{
|
||||
if (value == autoPilot) return;
|
||||
|
||||
autoPilot = value;
|
||||
|
||||
if (autoPilot)
|
||||
{
|
||||
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||
steeringPath = pathFinder.FindPath(
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.Position),
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 TargetVelocity
|
||||
{
|
||||
@@ -43,18 +64,16 @@ namespace Subsurface.Items.Components
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
|
||||
|
||||
|
||||
if (autoPilot)
|
||||
{
|
||||
if (steeringPath==null)
|
||||
{
|
||||
PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||
steeringPath = pathFinder.FindPath(
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||
}
|
||||
//if (steeringPath==null)
|
||||
//{
|
||||
// PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||
// steeringPath = pathFinder.FindPath(
|
||||
// ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
|
||||
// ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||
//}
|
||||
|
||||
steeringPath.GetNode(Vector2.Zero, 20.0f);
|
||||
|
||||
@@ -90,7 +109,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
|
||||
{
|
||||
autoPilot = !autoPilot;
|
||||
AutoPilot = !AutoPilot;
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
@@ -156,7 +175,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
TargetVelocity = newTargetVelocity;
|
||||
autoPilot = newAutoPilot;
|
||||
AutoPilot = newAutoPilot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user