public void OnEnable() { botsLeftToRemove = BotsToRemove; removeDelayCounter = RemoveDelay; remoteBotPlayers.Clear(); CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>(); DataEntityHandle[] remotePlayerHandles = cPDataEntityCollection.GetRemotePlayerHandles(); int num = remotePlayerHandles.Length; for (int i = 0; i < num; i++) { if (cPDataEntityCollection.TryGetComponent(remotePlayerHandles[i], out DisplayNameData component)) { RemotePlayerBot component2 = RemotePlayerBotUtil.GetBotContainer().Find(component.DisplayName).GetComponent <RemotePlayerBot>(); remoteBotPlayers.Add(component2); } } }
private bool onRemotePlayerJoinedRoom(NetworkControllerEvents.RemotePlayerJoinedRoomEvent evt) { if (Service.Get <CPDataEntityCollection>().TryGetComponent(evt.Handle, out DisplayNameData component) && component.DisplayName.StartsWith(BotName)) { Transform botContainer = RemotePlayerBotUtil.GetBotContainer(); GameObject gameObject = new GameObject(component.DisplayName); gameObject.transform.SetParent(botContainer); RemotePlayerBot remotePlayerBot = gameObject.AddComponent <RemotePlayerBot>(); remotePlayerBot.Handle = evt.Handle; remotePlayerBot.RandomizeClothing(); remotePlayerBot.RandomizeColor(); remotePlayerBot.RandomizePosition(base.transform.position, SpawnRadius); if (AutoRemove) { remotePlayerBot.Remove(Random.Range(0.2f, 10f)); } } return(false); }