Fixed clients not seeing additional cargo + spawn monster cursor
This commit is contained in:
@@ -226,21 +226,22 @@ namespace Barotrauma
|
||||
Character spawnedCharacter = null;
|
||||
|
||||
Vector2 spawnPosition = Vector2.Zero;
|
||||
WayPoint spawnPoint = null;
|
||||
|
||||
spawnPosition = Vector2.Zero;
|
||||
|
||||
if (commands.Length > 2)
|
||||
{
|
||||
switch (commands[2].ToLowerInvariant())
|
||||
{
|
||||
case "inside":
|
||||
spawnPoint = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
|
||||
spawnPosition = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub).WorldPosition;
|
||||
break;
|
||||
case "outside":
|
||||
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||
spawnPosition = WayPoint.GetRandom(SpawnType.Enemy).WorldPosition;
|
||||
break;
|
||||
case "near":
|
||||
case "close":
|
||||
float closestDist = 0.0f;
|
||||
float closestDist = -1.0f;
|
||||
foreach (WayPoint wp in WayPoint.WayPointList)
|
||||
{
|
||||
if (wp.Submarine != null) continue;
|
||||
@@ -250,26 +251,27 @@ namespace Barotrauma
|
||||
|
||||
float dist = Vector2.Distance(wp.WorldPosition, GameMain.GameScreen.Cam.WorldViewCenter);
|
||||
|
||||
if (spawnPoint == null || dist < closestDist)
|
||||
if (closestDist < 0.0f || dist < closestDist)
|
||||
{
|
||||
spawnPoint = wp;
|
||||
spawnPosition = wp.WorldPosition;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "cursor":
|
||||
spawnPosition = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
break;
|
||||
default:
|
||||
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy);
|
||||
spawnPosition = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy).WorldPosition;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
|
||||
spawnPosition = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy).WorldPosition;
|
||||
}
|
||||
|
||||
spawnPosition = spawnPoint == null ? Vector2.Zero : spawnPoint.WorldPosition;
|
||||
|
||||
if (commands[1].ToLowerInvariant()=="human")
|
||||
{
|
||||
spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition);
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace Barotrauma
|
||||
|
||||
message.Write(items[i].Position.X);
|
||||
message.Write(items[i].Position.Y);
|
||||
message.Write(items[i].Submarine != null ? items[i].Submarine.ID : (ushort)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,6 +145,7 @@ namespace Barotrauma
|
||||
ushort itemId = message.ReadUInt16();
|
||||
|
||||
Vector2 pos = Vector2.Zero;
|
||||
Submarine sub = null;
|
||||
ushort inventoryId = message.ReadUInt16();
|
||||
|
||||
int inventorySlotIndex = -1;
|
||||
@@ -155,13 +157,18 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
pos = new Vector2(message.ReadSingle(), message.ReadSingle());
|
||||
ushort subID = message.ReadUInt16();
|
||||
if (subID > 0)
|
||||
{
|
||||
sub = Submarine.Loaded.Find(s => s.ID == subID);
|
||||
}
|
||||
}
|
||||
|
||||
string tags = "";
|
||||
if (itemName == "ID Card")
|
||||
{
|
||||
tags = message.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
var prefab = MapEntityPrefab.list.Find(me => me.Name == itemName);
|
||||
if (prefab == null) continue;
|
||||
@@ -188,11 +195,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var item = new Item(itemPrefab, pos, null);
|
||||
var item = new Item(itemPrefab, pos, sub);
|
||||
|
||||
item.ID = itemId;
|
||||
item.CurrentHull = Hull.FindHull(pos, null, false);
|
||||
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine;
|
||||
if (sub != null)
|
||||
{
|
||||
item.CurrentHull = Hull.FindHull(pos + sub.Position, null, true);
|
||||
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(tags)) item.Tags = tags;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user