Wifi components can't communicate with the enemy sub in combat missions. Fixes #554
This commit is contained in:
@@ -14,6 +14,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private int channel;
|
||||
|
||||
public byte TeamID;
|
||||
|
||||
[Serialize(20000.0f, false)]
|
||||
public float Range
|
||||
{
|
||||
@@ -59,7 +61,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (!HasRequiredContainedItems(false)) return false;
|
||||
|
||||
if (sender == null || sender.channel != channel) return false;
|
||||
if (sender == null || sender.channel != channel || sender.TeamID != TeamID) return false;
|
||||
|
||||
return Vector2.Distance(item.WorldPosition, sender.item.WorldPosition) <= sender.Range;
|
||||
}
|
||||
|
||||
@@ -1647,7 +1647,15 @@ namespace Barotrauma
|
||||
int index = ParentInventory.FindIndex(this);
|
||||
msg.Write(index < 0 ? (byte)255 : (byte)index);
|
||||
}
|
||||
|
||||
|
||||
byte teamID = 0;
|
||||
foreach (WifiComponent wifiComponent in GetComponents<WifiComponent>())
|
||||
{
|
||||
teamID = wifiComponent.TeamID;
|
||||
break;
|
||||
}
|
||||
|
||||
msg.Write(teamID);
|
||||
bool tagsChanged = tags.Count != prefab.Tags.Count || !tags.All(t => prefab.Tags.Contains(t));
|
||||
msg.Write(tagsChanged);
|
||||
if (tagsChanged)
|
||||
@@ -1692,6 +1700,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
byte teamID = msg.ReadByte();
|
||||
bool tagsChanged = msg.ReadBoolean();
|
||||
string tags = "";
|
||||
if (tagsChanged)
|
||||
@@ -1725,15 +1734,22 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var item = new Item(itemPrefab, pos, sub);
|
||||
item.ID = itemId;
|
||||
var item = new Item(itemPrefab, pos, sub)
|
||||
{
|
||||
ID = itemId
|
||||
};
|
||||
|
||||
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
|
||||
{
|
||||
wifiComponent.TeamID = teamID;
|
||||
}
|
||||
if (descriptionChanged) item.Description = itemDesc;
|
||||
if (tagsChanged) item.Tags = tags;
|
||||
|
||||
if (sub != null)
|
||||
{
|
||||
item.CurrentHull = Hull.FindHull(pos + sub.Position, null, true);
|
||||
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine;
|
||||
item.Submarine = item.CurrentHull?.Submarine;
|
||||
}
|
||||
|
||||
if (inventory != null)
|
||||
|
||||
Reference in New Issue
Block a user