From ed529052a2b9d38379ce00e87993fc678451ab90 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 24 May 2016 19:17:42 +0300 Subject: [PATCH] - relaycomponent inherits from powertransfer, so that they're included when calculating the load/power for the grid - deactivated powertransfer components don't carry power - fixed reactor graph lines going over the graph if load > 10 000 --- Subsurface/Content/Items/blank.png | Bin 1631 -> 585 bytes .../Source/Items/Components/ItemLabel.cs | 8 +++++- .../Items/Components/Machines/Reactor.cs | 10 ++++++-- .../Items/Components/Power/PowerContainer.cs | 2 +- .../Items/Components/Power/PowerTransfer.cs | 2 +- .../Items/Components/Signal/RelayComponent.cs | 24 +++++++++++++++--- 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Subsurface/Content/Items/blank.png b/Subsurface/Content/Items/blank.png index 9a1af98011ac848e82df474fb3263f2d88f0bb6e..8cc7ad79c38beebcb71c29a2ddd7941d0d0985d7 100644 GIT binary patch delta 551 zcmV+?0@(fE49Nr`iBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUad2e*g(^ zNLh0L01m_e01m_fl`9S#0005cNkl+MJV%y= zplKQ=zkYn3-g@kFV$LV-F+SfrV(+-_EBbZCo-10A%(jU`OJ#05S`3(Xx?&1ZUN1*c00Yqss1m zHqm>Ks`f=0q$&{LW9Q;bCY(XTCjscJK^es8S4-Z4_5PM21AhiW-2_<-u$xdDeog8P zV~4&PUDR#3HG@~$bU^v6<((q?(*lfp&+luJ6HKOaC*G?9$(k?*ltVSdijXIL-<+t8mS= zR56-O;iOyRTCIFzWa!ub@jiRTummM{;UGx;xrk7Y`cUdmIdwEE)7Tt}y&WFgLtO=O pXsu&Q&6dDj`4cJN7QFJE_zUowHxz$bxSaq1002ovPDHLkV1kBh0OtSz delta 1606 zcmV-M2D$mk1m6rciBL{Q4GJ0x0000DNk~Le0000W0000W2nGNE0CReJ^Z)<=32;bR za{vGf6951U69E94oEVWIE`J5(Nkl-B>IFyvZ5LvNVF~@FJuuB;J~NY`+sourmB#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2PDh64&hz+wwUC2O zD`ALpb_+^OJi~Ka?q}udcem$`DI)rASc3Cgp7{R&61>^!JEm5(00000Ne4wvM6N<$ Ef@UKIB>(^b diff --git a/Subsurface/Source/Items/Components/ItemLabel.cs b/Subsurface/Source/Items/Components/ItemLabel.cs index 7837ad5c0..a26acc44e 100644 --- a/Subsurface/Source/Items/Components/ItemLabel.cs +++ b/Subsurface/Source/Items/Components/ItemLabel.cs @@ -14,6 +14,12 @@ namespace Barotrauma.Items.Components set { if (value == TextBlock.Text || item.Rect.Width < 5) return; + + if (textBlock.Rect.Width != item.Rect.Width || textBlock.Rect.Height != item.Rect.Height) + { + textBlock = null; + } + TextBlock.Text = value; } } @@ -57,7 +63,7 @@ namespace Barotrauma.Items.Components : base(item, element) { } - + public override void Draw(SpriteBatch spriteBatch, bool editing = false) { base.Draw(spriteBatch, editing); diff --git a/Subsurface/Source/Items/Components/Machines/Reactor.cs b/Subsurface/Source/Items/Components/Machines/Reactor.cs index cbe18715c..f809c0086 100644 --- a/Subsurface/Source/Items/Components/Machines/Reactor.cs +++ b/Subsurface/Source/Items/Components/Machines/Reactor.cs @@ -452,11 +452,17 @@ namespace Barotrauma.Items.Components spriteBatch.DrawString(GUI.Font, "Grid load: " + (int)load + " kW", new Vector2(x + 600, y + 30), Color.Yellow); + float maxLoad = 0.0f; + foreach (float loadVal in loadGraph) + { + maxLoad = Math.Max(maxLoad, loadVal); + } + DrawGraph(tempGraph, spriteBatch, - new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Red); + new Rectangle(x + 30, y + 30, 400, 250), Math.Max(10000.0f, maxLoad), xOffset, Color.Red); DrawGraph(loadGraph, spriteBatch, - new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Yellow); + new Rectangle(x + 30, y + 30, 400, 250), Math.Max(10000.0f, maxLoad), xOffset, Color.Yellow); spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + (int)shutDownTemp, new Vector2(x + 450, y + 80), Color.White); diff --git a/Subsurface/Source/Items/Components/Power/PowerContainer.cs b/Subsurface/Source/Items/Components/Power/PowerContainer.cs index 5ecaa21bd..85ff2bd07 100644 --- a/Subsurface/Source/Items/Components/Power/PowerContainer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerContainer.cs @@ -124,7 +124,7 @@ namespace Barotrauma.Items.Components foreach (Connection c2 in c.Recipients) { PowerTransfer pt = c2.Item.GetComponent(); - if (pt == null) continue; + if (pt == null || !pt.IsActive) continue; gridLoad += pt.PowerLoad; } diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index d4a8c5198..c443b8e1d 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -130,7 +130,7 @@ namespace Barotrauma.Items.Components //if (it.Updated) continue; Powered powered = it.GetComponent(); - if (powered == null) continue; + if (powered == null || !powered.IsActive) continue; if (connectedList.Contains(powered)) continue; diff --git a/Subsurface/Source/Items/Components/Signal/RelayComponent.cs b/Subsurface/Source/Items/Components/Signal/RelayComponent.cs index 958dffa13..92511b0c5 100644 --- a/Subsurface/Source/Items/Components/Signal/RelayComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/RelayComponent.cs @@ -3,7 +3,7 @@ using System.Xml.Linq; namespace Barotrauma.Items.Components { - class RelayComponent : ItemComponent + class RelayComponent : PowerTransfer { private float maxPower; @@ -17,27 +17,43 @@ namespace Barotrauma.Items.Components } } + private bool isOn; + [Editable, HasDefaultValue(false, true)] public bool IsOn { - get; set; + get + { + return IsActive; + } + set + { + isOn = value; + IsActive = value; + if (!IsActive) + { + currPowerConsumption = 0.0f; + } + } } public RelayComponent(Item item, XElement element) : base (item, element) { - IsActive = true; - IsOn = true; + IsActive = isOn; } public override void Update(float deltaTime, Camera cam) { + base.Update(deltaTime, cam); item.SendSignal(0, IsOn ? "1" : "0", "state_out"); } public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f) { + if (connection.IsPower && connection.Name.Contains("_out")) return; + if (item.Condition <= 0.0f) return; if (power > maxPower) item.Condition = 0.0f;