public void Awake() { if (Instance != this) { Instance = this; DontDestroyOnLoad(gameObject); Client.Instance.MessageReceived -= PacketReceived; Client.Instance.MessageReceived += PacketReceived; _currentScene = SceneManager.GetActiveScene().name; _messageDisplayText = CustomExtensions.CreateWorldText(transform, ""); transform.position = new Vector3(40f, -43.75f, 3.75f); transform.rotation = Quaternion.Euler(-30f, 0f, 0f); _messageDisplayText.overflowMode = TextOverflowModes.Overflow; _messageDisplayText.enableWordWrapping = false; _messageDisplayText.alignment = TextAlignmentOptions.Center; DontDestroyOnLoad(_messageDisplayText.gameObject); CustomAvatar.Plugin.Instance.PlayerAvatarManager.AvatarChanged += PlayerAvatarManager_AvatarChanged; if (Config.Instance.EnableVoiceChat) { voiceChatListener = new GameObject("Voice Chat Listener").AddComponent <VoipListener>(); voiceChatListener.OnAudioGenerated += ProcesVoiceFragment; DontDestroyOnLoad(voiceChatListener.gameObject); isVoiceChatActive = true; } } }
IEnumerator InitializeAvatarController() { if (!defaultAvatarInstance.IsLoaded) { #if DEBUG Plugin.log.Info("Waiting for avatar to load"); #endif yield return(new WaitWhile(delegate() { return !defaultAvatarInstance.IsLoaded; })); } else { yield return(null); } #if DEBUG Plugin.log.Info("Spawning avatar"); #endif centerAdjust = FindObjectOfType <VRCenterAdjust>(); avatar = AvatarSpawner.SpawnAvatar(defaultAvatarInstance, this); exclusionScript = avatar.GameObject.GetComponentsInChildren <AvatarScriptPack.FirstPersonExclusion>().FirstOrDefault(); if (exclusionScript != null) { exclusionScript.SetVisible(); } playerNameText = CustomExtensions.CreateWorldText(transform, "INVALID"); playerNameText.rectTransform.anchoredPosition3D = new Vector3(0f, 0.25f, 0f); playerNameText.alignment = TextAlignmentOptions.Center; playerNameText.fontSize = 2.5f; playerSpeakerIcon = new GameObject("Player Speaker Icon", typeof(Canvas), typeof(CanvasRenderer)).AddComponent <Image>(); playerSpeakerIcon.GetComponent <Canvas>().renderMode = RenderMode.WorldSpace; playerSpeakerIcon.rectTransform.SetParent(transform); playerSpeakerIcon.rectTransform.localScale = new Vector3(0.004f, 0.004f, 1f); playerSpeakerIcon.rectTransform.pivot = new Vector2(0.5f, 0.5f); playerSpeakerIcon.rectTransform.anchoredPosition3D = new Vector3(0f, 0.65f, 0f); playerSpeakerIcon.sprite = Sprites.speakerIcon; avatar.GameObject.transform.SetParent(centerAdjust.transform, false); transform.SetParent(centerAdjust.transform, false); if (ModelSaberAPI.cachedAvatars.Any(x => x.Value == avatar.CustomAvatar)) { currentAvatarHash = ModelSaberAPI.cachedAvatars.First(x => x.Value == avatar.CustomAvatar).Key; } else { currentAvatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; } }
void Awake() { playerPlaceText = CustomExtensions.CreateWorldText(transform, ""); playerPlaceText.rectTransform.anchoredPosition = new Vector2(2.5f, 0f); playerPlaceText.fontSize = 8f; playerNameText = CustomExtensions.CreateWorldText(transform, ""); playerNameText.rectTransform.anchoredPosition = new Vector2(4f, 0f); playerNameText.fontSize = 7f; playerScoreText = CustomExtensions.CreateWorldText(transform, ""); playerScoreText.rectTransform.anchoredPosition = new Vector2(15f, 0f); playerScoreText.fontSize = 8f; }
public void Awake() { if (Instance != this) { Instance = this; DontDestroyOnLoad(gameObject); Client.ClientCreated += ClientCreated; _currentScene = SceneManager.GetActiveScene().name; _messageDisplayText = CustomExtensions.CreateWorldText(transform, ""); transform.position = new Vector3(0f, 3.75f, 3.75f); transform.rotation = Quaternion.Euler(-30f, 0f, 0f); _messageDisplayText.overflowMode = TextOverflowModes.Overflow; _messageDisplayText.enableWordWrapping = false; _messageDisplayText.alignment = TextAlignmentOptions.Center; DontDestroyOnLoad(_messageDisplayText.gameObject); } }
void InitializeAvatarController() { #if DEBUG Plugin.log.Info("Spawning avatar"); #endif centerAdjust = GameObject.FindObjectOfType <VRCenterAdjust>(); avatarInput = new MultiplayerAvatarInput(); avatar = AvatarManager.SpawnAvatar(defaultAvatarInstance, avatarInput); /* * exclusionScript = avatar.GameObject.GetComponentsInChildren<AvatarScriptPack.FirstPersonExclusion>().FirstOrDefault(); * if (exclusionScript != null) * exclusionScript.SetVisible(); */ playerNameText = CustomExtensions.CreateWorldText(transform, "INVALID"); playerNameText.rectTransform.anchoredPosition3D = new Vector3(0f, 0.25f, 0f); playerNameText.alignment = TextAlignmentOptions.Center; playerNameText.fontSize = 2.5f; playerSpeakerIcon = new GameObject("Player Speaker Icon", typeof(Canvas), typeof(CanvasRenderer)).AddComponent <Image>(); playerSpeakerIcon.GetComponent <Canvas>().renderMode = RenderMode.WorldSpace; playerSpeakerIcon.rectTransform.SetParent(transform); playerSpeakerIcon.rectTransform.localScale = new Vector3(0.004f, 0.004f, 1f); playerSpeakerIcon.rectTransform.pivot = new Vector2(0.5f, 0.5f); playerSpeakerIcon.rectTransform.anchoredPosition3D = new Vector3(0f, 0.65f, 0f); playerSpeakerIcon.sprite = Sprites.speakerIcon; avatar.eventsPlayer.gameObject.transform.SetParent(centerAdjust.transform, false); transform.SetParent(centerAdjust.transform, false); if (ModelSaberAPI.cachedAvatars.Any(x => x.Value.fullPath == avatar.customAvatar.fullPath)) { currentAvatarHash = ModelSaberAPI.cachedAvatars.First(x => x.Value.fullPath == avatar.customAvatar.fullPath).Key; } else { currentAvatarHash = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; } }
void Awake() { playerPlaceText = CustomExtensions.CreateWorldText(transform, ""); playerPlaceText.rectTransform.anchoredPosition = new Vector2(42.5f, -47.5f); playerPlaceText.fontSize = 8f; playerNameText = CustomExtensions.CreateWorldText(transform, ""); playerNameText.rectTransform.anchoredPosition = new Vector2(44f, -47.5f); playerNameText.fontSize = 7f; playerScoreText = CustomExtensions.CreateWorldText(transform, ""); playerScoreText.rectTransform.anchoredPosition = new Vector2(55f, -47.5f); playerScoreText.fontSize = 8f; playerSpeakerIcon = new GameObject("Player Speaker Icon", typeof(Canvas), typeof(CanvasRenderer)).AddComponent <Image>(); playerSpeakerIcon.GetComponent <Canvas>().renderMode = RenderMode.WorldSpace; playerSpeakerIcon.rectTransform.SetParent(transform); playerSpeakerIcon.rectTransform.localScale = new Vector3(0.008f, 0.008f, 1f); playerSpeakerIcon.rectTransform.pivot = new Vector2(0.5f, 0.5f); playerSpeakerIcon.rectTransform.anchoredPosition3D = new Vector3(-8.5f, 2f, 0f); playerSpeakerIcon.sprite = Sprites.speakerIcon; }
IEnumerator InitializeAvatarController() { if (!defaultAvatarInstance.IsLoaded) { #if DEBUG Misc.Logger.Info("Waiting for avatar to load"); #endif yield return(new WaitWhile(delegate() { return !defaultAvatarInstance.IsLoaded; })); } else { yield return(null); } #if DEBUG Misc.Logger.Info("Spawning avatar"); #endif _centerAdjust = FindObjectOfType <VRCenterAdjust>(); avatar = AvatarSpawner.SpawnAvatar(defaultAvatarInstance, this); exclusionScript = avatar.GameObject.GetComponentsInChildren <AvatarScriptPack.FirstPersonExclusion>().FirstOrDefault(); if (exclusionScript != null) { exclusionScript.SetVisible(); } playerNameText = CustomExtensions.CreateWorldText(transform, "INVALID"); playerNameText.rectTransform.anchoredPosition3D = new Vector3(0f, 0.25f, 0f); playerNameText.alignment = TextAlignmentOptions.Center; playerNameText.fontSize = 2.5f; avatar.GameObject.transform.SetParent(_centerAdjust.transform, false); transform.SetParent(_centerAdjust.transform, false); currentAvatarHash = ModelSaberAPI.cachedAvatars.First(x => x.Value == avatar.CustomAvatar).Key; }
public void GameSceneLoaded() { Plugin.log.Info("Game scene loaded"); _currentScene = "GameCore"; if (!Config.Instance.SpectatorMode || !Client.Instance.connected) { active = false; return; } StartCoroutine(Delay(5, () => { active = true; })); _paused = false; DestroyAvatar(); ReplaceControllers(); if (_spectatingText != null) { Destroy(_spectatingText); } _spectatingText = CustomExtensions.CreateWorldText(transform, "Spectating PLAYER"); _spectatingText.alignment = TextAlignmentOptions.Center; _spectatingText.fontSize = 6f; _spectatingText.transform.position = new Vector3(0f, 3.75f, 12f); _spectatingText.gameObject.SetActive(false); if (_bufferingText != null) { Destroy(_bufferingText); } _bufferingText = CustomExtensions.CreateWorldText(transform, "Buffering..."); _bufferingText.alignment = TextAlignmentOptions.Center; _bufferingText.fontSize = 8f; _bufferingText.transform.position = new Vector3(0f, 2f, 8f); _bufferingText.gameObject.SetActive(false); if (playerUpdates != null) { playerUpdates.Clear(); } else { playerUpdates = new Dictionary <ulong, ReplayData>(); } #if DEBUG && LOCALREPLAY string replayPath = Path.GetFullPath("MPDumps\\BootyBounce.mpdmp"); Stream stream; long length; long position; if (replayPath.EndsWith(".zip")) { ZipArchiveEntry entry = new ZipArchive(File.Open(replayPath, FileMode.Open, FileAccess.Read, FileShare.Read), ZipArchiveMode.Read).Entries.First(x => x.Name.EndsWith(".mpdmp")); position = 0; length = entry.Length; stream = entry.Open(); } else { var fileStream = File.Open(replayPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); position = 0; length = fileStream.Length; stream = fileStream; } byte[] startLevelInfo = new byte[2]; stream.Read(startLevelInfo, 0, 2); position += 2; byte[] levelIdBytes = new byte[16]; stream.Read(levelIdBytes, 0, 20); position += 20; while (length - position > 79) { byte[] packetSizeBytes = new byte[4]; stream.Read(packetSizeBytes, 0, 4); position += 4; int packetSize = BitConverter.ToInt32(packetSizeBytes, 0); byte[] packetBytes = new byte[packetSize]; stream.Read(packetBytes, 0, packetSize); position += packetSize; PlayerInfo player = new PlayerInfo(packetBytes); player.playerId = 76561198047255565; player.playerName = "andruzzzhka"; player.avatarHash = "1f0152521ab8aa04ea53beed79c083e6".ToUpper(); if (playerInfos.ContainsKey(player.playerId)) { playerInfos[player.playerId].Add(player); playersHits[player.playerId].AddRange(player.hitsLastUpdate); } else { playerInfos.Add(player.playerId, new List <PlayerInfo>() { player }); playersHits.Add(player.playerId, new List <HitData>(player.hitsLastUpdate)); } } Plugin.log.Info("Loaded " + playerInfos[76561198047255565].Count + " packets!"); #endif }