public static ReplayController Create(string name)
        {
            FileInfo fileLocation = new FileInfo($"UserData/Replays/{name}.replay");

            if (!fileLocation.Exists)
            {
                return(null);
            }
            GameObject       go          = new GameObject("ReplayController");
            ReplayController _controller = go.AddComponent <ReplayController>();

            Logger.Info($"Loading Replay for {name}");
            string[] replay = File.ReadAllText(fileLocation.FullName).Split('|');
            foreach (string position in replay)
            {
                _controller._replay.Add(new ReplayPacket(position));
            }
            if (_controller._replay.Count == replay.Length)
            {
                Logger.Info($"Loaded Replay for {name}");
            }
            else
            {
                Logger.Info($"Failed to load replay for {name}");
            }
            _controller.Replay = true;
            return(_controller);
        }
        public static void LoadAvatars()
        {
            if (defaultAvatar == null)
            {
                defaultAvatar = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.FirstOrDefault(x => x.FullPath.ToLower().Contains("template.avatar"));
            }
            Logger.Debug($"Found avatar, isLoaded={defaultAvatar.IsLoaded}");
            if (!defaultAvatar.IsLoaded)
            {
                defaultAvatar.Load(null);
            }

            foreach (CustomAvatar.CustomAvatar avatar in CustomAvatar.Plugin.Instance.AvatarLoader.Avatars)
            {
                Task.Run(() =>
                {
                    string hash;
                    if (CreateMD5FromFile(avatar.FullPath, out hash))
                    {
                        cachedAvatars.Add(hash, avatar);
                        Logger.Debug("Hashed avatar " + avatar.FullPath + "! Hash: " + hash);
                    }
                }).ConfigureAwait(false);
            }
        }
Example #3
0
 public ReplayPacket(string data)
 {
     try
     {
         FromBytes(DeSerialize(data));
     } catch (Exception e)
     {
         Logger.Error(e);
     }
 }
 void MovementRecord()
 {
     try
     {
         _replayPackets.Add(GetReplayPacket().Serialize());
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
 void MovementPlay()
 {
     if (_replay.Count == 0)
     {
         Logger.Info($"Movement is 0"); Replay = false; return;
     }
     position = _replay[0].CharacterPosition;
     if (_replay.Count >= 2)
     {
         targetPosition = _replay[1].CharacterPosition;
     }
     update             = 0f;
     transform.position = new Vector3(2f, 0f, 2.5f);
     _replay.RemoveAt(0);
 }
        IEnumerator InitializeReplayManager()
        {
            if (!defaultAvatar.IsLoaded)
            {
                Logger.Debug("Waiting for avatar to load");
                yield return(new WaitWhile(delegate() { return !defaultAvatar.IsLoaded; }));
            }
            else
            {
                yield return(null);
            }

            Logger.Debug("Spawning avatar");
            _centerAdjust = FindObjectOfType <VRCenterAdjust>();

            avatar = AvatarSpawner.SpawnAvatar(defaultAvatar, this);

            avatar.GameObject.transform.SetParent(_centerAdjust.transform, false);
            transform.SetParent(_centerAdjust.transform, false);

            InvokeRepeating("MovementPlay", 0f, UPDATE_INTERVAL);
        }