Fixed AI characters constantly flipping over the X-axis when inside, fixed clients not receiving a msg about characters spawned by RespawnManager

This commit is contained in:
Regalis
2017-01-07 16:51:51 +02:00
parent 6364915353
commit 44cbd0d9bf
5 changed files with 23 additions and 16 deletions
@@ -155,8 +155,8 @@ namespace Barotrauma
if (!flip) return; if (!flip) return;
flipTimer += deltaTime; flipTimer += deltaTime;
if (TargetDir != dir) if (TargetDir != Direction.None && TargetDir != dir)
{ {
if (flipTimer>1.0f || character.IsRemotePlayer) if (flipTimer>1.0f || character.IsRemotePlayer)
{ {
+2 -7
View File
@@ -823,7 +823,7 @@ namespace Barotrauma
public void Control(float deltaTime, Camera cam) public void Control(float deltaTime, Camera cam)
{ {
if (isDead || AnimController.StunTimer>0.0f) return; if (!AllowInput) return;
Vector2 targetMovement = GetTargetMovement(); Vector2 targetMovement = GetTargetMovement();
@@ -1461,12 +1461,7 @@ namespace Barotrauma
ControlLocalPlayer(deltaTime, cam); ControlLocalPlayer(deltaTime, cam);
} }
if (controlled == this || Control(deltaTime, cam);
!(this is AICharacter) ||
!((AICharacter)this).AIController.Enabled)
{
Control(deltaTime, cam);
}
if (selectedConstruction != null && !selectedConstruction.IsInPickRange(WorldPosition)) if (selectedConstruction != null && !selectedConstruction.IsInPickRange(WorldPosition))
{ {
@@ -152,6 +152,18 @@ namespace Barotrauma
NetStateID = (UInt32)spawnHistory.Count; NetStateID = (UInt32)spawnHistory.Count;
} }
public void AddToSpawnedList(IEnumerable<Entity> entities)
{
if (GameMain.Server == null) return;
if (entities == null) return;
foreach (Entity entity in entities)
{
spawnHistory.Add(new SpawnOrRemove(entity, false));
NetStateID = (UInt32)spawnHistory.Count;
}
}
public void ServerWrite(Lidgren.Network.NetBuffer message, Client client, object[] extraData = null) public void ServerWrite(Lidgren.Network.NetBuffer message, Client client, object[] extraData = null)
{ {
if (GameMain.Server == null) return; if (GameMain.Server == null) return;
+1 -2
View File
@@ -960,8 +960,7 @@ namespace Barotrauma.Networking
foreach (Character c in GameMain.GameSession.CrewManager.characters) foreach (Character c in GameMain.GameSession.CrewManager.characters)
{ {
Entity.Spawner.AddToSpawnedList(c); Entity.Spawner.AddToSpawnedList(c);
Entity.Spawner.AddToSpawnedList(c.SpawnItems);
c.SpawnItems.ForEach(item => Entity.Spawner.AddToSpawnedList(item));
} }
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClients); SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset, connectedClients);
@@ -412,6 +412,8 @@ namespace Barotrauma.Networking
bool myCharacter = i >= clients.Count; bool myCharacter = i >= clients.Count;
var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, !myCharacter, false); var character = Character.Create(characterInfos[i], shuttleSpawnPoints[i].WorldPosition, !myCharacter, false);
Entity.Spawner.AddToSpawnedList(character);
character.TeamID = 1; character.TeamID = 1;
if (myCharacter) if (myCharacter)
@@ -424,9 +426,7 @@ namespace Barotrauma.Networking
{ {
clients[i].Character = character; clients[i].Character = character;
} }
spawnedCharacters.Add(character);
Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position; Vector2 pos = cargoSp == null ? character.Position : cargoSp.Position;
if (divingSuitPrefab != null && oxyPrefab != null) if (divingSuitPrefab != null && oxyPrefab != null)
@@ -450,10 +450,11 @@ namespace Barotrauma.Networking
spawnedItems.Add(scooter); spawnedItems.Add(scooter);
spawnedItems.Add(battery); spawnedItems.Add(battery);
} }
spawnedItems.ForEach(s => Item.Spawner.AddToSpawnedList(s));
character.GiveJobItems(mainSubSpawnPoints[i]); character.GiveJobItems(mainSubSpawnPoints[i]);
Entity.Spawner.AddToSpawnedList(character.SpawnItems);
Entity.Spawner.AddToSpawnedList(spawnedItems);
GameMain.GameSession.CrewManager.characters.Add(character); GameMain.GameSession.CrewManager.characters.Add(character);
} }