private void setupRemotePlayers() { DataEntityHandle[] remotePlayerHandles = dataEntityCollection.GetRemotePlayerHandles(); for (int i = 0; i < remotePlayerHandles.Length; i++) { createRemotePlayer(remotePlayerHandles[i], attemptSpawn: false); } Service.Get <LODService>().SetupComplete(LODSystem.REMOTE_PLAYER); }
protected virtual bool onRoomJoined(WorldServiceEvents.SelfRoomJoinedEvent evt) { DataEntityHandle localPlayerHandle = dataEntityCollection.LocalPlayerHandle; if (localPlayerHandle.IsNull) { throw new MissingReferenceException("The local player handle does not exist!"); } PlayerDataEntityFactory.AddCommonDataComponents(dataEntityCollection, localPlayerHandle); PlayerDataEntityFactory.AddCommonZoneScopeDataComponents(dataEntityCollection, localPlayerHandle); dataEntityCollection.AddComponent <LocalPlayerInZoneData>(localPlayerHandle); PresenceData component2 = dataEntityCollection.GetComponent <PresenceData>(localPlayerHandle); if (string.IsNullOrEmpty(evt.Room.zoneId.instanceId)) { component2.World = evt.Room.world; component2.Room = evt.Room.zoneId.name; component2.ContentIdentifier = evt.Room.contentIdentifier; component2.InstanceRoom = null; } else { component2.InstanceRoom = evt.Room.zoneId; } DataEntityHandle[] remotePlayerHandles = dataEntityCollection.GetRemotePlayerHandles(); for (int i = 0; i < remotePlayerHandles.Length; i++) { PresenceData component3 = dataEntityCollection.GetComponent <PresenceData>(remotePlayerHandles[i]); if (string.IsNullOrEmpty(evt.Room.zoneId.instanceId)) { component3.World = evt.Room.world; component3.Room = evt.Room.zoneId.name; component3.ContentIdentifier = evt.Room.contentIdentifier; component3.InstanceRoom = null; } else { component3.InstanceRoom = evt.Room.zoneId; } } if (dataEntityCollection.TryGetComponent <SessionIdData>(localPlayerHandle, out var component4)) { component4.SessionId = evt.SessionId; } else { component4 = dataEntityCollection.AddComponent(localPlayerHandle, delegate(SessionIdData component) { component.SessionId = evt.SessionId; }); } eventDispatcher.DispatchEvent(new NetworkControllerEvents.LocalPlayerJoinedRoomEvent(localPlayerHandle, evt.Room.world, evt.Room.zoneId.name)); return(false); }
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); } } }