public void OnSpawnBot(ref MyEventSpawnBot msg) { LogDevelop(string.Format("OnSpawnBot(SpawnPointId = {0}, DesiredBotId = {1}, BotsIdx = {2})", msg.SpawnPointId, msg.DesiredBotId, msg.BotsIdx)); MySpawnPoint spawnPoint; if (!MyEntityIdentifier.TryGetEntity<MySpawnPoint>(new MyEntityIdentifier(msg.SpawnPointId), out spawnPoint)) { Alert("Spawn point not found", msg.SenderEndpoint, MyEventEnum.SPAWN_BOT); return; } MyEntity existingEntity; if (MyEntities.TryGetEntityById(msg.DesiredBotId.ToEntityId(), out existingEntity)) { Debug.Fail("Spawning bot, but another entity with same id already exists"); } else { spawnPoint.SpawnShip(msg.BotsIdx, msg.SpawnPosition, msg.DesiredBotId); } }
public void SpawnBot(MySpawnPoint spawnPoint, MySmallShipBot bot, int botsIdx, Vector3 spawnPosition) { MyEventSpawnBot msg = new MyEventSpawnBot(); msg.SpawnPointId = (uint)spawnPoint.EntityId.Value.NumericValue; msg.DesiredBotId = (uint)bot.EntityId.Value.NumericValue; msg.BotsIdx = botsIdx; msg.SpawnPosition = spawnPosition; LogDevelop(string.Format("SpawnBot(SpawnPointId = {0}, DesiredBotId = {1}, BotsIdx = {2})", msg.SpawnPointId, msg.DesiredBotId, msg.BotsIdx)); Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered); }