Wifi components can't communicate with the enemy sub in combat missions. Fixes #554
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using Barotrauma.Items.Components;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
@@ -135,6 +136,11 @@ namespace Barotrauma
|
|||||||
if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc))
|
if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc))
|
||||||
item.Description = spawnPoint.IdCardDesc;
|
item.Description = spawnPoint.IdCardDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
|
||||||
|
{
|
||||||
|
wifiComponent.TeamID = character.TeamID;
|
||||||
|
}
|
||||||
|
|
||||||
if (parentItem != null) parentItem.Combine(item);
|
if (parentItem != null) parentItem.Combine(item);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Items.Components;
|
||||||
|
using Barotrauma.Networking;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -72,7 +73,7 @@ namespace Barotrauma
|
|||||||
descriptions[i] = descriptions[i].Replace("[location" + (n + 1) + "]", locations[n].Name);
|
descriptions[i] = descriptions[i].Replace("[location" + (n + 1) + "]", locations[n].Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
teamNames = new string[]
|
teamNames = new string[]
|
||||||
{
|
{
|
||||||
prefab.ConfigElement.GetAttributeString("teamname1", "Team A"),
|
prefab.ConfigElement.GetAttributeString("teamname1", "Team A"),
|
||||||
@@ -145,6 +146,23 @@ namespace Barotrauma
|
|||||||
subs[1].SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
subs[1].SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
||||||
subs[1].FlipX();
|
subs[1].FlipX();
|
||||||
|
|
||||||
|
//prevent wifi components from communicating between subs
|
||||||
|
List<WifiComponent> wifiComponents = new List<WifiComponent>();
|
||||||
|
foreach (Item item in Item.ItemList)
|
||||||
|
{
|
||||||
|
wifiComponents.AddRange(item.GetComponents<WifiComponent>());
|
||||||
|
}
|
||||||
|
foreach (WifiComponent wifiComponent in wifiComponents)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
if (wifiComponent.Item.Submarine == subs[i] || subs[i].DockedTo.Contains(wifiComponent.Item.Submarine))
|
||||||
|
{
|
||||||
|
wifiComponent.TeamID = subs[i].TeamID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
crews = new List<Character>[] { new List<Character>(), new List<Character>() };
|
crews = new List<Character>[] { new List<Character>(), new List<Character>() };
|
||||||
|
|
||||||
foreach (Submarine submarine in Submarine.Loaded)
|
foreach (Submarine submarine in Submarine.Loaded)
|
||||||
@@ -208,7 +226,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (winner>=0 && subs[winner] != null &&
|
if (winner >= 0 && subs[winner] != null &&
|
||||||
(winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) &&
|
(winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) &&
|
||||||
crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner]))
|
crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner]))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private int channel;
|
private int channel;
|
||||||
|
|
||||||
|
public byte TeamID;
|
||||||
|
|
||||||
[Serialize(20000.0f, false)]
|
[Serialize(20000.0f, false)]
|
||||||
public float Range
|
public float Range
|
||||||
{
|
{
|
||||||
@@ -59,7 +61,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (!HasRequiredContainedItems(false)) return false;
|
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;
|
return Vector2.Distance(item.WorldPosition, sender.item.WorldPosition) <= sender.Range;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1647,7 +1647,15 @@ namespace Barotrauma
|
|||||||
int index = ParentInventory.FindIndex(this);
|
int index = ParentInventory.FindIndex(this);
|
||||||
msg.Write(index < 0 ? (byte)255 : (byte)index);
|
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));
|
bool tagsChanged = tags.Count != prefab.Tags.Count || !tags.All(t => prefab.Tags.Contains(t));
|
||||||
msg.Write(tagsChanged);
|
msg.Write(tagsChanged);
|
||||||
if (tagsChanged)
|
if (tagsChanged)
|
||||||
@@ -1692,6 +1700,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte teamID = msg.ReadByte();
|
||||||
bool tagsChanged = msg.ReadBoolean();
|
bool tagsChanged = msg.ReadBoolean();
|
||||||
string tags = "";
|
string tags = "";
|
||||||
if (tagsChanged)
|
if (tagsChanged)
|
||||||
@@ -1725,15 +1734,22 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = new Item(itemPrefab, pos, sub);
|
var item = new Item(itemPrefab, pos, sub)
|
||||||
item.ID = itemId;
|
{
|
||||||
|
ID = itemId
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
|
||||||
|
{
|
||||||
|
wifiComponent.TeamID = teamID;
|
||||||
|
}
|
||||||
if (descriptionChanged) item.Description = itemDesc;
|
if (descriptionChanged) item.Description = itemDesc;
|
||||||
if (tagsChanged) item.Tags = tags;
|
if (tagsChanged) item.Tags = tags;
|
||||||
|
|
||||||
if (sub != null)
|
if (sub != null)
|
||||||
{
|
{
|
||||||
item.CurrentHull = Hull.FindHull(pos + sub.Position, null, true);
|
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)
|
if (inventory != null)
|
||||||
|
|||||||
@@ -1309,8 +1309,8 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, assignedWayPoints[i].WorldPosition, true, false);
|
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, assignedWayPoints[i].WorldPosition, true, false);
|
||||||
spawnedCharacter.AnimController.Frozen = true;
|
spawnedCharacter.AnimController.Frozen = true;
|
||||||
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
|
||||||
spawnedCharacter.TeamID = (byte)teamID;
|
spawnedCharacter.TeamID = (byte)teamID;
|
||||||
|
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
||||||
|
|
||||||
teamClients[i].Character = spawnedCharacter;
|
teamClients[i].Character = spawnedCharacter;
|
||||||
|
|
||||||
@@ -1323,8 +1323,8 @@ namespace Barotrauma.Networking
|
|||||||
if (characterInfo != null && hostTeam == teamID)
|
if (characterInfo != null && hostTeam == teamID)
|
||||||
{
|
{
|
||||||
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
||||||
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
|
||||||
myCharacter.TeamID = (byte)teamID;
|
myCharacter.TeamID = (byte)teamID;
|
||||||
|
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
||||||
|
|
||||||
Character.Controlled = myCharacter;
|
Character.Controlled = myCharacter;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user