Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
This commit is contained in:
@@ -8,12 +8,15 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class WifiComponent : ItemComponent
|
||||
partial class WifiComponent : ItemComponent, IServerSerializable
|
||||
{
|
||||
private static readonly List<WifiComponent> list = new List<WifiComponent>();
|
||||
|
||||
const int ChannelMemorySize = 10;
|
||||
|
||||
private const int MinChannel = 0;
|
||||
private const int MaxChannel = 10000;
|
||||
|
||||
private float range;
|
||||
|
||||
private int channel;
|
||||
@@ -24,6 +27,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private readonly int[] channelMemory = new int[ChannelMemorySize];
|
||||
|
||||
private Connection signalInConnection;
|
||||
private Connection signalOutConnection;
|
||||
|
||||
[Serialize(CharacterTeamType.None, true, description: "WiFi components can only communicate with components that have the same Team ID.", alwaysUseInstanceValues: true)]
|
||||
@@ -48,7 +52,7 @@ namespace Barotrauma.Items.Components
|
||||
get { return channel; }
|
||||
set
|
||||
{
|
||||
channel = MathHelper.Clamp(value, 0, 10000);
|
||||
channel = MathHelper.Clamp(value, MinChannel, MaxChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +117,7 @@ namespace Barotrauma.Items.Components
|
||||
if (item.Connections != null)
|
||||
{
|
||||
signalOutConnection = item.Connections.Find(c => c.Name == "signal_out");
|
||||
signalInConnection = item.Connections.Find(c => c.Name == "signal_in");
|
||||
}
|
||||
if (channelMemory.All(m => m == 0))
|
||||
{
|
||||
@@ -227,6 +232,18 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (wifiComp.signalOutConnection != null)
|
||||
{
|
||||
if (signal.source != null && wifiComp.signalInConnection != null)
|
||||
{
|
||||
if (signal.source.LastSentSignalRecipients.Contains(wifiComp.signalInConnection))
|
||||
{
|
||||
//signal already passed through this wifi component -> stop here to prevent an infinite loop
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
signal.source.LastSentSignalRecipients.Add(wifiComp.signalInConnection);
|
||||
}
|
||||
}
|
||||
wifiComp.item.SendSignal(s, wifiComp.signalOutConnection);
|
||||
}
|
||||
|
||||
@@ -301,7 +318,14 @@ namespace Barotrauma.Items.Components
|
||||
case "set_channel":
|
||||
if (int.TryParse(signal.value, out int newChannel))
|
||||
{
|
||||
int prevChannel = Channel;
|
||||
Channel = newChannel;
|
||||
if (prevChannel != Channel)
|
||||
{
|
||||
#if SERVER
|
||||
item.CreateServerEvent(this);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "set_range":
|
||||
|
||||
Reference in New Issue
Block a user