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