Launcher bugfixes, fixed submarine position syncing, previewing the sub after round ends, wiring bugfix, slower reactor overheat, itemlabel, wifi components
This commit is contained in:
@@ -319,14 +319,13 @@ namespace Subsurface.Items.Components
|
||||
if (index>-1)
|
||||
{
|
||||
Wires[index].RemoveConnection(this);
|
||||
Wires[index].Item.SetTransform(item.SimPosition, 0.0f);
|
||||
Wires[index].Item.Drop();
|
||||
Wires[index].Item.body.Enabled = true;
|
||||
//Wires[index].Item.SetTransform(item.SimPosition, 0.0f);
|
||||
//Wires[index].Item.Drop();
|
||||
//Wires[index].Item.body.Enabled = true;
|
||||
Wires[index] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private string expression;
|
||||
|
||||
private string receivedSignal;
|
||||
|
||||
[InGameEditable, HasDefaultValue("1", true)]
|
||||
public string Output
|
||||
{
|
||||
@@ -26,6 +28,27 @@ namespace Subsurface.Items.Components
|
||||
public RegExFindComponent(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(expression)) return;
|
||||
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
Regex regex = new Regex(@expression);
|
||||
Match match = regex.Match(receivedSignal);
|
||||
success = match.Success;
|
||||
}
|
||||
catch
|
||||
{
|
||||
item.SendSignal("ERROR", "signal_out");
|
||||
return;
|
||||
}
|
||||
|
||||
item.SendSignal(success ? output : "0", "signal_out");
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0.0f)
|
||||
@@ -33,22 +56,7 @@ namespace Subsurface.Items.Components
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "signal_in":
|
||||
if (string.IsNullOrWhiteSpace(expression)) return;
|
||||
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
Regex regex = new Regex(@expression);
|
||||
Match match = regex.Match(signal);
|
||||
success = match.Success;
|
||||
}
|
||||
catch
|
||||
{
|
||||
item.SendSignal("ERROR", "signal_out");
|
||||
return;
|
||||
}
|
||||
|
||||
item.SendSignal(success ? output : "0", "signal_out");
|
||||
receivedSignal = signal;
|
||||
|
||||
break;
|
||||
case "set_output":
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface.Items.Components
|
||||
{
|
||||
class WifiComponent : ItemComponent
|
||||
{
|
||||
|
||||
private static List<WifiComponent> list = new List<WifiComponent>();
|
||||
|
||||
private int channel;
|
||||
|
||||
[InGameEditable, HasDefaultValue(1, true)]
|
||||
public int Channel
|
||||
{
|
||||
get { return channel; }
|
||||
set
|
||||
{
|
||||
channel = MathHelper.Clamp(value, 0, 100);
|
||||
}
|
||||
}
|
||||
|
||||
public WifiComponent(Item item, XElement element)
|
||||
: base (item, element)
|
||||
{
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
{
|
||||
//prevent an ininite loop of wificomponents sending messages between each other
|
||||
if (sender.GetComponent<WifiComponent>()!=null) return;
|
||||
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "signal_in":
|
||||
foreach (WifiComponent wifiComp in list)
|
||||
{
|
||||
if (wifiComp == this || wifiComp.channel != channel) continue;
|
||||
wifiComp.item.SendSignal(signal, "signal_out");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
base.Remove();
|
||||
|
||||
list.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user