Changed ItemSpawner to EntitySpawner, used for syncing both item and character spawning

This commit is contained in:
Regalis
2016-10-12 19:25:01 +03:00
parent ac3539da63
commit 60b36e020c
12 changed files with 227 additions and 181 deletions
+11 -3
View File
@@ -49,8 +49,6 @@ namespace Barotrauma
}
}
public bool SpawnedMidRound;
public List<Item> SpawnItems = new List<Item>();
private bool enabled;
@@ -1846,7 +1844,7 @@ namespace Barotrauma
msg.Write(Info.Job == null ? "" : Info.Job.Name);
}
public static Character ReadSpawnData(NetIncomingMessage inc)
public static Character ReadSpawnData(NetIncomingMessage inc, bool spawn=true)
{
if (GameMain.Server != null) return null;
@@ -1862,6 +1860,8 @@ namespace Barotrauma
if (noInfo)
{
if (!spawn) return null;
character = Character.Create(configPath, position, null, true);
character.ID = id;
}
@@ -1877,6 +1877,8 @@ namespace Barotrauma
int headSpriteID = inc.ReadByte();
string jobName = inc.ReadString();
if (!spawn) return null;
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name == jobName);
CharacterInfo ch = new CharacterInfo(configPath, newName, isFemale ? Gender.Female : Gender.Male, jobPrefab);
@@ -1885,6 +1887,12 @@ namespace Barotrauma
character = Character.Create(configPath, position, ch, true, hasAi);
character.ID = id;
if (GameMain.Client.MyCharacterID == id)
{
GameMain.Client.Character = character;
Controlled = character;
}
if (configPath == Character.HumanConfigFile)
{
GameMain.GameSession.CrewManager.characters.Add(character);
@@ -171,7 +171,7 @@ namespace Barotrauma
character.Enabled = false;
husk.SpawnedMidRound = true;
Entity.Spawner.AddToSpawnedList(husk);
}
}
}