Supercapacitors have much higher max output but smaller capacity, fixed not being able to drag wire nodes in editor, batteries working properly now

This commit is contained in:
Regalis
2016-02-07 12:32:19 +02:00
parent ec7bd3523c
commit 201dc1b733
27 changed files with 93 additions and 60 deletions

View File

@@ -326,7 +326,7 @@ namespace Barotrauma
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition))
{
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonHeld())
{
slotRect.X = (int)PlayerInput.MousePosition.X - slotRect.Width / 2;
slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2;

View File

@@ -442,9 +442,9 @@ namespace Barotrauma.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
spriteBatch.DrawString(GUI.Font, "Temperature: " + (int)temperature + " C",
spriteBatch.DrawString(GUI.Font, "Output: " + (int)temperature + " kW",
new Vector2(x + 450, y + 30), Color.Red);
spriteBatch.DrawString(GUI.Font, "Grid load: " + (int)load + " C",
spriteBatch.DrawString(GUI.Font, "Grid load: " + (int)load + " kW",
new Vector2(x + 620, y + 30), Color.Yellow);
DrawGraph(tempGraph, spriteBatch,

View File

@@ -183,7 +183,7 @@ namespace Barotrauma.Items.Components
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)targetVelPos.X -10, (int)targetVelPos.Y - 10, 20, 20), Color.Red);
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonHeld())
{
TargetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
targetVelocity.Y = -targetVelocity.Y;

View File

@@ -42,7 +42,7 @@ namespace Barotrauma.Items.Components
get { return charge; }
set
{
if (float.IsNaN(value)) return;
if (!MathUtils.IsValid(value)) return;
charge = MathHelper.Clamp(value, 0.0f, capacity);
}
}
@@ -60,7 +60,7 @@ namespace Barotrauma.Items.Components
get { return rechargeSpeed; }
set
{
if (float.IsNaN(value)) return;
if (!MathUtils.IsValid(value)) return;
rechargeSpeed = MathHelper.Clamp(value, 0.0f, maxRechargeSpeed);
rechargeSpeed = MathUtils.Round(rechargeSpeed, Math.Max(maxRechargeSpeed * 0.1f, 1.0f));
}
@@ -120,7 +120,7 @@ namespace Barotrauma.Items.Components
foreach (Connection c in item.Connections)
{
if (c.Name.Contains("recharge")) continue;
if (c.Name == "power_in") continue;
foreach (Connection c2 in c.Recipients)
{
PowerTransfer pt = c2.Item.GetComponent<PowerTransfer>();
@@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components
// 0.1f);
//powerConsumption = Math.Min(powerConsumption, 0.0f);
charge -= CurrPowerOutput / 3600.0f;
Charge -= CurrPowerOutput / 3600.0f;
}
rechargeVoltage = 0.0f;
@@ -212,7 +212,7 @@ namespace Barotrauma.Items.Components
{
if (!connection.IsPower) return;
if (connection.Name.Contains("recharge"))
if (connection.Name == "power_in")
{
rechargeVoltage = power;
}
@@ -247,11 +247,10 @@ namespace Barotrauma.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
spriteBatch.DrawString(GUI.Font,
"Charge: " + (int)charge + "/" + (int)capacity + " (" + (int)((charge / capacity) * 100.0f) + " %)",
"Charge: " + (int)charge + "/" + (int)capacity + "kWm (" + (int)((charge / capacity) * 100.0f) + " %)",
new Vector2(x + 30, y + 30), Color.White);
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed)*100.0f)+" %", new Vector2(x + 30, y + 95), Color.White);
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", new Vector2(x + 30, y + 95), Color.White);
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)

View File

@@ -132,7 +132,7 @@ namespace Barotrauma.Items.Components
}
else if (powerContainer != null)
{
if (recipient.Name.Contains("recharge"))
if (recipient.Name == "power_in")
{
fullLoad += powerContainer.CurrPowerConsumption;
}
@@ -167,8 +167,8 @@ namespace Barotrauma.Items.Components
GuiFrame.Draw(spriteBatch);
spriteBatch.DrawString(GUI.Font, "Power: " + (int)(-currPowerConsumption), new Vector2(x + 30, y + 30), Color.White);
spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad, new Vector2(x + 30, y + 100), Color.White);
spriteBatch.DrawString(GUI.Font, "Power: " + (int)(-currPowerConsumption) + " kW", new Vector2(x + 30, y + 30), Color.White);
spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad + " kW", new Vector2(x + 30, y + 100), Color.White);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)

View File

@@ -249,8 +249,8 @@ namespace Barotrauma.Items.Components
}
else
{
c.Draw(spriteBatch, panel.Item, leftPos,
new Vector2(leftPos.X - 100, leftPos.Y),
c.Draw(spriteBatch, panel.Item, leftPos,
new Vector2(leftPos.X - GUI.SmallFont.MeasureString(c.Name).X - 20, leftPos.Y),
new Vector2(leftWireX, y + height),
mouseInRect, equippedWire != null);
@@ -291,7 +291,7 @@ namespace Barotrauma.Items.Components
if (draggingConnected != null)
{
if (!PlayerInput.LeftButtonDown())
if (!PlayerInput.LeftButtonHeld())
{
panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(Character);
@@ -306,7 +306,7 @@ namespace Barotrauma.Items.Components
private void Draw(SpriteBatch spriteBatch, Item item, Vector2 position, Vector2 labelPos, Vector2 wirePosition, bool mouseIn, bool wireEquipped)
{
spriteBatch.DrawString(GUI.Font, Name, new Vector2(labelPos.X, labelPos.Y-10), Color.White);
spriteBatch.DrawString(GUI.SmallFont, Name, new Vector2(labelPos.X, labelPos.Y-10), Color.White);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)position.X-10, (int)position.Y-10, 20, 20), Color.White);
spriteBatch.Draw(panelTexture, position - new Vector2(16.0f, 16.0f), new Rectangle(64, 256, 32, 32), Color.White);
@@ -323,7 +323,7 @@ namespace Barotrauma.Items.Components
//dragging a wire and released the mouse -> see if the wire can be connected to this connection
if (draggingConnected != null
&& !PlayerInput.LeftButtonDown())
&& !PlayerInput.LeftButtonHeld())
{
//close enough to the connector -> make a new connection
if (Vector2.Distance(position, PlayerInput.MousePosition) < 10.0f)
@@ -404,7 +404,7 @@ namespace Barotrauma.Items.Components
float dir = (end.X > start.X) ? -1.0f : 1.0f;
wireCorner.Draw(spriteBatch,
new Vector2(start.X, end.Y+24), wireItem.Color * alpha, 0.0f, 1.0f,
new Vector2(start.X, end.Y+25), wireItem.Color * alpha, 0.0f, 1.0f,
(end.X > start.X) ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
float wireStartX = start.X - wireCorner.size.X / 2 * dir;
@@ -426,7 +426,7 @@ namespace Barotrauma.Items.Components
{
item.IsHighlighted = true;
//start dragging the wire
if (PlayerInput.LeftButtonDown()) draggingConnected = wireItem;
if (PlayerInput.LeftButtonHeld()) draggingConnected = wireItem;
}
}

View File

@@ -351,7 +351,7 @@ namespace Barotrauma.Items.Components
if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny)
{
if (PlayerInput.LeftButtonClicked())
if (PlayerInput.LeftButtonDown())
{
MapEntity.DisableSelect = true;
MapEntity.SelectEntity(item);
@@ -367,7 +367,7 @@ namespace Barotrauma.Items.Components
}
}
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonHeld())
{
if (selectedNodeIndex != null && draggingWire == this)
{

View File

@@ -159,10 +159,10 @@ namespace Barotrauma.Items.Components
float availablePower = 0.0f;
foreach (PowerContainer battery in batteries)
{
float batteryPower = Math.Min(battery.Charge, battery.MaxOutPut);
float takePower = Math.Min(currPowerConsumption - availablePower, batteryPower);
float batteryPower = Math.Min(battery.Charge*3600.0f, battery.MaxOutPut);
float takePower = Math.Min(powerConsumption - availablePower, batteryPower);
battery.Charge -= takePower;
battery.Charge -= takePower/3600.0f;
}
reload = reloadTime;
@@ -284,7 +284,7 @@ namespace Barotrauma.Items.Components
float availablePower = 0.0f;
foreach (PowerContainer battery in batteries)
{
float batteryPower = Math.Min(battery.Charge, battery.MaxOutPut);
float batteryPower = Math.Min(battery.Charge*3600.0f, battery.MaxOutPut);
availablePower += batteryPower;
}

View File

@@ -205,7 +205,7 @@ namespace Barotrauma
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.Container == this.Owner)
{
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonHeld())
{
slotRect.X = (int)PlayerInput.MousePosition.X - slotRect.Width / 2;
slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2;
@@ -261,7 +261,7 @@ namespace Barotrauma
{
if (draggingItem == null)
{
if (PlayerInput.LeftButtonDown())
if (PlayerInput.LeftButtonHeld())
{
draggingItem = item;
}

View File

@@ -114,7 +114,7 @@ namespace Barotrauma
if (placePosition == Vector2.Zero)
{
if (PlayerInput.LeftButtonDown()) placePosition = position;
if (PlayerInput.LeftButtonHeld()) placePosition = position;
}
else
{