v0.10.5.1
This commit is contained in:
@@ -12,6 +12,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
private static readonly List<WifiComponent> list = new List<WifiComponent>();
|
||||
|
||||
const int ChannelMemorySize = 10;
|
||||
|
||||
private float range;
|
||||
|
||||
private int channel;
|
||||
@@ -20,6 +22,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private string prevSignal;
|
||||
|
||||
private int[] channelMemory = new int[ChannelMemorySize];
|
||||
|
||||
[Serialize(Character.TeamType.None, true, description: "WiFi components can only communicate with components that have the same Team ID.", alwaysUseInstanceValues: true)]
|
||||
public Character.TeamType TeamID { get; set; }
|
||||
|
||||
@@ -36,7 +40,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
[InGameEditable, Serialize(1, true, description: "WiFi components can only communicate with components that use the same channel.", alwaysUseInstanceValues: true)]
|
||||
[InGameEditable, Serialize(0, true, description: "WiFi components can only communicate with components that use the same channel.", alwaysUseInstanceValues: true)]
|
||||
public int Channel
|
||||
{
|
||||
get { return channel; }
|
||||
@@ -83,6 +87,18 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
list.Add(this);
|
||||
IsActive = true;
|
||||
channelMemory = element.GetAttributeIntArray("channelmemory", new int[ChannelMemorySize]);
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
{
|
||||
if (channelMemory.All(m => m == 0))
|
||||
{
|
||||
for (int i = 0; i < channelMemory.Length; i++)
|
||||
{
|
||||
channelMemory[i] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanTransmit()
|
||||
@@ -118,6 +134,24 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public int GetChannelMemory(int index)
|
||||
{
|
||||
if (index < 0 || index >= ChannelMemorySize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return channelMemory[index];
|
||||
}
|
||||
|
||||
public void SetChannelMemory(int index, int value)
|
||||
{
|
||||
if (index < 0 || index >= ChannelMemorySize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
channelMemory[index] = MathHelper.Clamp(value, 0, 10000);
|
||||
}
|
||||
|
||||
public void TransmitSignal(int stepsTaken, string signal, Item source, Character sender, bool sendToChat, float signalStrength = 1.0f)
|
||||
{
|
||||
var senderComponent = source?.GetComponent<WifiComponent>();
|
||||
@@ -220,5 +254,12 @@ namespace Barotrauma.Items.Components
|
||||
base.RemoveComponentSpecific();
|
||||
list.Remove(this);
|
||||
}
|
||||
|
||||
public override XElement Save(XElement parentElement)
|
||||
{
|
||||
var element = base.Save(parentElement);
|
||||
element.Add(new XAttribute("channelmemory", string.Join(',', channelMemory)));
|
||||
return element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user