- fixed light components throwing errors when receiving an invalid color value to the "set_color" input

- fixed it being possible to connect wires to more than two items by selecting another item while dragging the wire
- relay components break if too much power is directed through them
- relay components are active by default and the can be toggled on/off in the editor
- bool properties show as checkboxes in the editor
This commit is contained in:
Regalis
2016-03-17 19:16:21 +02:00
parent d6a57f9533
commit 20d61b0647
6 changed files with 120 additions and 60 deletions

View File

@@ -1,9 +1,32 @@
using System.Xml.Linq;
using System;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{
class RelayComponent : ItemComponent
{
private float maxPower;
[Editable, HasDefaultValue(1000.0f, true)]
public float MaxPower
{
get { return maxPower; }
set
{
maxPower = Math.Max(0.0f, value);
}
}
[Editable, HasDefaultValue(false, true)]
public bool IsOn
{
get { return IsActive; }
set
{
IsActive = value;
}
}
public RelayComponent(Item item, XElement element)
: base (item, element)
{
@@ -12,6 +35,10 @@ namespace Barotrauma.Items.Components
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
if (item.Condition <= 0.0f) return;
if (power > maxPower) item.Condition = 0.0f;
if (connection.Name.Contains("_in"))
{
if (!IsActive) return;