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.Xml.Linq;
|
||||
|
||||
@@ -135,6 +136,11 @@ namespace Barotrauma
|
||||
if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc))
|
||||
item.Description = spawnPoint.IdCardDesc;
|
||||
}
|
||||
|
||||
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
|
||||
{
|
||||
wifiComponent.TeamID = character.TeamID;
|
||||
}
|
||||
|
||||
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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -72,7 +73,7 @@ namespace Barotrauma
|
||||
descriptions[i] = descriptions[i].Replace("[location" + (n + 1) + "]", locations[n].Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
teamNames = new string[]
|
||||
{
|
||||
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].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>() };
|
||||
|
||||
foreach (Submarine submarine in Submarine.Loaded)
|
||||
@@ -208,7 +226,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (winner>=0 && subs[winner] != null &&
|
||||
if (winner >= 0 && subs[winner] != null &&
|
||||
(winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) &&
|
||||
crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner]))
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1309,8 +1309,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, assignedWayPoints[i].WorldPosition, true, false);
|
||||
spawnedCharacter.AnimController.Frozen = true;
|
||||
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
||||
spawnedCharacter.TeamID = (byte)teamID;
|
||||
spawnedCharacter.GiveJobItems(assignedWayPoints[i]);
|
||||
|
||||
teamClients[i].Character = spawnedCharacter;
|
||||
|
||||
@@ -1323,8 +1323,8 @@ namespace Barotrauma.Networking
|
||||
if (characterInfo != null && hostTeam == teamID)
|
||||
{
|
||||
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);
|
||||
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
||||
myCharacter.TeamID = (byte)teamID;
|
||||
myCharacter.GiveJobItems(assignedWayPoints.Last());
|
||||
|
||||
Character.Controlled = myCharacter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user