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
@@ -8,9 +8,9 @@
Tags="smallitem" Tags="smallitem"
pickdistance="150"> pickdistance="150">
<Sprite texture="lamp.png" sourcerect="0,0,16,32" depth="0.8"/> <Sprite texture="lamp.png" sourcerect="0,0,16,32" depth="0.8"/>
<LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="50"> <LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="5">
<sprite texture="Content/Items/Electricity/lamp.png" sourcerect="33,0,31,39"/> <sprite texture="Content/Items/Electricity/lamp.png" sourcerect="33,0,31,39"/>
</LightComponent> </LightComponent>
@@ -54,8 +54,8 @@
<Explosion range="100.0" damage="15" stun="10" force="3.0" flames="false" shockwave="false" sparks="true"/> <Explosion range="100.0" damage="15" stun="10" force="3.0" flames="false" shockwave="false" sparks="true"/>
</StatusEffect> </StatusEffect>
<requireditem name="Screwdriver" type="Equipped"/> <requireditem name="Screwdriver" type="Equipped"/>
<input name="power"/> <input name="power_out"/>
<input name="recharge"/> <input name="power_in"/>
</ConnectionPanel> </ConnectionPanel>
<ItemContainer capacity="3" hideitems="true"> <ItemContainer capacity="3" hideitems="true">
@@ -68,11 +68,11 @@
category="Electrical" category="Electrical"
linkable="true" linkable="true"
pickdistance="150" pickdistance="150"
description="Can accept and deliver charge much faster than batteries."> description="Can take in and deliver power much faster than batteries.">
<Sprite texture ="supercapacitor.png" depth="0.8"/> <Sprite texture ="supercapacitor.png" depth="0.8"/>
<PowerContainer capacity="2000.0" maxrechargespeed="2000.0" maxoutput="2000.0" canbeselected = "true"> <PowerContainer capacity="20.0" maxrechargespeed="20.0" maxoutput="2000000.0" canbeselected = "true">
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/> <GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</PowerContainer> </PowerContainer>
@@ -81,7 +81,8 @@
<Explosion range="100.0" damage="30" stun="20" force="5.0" shockwave="false" sparks="true"/> <Explosion range="100.0" damage="30" stun="20" force="5.0" shockwave="false" sparks="true"/>
</StatusEffect> </StatusEffect>
<requireditem name="Screwdriver" type="Equipped"/> <requireditem name="Screwdriver" type="Equipped"/>
<input name="power"/> <input name="power_out"/>
<input name="power_in"/>
</ConnectionPanel> </ConnectionPanel>
</Item> </Item>
</Items> </Items>
+1 -1
View File
@@ -11,7 +11,7 @@
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128" <Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128"
rotationlimits="180,360" rotationlimits="180,360"
powerconsumption="500.0"> powerconsumption="20000.0">
<StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg"> <StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg">
<Explosion range="1000.0" structuredamage="0" force="0.01" camerashake="10.0"/> <Explosion range="1000.0" structuredamage="0" force="0.01" camerashake="10.0"/>
</StatusEffect> </StatusEffect>
+1 -1
View File
@@ -300,7 +300,7 @@ namespace Barotrauma
if (rect.Contains(PlayerInput.MousePosition)) if (rect.Contains(PlayerInput.MousePosition))
{ {
clicked = PlayerInput.LeftButtonDown(); clicked = PlayerInput.LeftButtonHeld();
color = clicked ? new Color(100, 100, 100) : new Color(250, 250, 250); color = clicked ? new Color(100, 100, 100) : new Color(250, 250, 250);
+1 -1
View File
@@ -152,7 +152,7 @@ namespace Barotrauma
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn))) if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
{ {
state = ComponentState.Hover; state = ComponentState.Hover;
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
if (OnPressed != null) if (OnPressed != null)
{ {
+1 -1
View File
@@ -129,7 +129,7 @@ namespace Barotrauma
base.Update(deltaTime); base.Update(deltaTime);
if (draggingBar != this) return; if (draggingBar != this) return;
if (!PlayerInput.LeftButtonDown()) draggingBar = null; if (!PlayerInput.LeftButtonHeld()) draggingBar = null;
MoveButton(); MoveButton();
} }
+1 -1
View File
@@ -70,7 +70,7 @@ namespace Barotrauma
box.State = ComponentState.Hover; box.State = ComponentState.Hover;
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
box.State = ComponentState.Selected; box.State = ComponentState.Selected;
} }
@@ -63,6 +63,20 @@ namespace Barotrauma.Tutorials
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }
infoBox = CreateInfoFrame("The reactor requires fuel rods to generate power. You can grab one from the steel cabinet by walking next to it and pressing E.");
while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.Name != "Steel Cabinet")
{
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("Pick up one of the fuel rods either by double-clicking or dragging and dropping it into your inventory.");
while (!HasItem("Fuel Rod"))
{
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("Select the reactor by walking next to it and pressing E."); infoBox = CreateInfoFrame("Select the reactor by walking next to it and pressing E.");
while (Character.Controlled.SelectedConstruction != reactor.Item) while (Character.Controlled.SelectedConstruction != reactor.Item)
@@ -71,7 +85,14 @@ namespace Barotrauma.Tutorials
} }
yield return new WaitForSeconds(0.5f); yield return new WaitForSeconds(0.5f);
infoBox = CreateInfoFrame("This is the control panel of the reactor. Try turning it on by increasing the fission rate."); infoBox = CreateInfoFrame("Load the fuel rod into the reactor by dropping it into any of the 5 slots.");
while (reactor.AvailableFuel <= 0.0f)
{
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("The reactor is now fueled up. Try turning it on by increasing the fission rate.");
while (reactor.FissionRate <= 0.0f) while (reactor.FissionRate <= 0.0f)
{ {
@@ -326,7 +326,7 @@ namespace Barotrauma
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition)) if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition))
{ {
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
slotRect.X = (int)PlayerInput.MousePosition.X - slotRect.Width / 2; slotRect.X = (int)PlayerInput.MousePosition.X - slotRect.Width / 2;
slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2; slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2;
@@ -442,9 +442,9 @@ namespace Barotrauma.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); //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); 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); new Vector2(x + 620, y + 30), Color.Yellow);
DrawGraph(tempGraph, spriteBatch, DrawGraph(tempGraph, spriteBatch,
@@ -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); 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 = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
targetVelocity.Y = -targetVelocity.Y; targetVelocity.Y = -targetVelocity.Y;
@@ -42,7 +42,7 @@ namespace Barotrauma.Items.Components
get { return charge; } get { return charge; }
set set
{ {
if (float.IsNaN(value)) return; if (!MathUtils.IsValid(value)) return;
charge = MathHelper.Clamp(value, 0.0f, capacity); charge = MathHelper.Clamp(value, 0.0f, capacity);
} }
} }
@@ -60,7 +60,7 @@ namespace Barotrauma.Items.Components
get { return rechargeSpeed; } get { return rechargeSpeed; }
set set
{ {
if (float.IsNaN(value)) return; if (!MathUtils.IsValid(value)) return;
rechargeSpeed = MathHelper.Clamp(value, 0.0f, maxRechargeSpeed); rechargeSpeed = MathHelper.Clamp(value, 0.0f, maxRechargeSpeed);
rechargeSpeed = MathUtils.Round(rechargeSpeed, Math.Max(maxRechargeSpeed * 0.1f, 1.0f)); 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) foreach (Connection c in item.Connections)
{ {
if (c.Name.Contains("recharge")) continue; if (c.Name == "power_in") continue;
foreach (Connection c2 in c.Recipients) foreach (Connection c2 in c.Recipients)
{ {
PowerTransfer pt = c2.Item.GetComponent<PowerTransfer>(); PowerTransfer pt = c2.Item.GetComponent<PowerTransfer>();
@@ -194,7 +194,7 @@ namespace Barotrauma.Items.Components
// 0.1f); // 0.1f);
//powerConsumption = Math.Min(powerConsumption, 0.0f); //powerConsumption = Math.Min(powerConsumption, 0.0f);
charge -= CurrPowerOutput / 3600.0f; Charge -= CurrPowerOutput / 3600.0f;
} }
rechargeVoltage = 0.0f; rechargeVoltage = 0.0f;
@@ -212,7 +212,7 @@ namespace Barotrauma.Items.Components
{ {
if (!connection.IsPower) return; if (!connection.IsPower) return;
if (connection.Name.Contains("recharge")) if (connection.Name == "power_in")
{ {
rechargeVoltage = power; rechargeVoltage = power;
} }
@@ -247,11 +247,10 @@ namespace Barotrauma.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
spriteBatch.DrawString(GUI.Font, 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); 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) public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
@@ -132,7 +132,7 @@ namespace Barotrauma.Items.Components
} }
else if (powerContainer != null) else if (powerContainer != null)
{ {
if (recipient.Name.Contains("recharge")) if (recipient.Name == "power_in")
{ {
fullLoad += powerContainer.CurrPowerConsumption; fullLoad += powerContainer.CurrPowerConsumption;
} }
@@ -167,8 +167,8 @@ namespace Barotrauma.Items.Components
GuiFrame.Draw(spriteBatch); GuiFrame.Draw(spriteBatch);
spriteBatch.DrawString(GUI.Font, "Power: " + (int)(-currPowerConsumption), new Vector2(x + 30, y + 30), 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, new Vector2(x + 30, y + 100), 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) public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
@@ -250,7 +250,7 @@ namespace Barotrauma.Items.Components
else else
{ {
c.Draw(spriteBatch, panel.Item, leftPos, c.Draw(spriteBatch, panel.Item, leftPos,
new Vector2(leftPos.X - 100, leftPos.Y), new Vector2(leftPos.X - GUI.SmallFont.MeasureString(c.Name).X - 20, leftPos.Y),
new Vector2(leftWireX, y + height), new Vector2(leftWireX, y + height),
mouseInRect, equippedWire != null); mouseInRect, equippedWire != null);
@@ -291,7 +291,7 @@ namespace Barotrauma.Items.Components
if (draggingConnected != null) if (draggingConnected != null)
{ {
if (!PlayerInput.LeftButtonDown()) if (!PlayerInput.LeftButtonHeld())
{ {
panel.Item.NewComponentEvent(panel, true, true); panel.Item.NewComponentEvent(panel, true, true);
//draggingConnected.Drop(Character); //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) 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); 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); 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 //dragging a wire and released the mouse -> see if the wire can be connected to this connection
if (draggingConnected != null if (draggingConnected != null
&& !PlayerInput.LeftButtonDown()) && !PlayerInput.LeftButtonHeld())
{ {
//close enough to the connector -> make a new connection //close enough to the connector -> make a new connection
if (Vector2.Distance(position, PlayerInput.MousePosition) < 10.0f) 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; float dir = (end.X > start.X) ? -1.0f : 1.0f;
wireCorner.Draw(spriteBatch, 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); (end.X > start.X) ? SpriteEffects.None : SpriteEffects.FlipHorizontally);
float wireStartX = start.X - wireCorner.size.X / 2 * dir; float wireStartX = start.X - wireCorner.size.X / 2 * dir;
@@ -426,7 +426,7 @@ namespace Barotrauma.Items.Components
{ {
item.IsHighlighted = true; item.IsHighlighted = true;
//start dragging the wire //start dragging the wire
if (PlayerInput.LeftButtonDown()) draggingConnected = wireItem; if (PlayerInput.LeftButtonHeld()) draggingConnected = wireItem;
} }
} }
@@ -351,7 +351,7 @@ namespace Barotrauma.Items.Components
if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny) if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny)
{ {
if (PlayerInput.LeftButtonClicked()) if (PlayerInput.LeftButtonDown())
{ {
MapEntity.DisableSelect = true; MapEntity.DisableSelect = true;
MapEntity.SelectEntity(item); MapEntity.SelectEntity(item);
@@ -367,7 +367,7 @@ namespace Barotrauma.Items.Components
} }
} }
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
if (selectedNodeIndex != null && draggingWire == this) if (selectedNodeIndex != null && draggingWire == this)
{ {
+4 -4
View File
@@ -159,10 +159,10 @@ namespace Barotrauma.Items.Components
float availablePower = 0.0f; float availablePower = 0.0f;
foreach (PowerContainer battery in batteries) foreach (PowerContainer battery in batteries)
{ {
float batteryPower = Math.Min(battery.Charge, battery.MaxOutPut); float batteryPower = Math.Min(battery.Charge*3600.0f, battery.MaxOutPut);
float takePower = Math.Min(currPowerConsumption - availablePower, batteryPower); float takePower = Math.Min(powerConsumption - availablePower, batteryPower);
battery.Charge -= takePower; battery.Charge -= takePower/3600.0f;
} }
reload = reloadTime; reload = reloadTime;
@@ -284,7 +284,7 @@ namespace Barotrauma.Items.Components
float availablePower = 0.0f; float availablePower = 0.0f;
foreach (PowerContainer battery in batteries) 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; availablePower += batteryPower;
} }
+2 -2
View File
@@ -205,7 +205,7 @@ namespace Barotrauma
if (draggingItem != null && !draggingItemSlot.Contains(PlayerInput.MousePosition) && draggingItem.Container == this.Owner) 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.X = (int)PlayerInput.MousePosition.X - slotRect.Width / 2;
slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2; slotRect.Y = (int)PlayerInput.MousePosition.Y - slotRect.Height / 2;
@@ -261,7 +261,7 @@ namespace Barotrauma
{ {
if (draggingItem == null) if (draggingItem == null)
{ {
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
draggingItem = item; draggingItem = item;
} }
+1 -1
View File
@@ -114,7 +114,7 @@ namespace Barotrauma
if (placePosition == Vector2.Zero) if (placePosition == Vector2.Zero)
{ {
if (PlayerInput.LeftButtonDown()) placePosition = position; if (PlayerInput.LeftButtonHeld()) placePosition = position;
} }
else else
{ {
+7 -3
View File
@@ -101,7 +101,11 @@ namespace Barotrauma
public float Oxygen public float Oxygen
{ {
get { return oxygen; } get { return oxygen; }
set { oxygen = MathHelper.Clamp(value, 0.0f, FullVolume); } set
{
if (!MathUtils.IsValid(value)) return;
oxygen = MathHelper.Clamp(value, 0.0f, FullVolume);
}
} }
public float OxygenPercentage public float OxygenPercentage
@@ -283,12 +287,12 @@ namespace Barotrauma
Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition); Vector2 position = cam.ScreenToWorld(PlayerInput.MousePosition);
if (Submarine.RectContains(WorldRect, position)) if (Submarine.RectContains(WorldRect, position))
{ {
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
//waveY[GetWaveIndex(position.X - rect.X - Submarine.Position.X) / WaveWidth] = 100.0f; //waveY[GetWaveIndex(position.X - rect.X - Submarine.Position.X) / WaveWidth] = 100.0f;
Volume = Volume + 1500.0f; Volume = Volume + 1500.0f;
} }
else if (PlayerInput.RightButtonDown()) else if (PlayerInput.RightButtonHeld())
{ {
Volume = Volume - 1500.0f; Volume = Volume - 1500.0f;
} }
+1 -1
View File
@@ -353,7 +353,7 @@ namespace Barotrauma
else else
{ {
if (PlayerInput.LeftButtonDown() && if (PlayerInput.LeftButtonHeld() &&
PlayerInput.KeyUp(Keys.Space)) PlayerInput.KeyUp(Keys.Space))
{ {
//if clicking a selected entity, start moving it //if clicking a selected entity, start moving it
+2 -2
View File
@@ -134,7 +134,7 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch, new Vector2(position.X, -(position.Y - GameMain.GraphicsHeight)), new Vector2(position.X, -(position.Y + GameMain.GraphicsHeight)), Color.White); GUI.DrawLine(spriteBatch, new Vector2(position.X, -(position.Y - GameMain.GraphicsHeight)), new Vector2(position.X, -(position.Y + GameMain.GraphicsHeight)), Color.White);
if (PlayerInput.LeftButtonDown()) placePosition = position; if (PlayerInput.LeftButtonHeld()) placePosition = position;
} }
else else
{ {
@@ -164,7 +164,7 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, newRect, Color.DarkBlue); GUI.DrawRectangle(spriteBatch, newRect, Color.DarkBlue);
} }
if (PlayerInput.RightButtonDown()) if (PlayerInput.RightButtonHeld())
{ {
placePosition = Vector2.Zero; placePosition = Vector2.Zero;
selected = null; selected = null;
+2 -2
View File
@@ -124,7 +124,7 @@ namespace Barotrauma
if (placePosition == Vector2.Zero) if (placePosition == Vector2.Zero)
{ {
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
placePosition = Submarine.MouseToWorldGrid(cam); placePosition = Submarine.MouseToWorldGrid(cam);
newRect.X = (int)position.X; newRect.X = (int)position.X;
@@ -161,7 +161,7 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth*2, newRect.Height), Color.White); GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth*2, newRect.Height), Color.White);
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight*2), Color.White); GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight*2), Color.White);
if (PlayerInput.RightButtonDown()) selected = null; if (PlayerInput.RightButtonHeld()) selected = null;
} }
} }
} }
+12 -4
View File
@@ -46,11 +46,11 @@ namespace Barotrauma
} }
else if (mouseButton == 0) else if (mouseButton == 0)
{ {
return PlayerInput.LeftButtonDown(); return PlayerInput.LeftButtonHeld();
} }
else if (mouseButton == 1) else if (mouseButton == 1)
{ {
return PlayerInput.RightButtonDown(); return PlayerInput.RightButtonHeld();
} }
return false; return false;
@@ -252,16 +252,24 @@ namespace Barotrauma
} }
public static bool LeftButtonDown() public static bool LeftButtonHeld()
{ {
return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Pressed; return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Pressed;
} }
public static bool LeftButtonDown()
{
return GameMain.WindowActive &&
oldMouseState.LeftButton == ButtonState.Released &&
mouseState.LeftButton == ButtonState.Pressed;
}
public static bool LeftButtonReleased() public static bool LeftButtonReleased()
{ {
return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Released; return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Released;
} }
public static bool LeftButtonClicked() public static bool LeftButtonClicked()
{ {
return (GameMain.WindowActive && return (GameMain.WindowActive &&
@@ -269,7 +277,7 @@ namespace Barotrauma
&& mouseState.LeftButton == ButtonState.Released); && mouseState.LeftButton == ButtonState.Released);
} }
public static bool RightButtonDown() public static bool RightButtonHeld()
{ {
return GameMain.WindowActive && mouseState.RightButton == ButtonState.Pressed; return GameMain.WindowActive && mouseState.RightButton == ButtonState.Pressed;
} }
@@ -194,7 +194,7 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitY * 5.0f, limbBodyPos - Vector2.UnitY * 5.0f, Color.White); GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitY * 5.0f, limbBodyPos - Vector2.UnitY * 5.0f, Color.White);
GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitX * 5.0f, limbBodyPos - Vector2.UnitX * 5.0f, Color.White); GUI.DrawLine(spriteBatch, limbBodyPos + Vector2.UnitX * 5.0f, limbBodyPos - Vector2.UnitX * 5.0f, Color.White);
if (Vector2.Distance(PlayerInput.MousePosition, limbBodyPos)<5.0f && PlayerInput.LeftButtonDown()) if (Vector2.Distance(PlayerInput.MousePosition, limbBodyPos)<5.0f && PlayerInput.LeftButtonHeld())
{ {
limb.sprite.Origin += PlayerInput.MouseSpeed; limb.sprite.Origin += PlayerInput.MouseSpeed;
} }
@@ -284,7 +284,7 @@ namespace Barotrauma
if (Vector2.Distance(PlayerInput.MousePosition, jointPos) < 6.0f) if (Vector2.Distance(PlayerInput.MousePosition, jointPos) < 6.0f)
{ {
GUI.DrawRectangle(spriteBatch, jointPos - new Vector2(3.0f, 3.0f), new Vector2(11.0f, 11.0f), Color.Red, false); GUI.DrawRectangle(spriteBatch, jointPos - new Vector2(3.0f, 3.0f), new Vector2(11.0f, 11.0f), Color.Red, false);
if (PlayerInput.LeftButtonDown()) if (PlayerInput.LeftButtonHeld())
{ {
Vector2 speed = ConvertUnits.ToSimUnits(PlayerInput.MouseSpeed); Vector2 speed = ConvertUnits.ToSimUnits(PlayerInput.MouseSpeed);
speed.Y = -speed.Y; speed.Y = -speed.Y;
+1 -1
View File
@@ -649,7 +649,7 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, cam); GUI.Draw((float)deltaTime, spriteBatch, cam);
if (!PlayerInput.LeftButtonDown()) Inventory.draggingItem = null; if (!PlayerInput.LeftButtonHeld()) Inventory.draggingItem = null;
spriteBatch.End(); spriteBatch.End();
} }
+1 -1
View File
@@ -202,7 +202,7 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, cam); GUI.Draw((float)deltaTime, spriteBatch, cam);
if (!PlayerInput.LeftButtonDown()) Inventory.draggingItem = null; if (!PlayerInput.LeftButtonHeld()) Inventory.draggingItem = null;
spriteBatch.End(); spriteBatch.End();
} }
Binary file not shown.