예제 #1
0
        private static IEnumerator GetModInfo(Mod mod)
        {
            Manifest man = null;

            var down = new WWW(mod.UpdateUrl);

            yield return(down);

            try
            {
                man = ManifestParser.ParseManifest(down.text.Split('\n'));
            }
            catch (Exception ex)
            {
                MDebug.WriteLine("Exception occurred while parsing update manifest for " + mod.FullName);
                MDebug.WriteLine("Details: " + ex);

                IGConsole.Log("Error occurred while updating " + mod.FullName);
            }

            if (man == null || man.Mods == null || man.Mods.Length == 0)
            {
                yield break;
            }

            var modInfo = man.Mods.SingleOrDefault(o => o.Name.Equals(mod.PackageName));

            if (modInfo != null)
            {
                ModInfos[mod] = modInfo;
            }
        }
예제 #2
0
        public override bool Execute(IEnumerable <string> arguments)
        {
            if (MyMod.SetUpdateRate == null)
            {
                IGConsole.Error("This command can only be used while in-game!");
                return(true);
            }

            if (!arguments.Any())
            {
                IGConsole.Log($"<b>Current update rate:</b> {MyMod.CurrentUpdateRate} tps");
                return(true);
            }

            string arg = arguments.First();

            if (float.TryParse(arg, out float num))
            {
                MyMod.SetUpdateRate(num);
                return(true);
            }
            else
            {
                IGConsole.Error("tps must be a decimal number");
            }

            return(false);
        }
예제 #3
0
        private void PatchThread(IEnumerable <Mod> mods, bool hotload)
        {
            foreach (var mod in mods.Where(o => o.MultiThreadedLoad))
            {
                LoadMod(mod, hotload);
            }
            CurrentlyLoading = null;

            MDebug.WriteLine("----------Done patching!----------");

            if (hotload)
            {
                return;
            }

            UpdateChecker.UpdateStatus += (a, v) =>
            {
                if (a)
                {
                    IGConsole.Log($"<color=#00ff00>PiTUNG version {v} available!</color> Run Installer.exe or type 'update' into the console to update.");
                }
            };
            ModUtilities.DummyComponent?.StartCoroutine(UpdateChecker.CheckUpdates());

            foreach (var item in Mods.Concat(CheckUpdatesBeforeLoading))
            {
                ModUtilities.DummyComponent?.StartCoroutine(ModUpdater.CheckUpdatesForMod(item, true));
            }
        }
예제 #4
0
            public override bool Execute(IEnumerable <string> arguments)
            {
                if (arguments.Count() != 1)
                {
                    IGConsole.Error("Usage: find component_name");
                    return(false);
                }
                Assembly asm           = typeof(UnityEngine.Object).Assembly;
                Type     componentType = asm.GetType($"UnityEngine.{arguments.ElementAt(0)}");

                if (componentType == null)
                {
                    IGConsole.Error($"{arguments.ElementAt(0)} is not a type");
                    return(false);
                }
                if (!componentType.IsSubclassOf(typeof(Component)))
                {
                    IGConsole.Error($"{arguments.ElementAt(0)} is not a Component");
                    return(false);
                }
                Component[] matches = (Component[])GameObject.FindObjectsOfType(componentType);
                foreach (Component component in matches)
                {
                    IGConsole.Log($"\"{component.name}\" is at {component.transform.position}");
                }
                return(true);
            }
예제 #5
0
        public static IEnumerator CheckUpdatesForMod(Mod mod, bool update)
        {
            if (mod.UpdateUrl == null)
            {
                yield break;
            }

            yield return(GetModInfo(mod));

            if (ModInfos.TryGetValue(mod, out var modInfo))
            {
                mod.HasAvailableUpdate = modInfo.Version > mod.ModVersion;
            }

            if (mod.HasAvailableUpdate)
            {
                Bootstrapper.Instance.ModUpdatesAvailable = true;

                if (update)
                {
                    yield return(UpdateMod(mod));
                }

                IGConsole.Log($"<color=lime>Downloaded update for {mod.FullName}!</color> Restart TUNG to install.");
            }
        }
예제 #6
0
 public static bool isButtonActive(string button)
 {
     if (!activeKeys_button.ContainsKey(button))
     {
         IGConsole.Log(new KeyNotFoundException($"'{button}'" + " is not contained in activeKeys_button dictionary! To register another key, call registerButton(string button) first!"));
     }
     return(activeKeys_button[button]);
 }
예제 #7
0
 public static bool isActive(KeyCode key)
 {
     if (!activeKeys_kc.ContainsKey(key))
     {
         IGConsole.Log(new KeyNotFoundException($"'KeyCode.{key.ToString()}'" + " is not contained in activeKeys_kc dictionary! To register another key, call registerKey(KeyCode key) first!"));
     }
     return(activeKeys_kc[key]);
 }
예제 #8
0
 public static bool isActive(string key)
 {
     if (!activeKeys.ContainsKey(key))
     {
         IGConsole.Log(new KeyNotFoundException($"'{key}'" + " is not contained in activeKeys dictionary! To register another key, call registerKey(string key) first!"));                throw new KeyNotFoundException(key + " is not contained in activeKeys dictionary! To register another key, call registerKey(string key) first!");
     }
     return(activeKeys[key]);
 }
예제 #9
0
 public void Init()
 {
     client = new Client();
     placer = new Placer();
     IGConsole.RegisterCommand(new Command_find());
     IGConsole.RegisterCommand(new Command_findobj());
     IGConsole.Log($"Polyglot v{ModVersion.ToString()} initialized");
 }
예제 #10
0
파일: MulTUNG.cs 프로젝트: pipe01/MulTUNG
        public override bool Execute(IEnumerable <string> arguments)
        {
            IList <string> players = PlayerManager.Players.Select(o => o.Username).ToList();

            players.Insert(0, Network.Username);

            IGConsole.Log($"<color=lime>Online players</color> (<b>{players.Count}</b>): {string.Join(", ", players.ToArray())}");

            return(true);
        }
예제 #11
0
 private static void Prefix(BoardPlacer __instance)
 {
     if (BoardPlacer.BoardBeingPlaced == null)
     {
         IGConsole.Log("null board?");
     }
     foreach (BuildListener listener in instances)
     {
         listener.OnPlaceBoard(BoardPlacer.BoardBeingPlaced);
     }
 }
예제 #12
0
 static void Postfix()
 {
     if (watch.IsRunning)
     {
         watch.Stop();
     }
     if (!betterSave)
     {
         IGConsole.Log($"Loaded save in {watch.Elapsed.ToString()}");
     }
 }
예제 #13
0
 private void OnPlayerIDAttribution(PlayerIDAttribution packet)
 {
     if (ID.HasValue)
     {
         IGConsole.Error("Received unexpected IDAttribution");
         return;
     }
     ID = packet.ID;
     IGConsole.Log($"ID set to {ID.Value}");
     SendPacket(new IDAttibutionACK());
 }
예제 #14
0
        public static void WaveGoodbye(int playerId)
        {
            if (PlayersInner.TryGetValue(playerId, out var player))
            {
                IGConsole.Log($"<color=orange>Player {player.Username} disconnected</color>");

                GameObject.Destroy(player.gameObject);

                PlayersInner.Remove(playerId);
            }
        }
예제 #15
0
 public override bool Execute(IEnumerable <string> args)
 {
     if (args.Count() == 0)
     {
         IGConsole.Log(CustomMusic.bmp.GetListOfSongs());
     }
     else
     {
         return(false);
     }
     return(true);
 }
예제 #16
0
        private Vector3 GetScale()
        {
            if (Physics.Raycast(FirstPersonInteraction.Ray(), out var hit))
            {
                IGConsole.Log(hit.transform.localPosition);
                IGConsole.Log(hit.transform.localScale);
                IGConsole.Log(hit.transform.localEulerAngles);

                ModUtilities.Graphics.CreateSphere(hit.point);
            }

            return(Vector3.back);
        }
예제 #17
0
        public NetOutgoingMessage GetMessage(NetPeer peer)
        {
            var msg = peer.CreateMessage();

            try
            {
                msg.Write(this.Serialize());
            }
            catch (Exception ex)
            {
                IGConsole.Log(ex);
            }
            return(msg);
        }
예제 #18
0
파일: Main.cs 프로젝트: Repsi0/CustomMusic
        public override void OnWorldLoaded(string worldName)
        {
            bmp = BetterMusicPlayer.CreateSelf();
            MusicPlayer[] mps = GameObject.FindObjectsOfType <MusicPlayer>();

            string musicDir = Directory.GetCurrentDirectory() + "\\music";

            if (!Directory.Exists(musicDir))
            {
                Directory.CreateDirectory(musicDir);
            }

            string[] musFiles = Directory.GetFiles(musicDir);
            foreach (string path in Directory.GetFiles(musicDir))
            {
                string[] splitPath           = path.Split('.');
                string   ext                 = splitPath[splitPath.Length - 1].ToLower();
                string[] availableExtensions = { "wav", "ogg" };
                if (!availableExtensions.Contains(ext))
                {
                    IGConsole.Log("[Custom Music] " + ext + " file type not supported! Try using .WAV or .OGG instead!");
                }
                else
                {
                    AudioType       at  = (ext == "ogg") ? AudioType.OGGVORBIS : ((ext == "mp3")?AudioType.MPEG :AudioType.WAV);
                    UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip("file:///" + path, at);

                    try {
                        uwr.SendWebRequest();
                        while (uwr.downloadProgress != 1.0f || !uwr.isDone)
                        {
                            //IGConsole.Log($"[Custom Music] File {path} downloaded: {100f*uwr.downloadProgress}%");
                        }
                        AudioClip ac = DownloadHandlerAudioClip.GetContent(uwr);

                        string[] splitPath2 = path.Split('/');
                        bmp.AddNewTrack(splitPath2[splitPath2.Length - 1], ac);
                    } catch (Exception e) {
                        IGConsole.Log(e);
                    }
                }
            }
            foreach (MusicPlayer mp in mps)
            {
                mp.Tracks = new AudioClip[] {}
            }
            ;
            bmp.BeginPlaylist();
        }
예제 #19
0
 public override bool Execute(IEnumerable <string> arguments)
 {
     IGConsole.Log("Disconnecting...");
     Disconnect();
     if (SceneManager.GetActiveScene().name == "gameplay")
     {
         UIManager.UnlockMouseAndDisableFirstPersonLooking();
         SceneManager.LoadScene("main menu");
     }
     else
     {
         IGConsole.Log("Not currently connected");
         return(false);
     }
     return(true);
 }
예제 #20
0
 private static void Connect(string address, int port)
 {
     if (connection != null && connection.Status == Status.Connected)
     {
         IGConsole.Error("Already connected, disconnect first");
         return;
     }
     IGConsole.Log($"Connecting to {address}:{port}");
     connection = new ClientConnection(address, port);
     if (!Directory.Exists(savesPath))
     {
         Directory.CreateDirectory(savesPath);
     }
     DeleteSave();
     SaveManager.SaveName = "multiplayer/_";
     SceneManager.LoadScene("gameplay");
 }
예제 #21
0
        public UserModel GetByID(int id)
        {
            if (!UserCache.ContainsKey(id))
            {
                var user = MakeRequest <UserModel>($"/user/{id}", HttpMethod.Get);

                if (user == null) //Error on the request, don't cache
                {
                    IGConsole.Log("Dont cache user " + id);
                    return(null);
                }

                UserCache[id] = user;
            }

            return(UserCache[id]);
        }
예제 #22
0
        public override void Undo()
        {
            IGConsole.Log("Component SavedObject is null: " + (SavedObject == null));

            SavedObjectUtilities.LoadSavedObject(SavedObject, Parent);

            //foreach (var item in Wires)
            //{
            //    if (item is InputInputConnection ii)
            //    {
            //        StuffConnector.LinkInputs(ii);
            //    }
            //    else if (item is InputOutputConnection io)
            //    {
            //        StuffConnector.LinkInputOutput(io);
            //    }
            //}
        }
예제 #23
0
    public override bool Execute(IEnumerable <string> args)
    {
        if (args.Count() < 2)
        {
            IGConsole.Log("Not enough arguments!");
            return(false);
        }
        string size = string.Join(" ", args.ToArray()); //turns the array into a string

        try
        {
            int[] xysize = Array.ConvertAll(size.Split(' '), s => int.Parse(s)); // split the string into a string array at every space and convert that into an int array
        }
        catch (Exception ex)                                                     // Catches all exceptions
        {
            IGConsole.Log($"Error! Cant remove Label of size {size}, correct format is \"{{X size of Label}} {{Y size of Label}}\" ");
            return(false);
        }
        string[] file = { };
        if (File.Exists($"{Directory.GetCurrentDirectory()}/sizes_l.txt"))
        {
            file = File.ReadAllLines($"{Directory.GetCurrentDirectory()}/sizes_l.txt");
            if (file.Contains(size))
            {
                List <string> fileList = file.ToList();
                fileList.Remove(size);
                file = fileList.ToArray();
            }
            else
            {
                IGConsole.Log($"Error! Cant remove Label of size {size}, It doesn't exist!");
                return(false);
            }
            File.WriteAllLines($"{Directory.GetCurrentDirectory()}/sizes_l.txt", file);
        }
        else
        {
            IGConsole.Log($"Error! Cant remove Label of size {size}, There are no custom Labels to delete!");
            return(false);
        }
        IGConsole.Log($"Reomved Label of size {size} from component list. NOTE: this change will only take effect when you restart your game!!!");
        return(true);
    }
예제 #24
0
            public override bool Execute(IEnumerable <string> arguments)
            {
                if (arguments.Count() == 0)
                {
                    IGConsole.Error("Usage: findobj name");
                    return(false);
                }
                string     name  = string.Join(" ", arguments.ToArray());
                GameObject found = GameObject.Find(name);

                if (found != null)
                {
                    IGConsole.Log($"{found.name} found at {found.transform.position}");
                }
                else
                {
                    IGConsole.Error("Object not found");
                }
                return(true);
            }
예제 #25
0
        public static void ColorBoard(PaintBoardMenu __instance)
        {
            if (Physics.Raycast(FirstPersonInteraction.Ray(), out var raycastHit, Settings.ReachDistance, Wire.IgnoreWiresLayermask) && raycastHit.collider.tag == "CircuitBoard")
            {
                var netObj = raycastHit.collider.GetComponent <NetObject>();
                IGConsole.Log("Hit " + netObj);

                if (netObj == null)
                {
                    return;
                }

                var color = __instance.Colors[__instance.SelectedThing];

                Network.SendPacket(new PaintBoardPacket
                {
                    BoardID = netObj.NetID,
                    Color   = color
                });
            }
        }
예제 #26
0
 private void ReceiveThread()
 {
     IGConsole.Log("Starting receiver thread");
     while (status != Status.Disconnected)
     {
         if (client.Available > 0)
         {
             try
             {
                 BinaryFormatter formatter = new BinaryFormatter();
                 Packet          packet    = formatter.Deserialize(client.GetStream()) as Packet;
                 receiveQueue.Enqueue(packet);
             } catch (Exception e)
             {
                 IGConsole.Error(e.ToString());
             }
         }
         Thread.Sleep(30);
     }
     IGConsole.Log("Receiver thread stopped");
 }
예제 #27
0
        public static void NewPlayer(int id, string username)
        {
            if (PlayersInner.TryGetValue(id, out var player))
            {
                player.Username = username;
            }
            else
            {
                IGConsole.Log($"<color=orange>Player {username} connected</color>");

                //Instantiate a new player from the prefab
                var obj = MakePlayerModel();

                //Add a RemotePlayer component
                var remotePlayer = obj.AddComponent <RemotePlayer>();
                remotePlayer.Username = username;

                //Add it to the players registry
                PlayersInner.Add(id, remotePlayer);
            }
        }
예제 #28
0
    public override bool Execute(IEnumerable <string> args)
    {
        if (args.Count() < 2)
        {
            IGConsole.Log("Not enough arguments!");
            return(false);
        }
        string size = string.Join(" ", args.ToArray()); //turns the array into a string

        try
        {
            int[] xysize = Array.ConvertAll(size.Split(' '), s => int.Parse(s)); // split the string into a string array at every space and convert that into an int array
            ComponentRegistry.CreateNew($"{xysize[0]} x {xysize[1]} PanelLabel", $"{xysize[0]} x {xysize[1]} PanelLabel", OversizeLabels.CreatePanelLabelOfSize(xysize[0], xysize[1]));
        }
        catch (Exception ex) // Catches all exceptions
        {
            if (ex is ArgumentException)
            {
                IGConsole.Log($"Error! Cant make Label of size {size}, It already exists!");
            }
            else
            {
                IGConsole.Log($"Error! Cant make Label of size {size}, correct format is \"{{X size of Label}} {{Y size of Label}}\" ");
            }
            return(false);
        }
        string[] file = { };
        if (File.Exists($"{Directory.GetCurrentDirectory()}/sizes_l.txt"))
        {
            file = File.ReadAllLines($"{Directory.GetCurrentDirectory()}/sizes_l.txt");
        }
        List <string> list = new List <string>();

        list.AddRange(file);
        list.AddRange(new string[] { size });
        file = list.ToArray();
        File.WriteAllLines($"{Directory.GetCurrentDirectory()}/sizes_l.txt", file);
        IGConsole.Log($"Added Label of size {size} to component list");
        return(true);
    }
예제 #29
0
 private void Init()
 {
     if (boardPlacer != null)
     {
         return;
     }
     boardPlacer = GameObject.FindObjectOfType <BoardPlacer>();
     if (!boardPlacer)
     {
         IGConsole.Error("Could not find BoardPlacer");
         return;
     }
     IGConsole.Log("Board placer found");
     _SetChildCircuitsMegaMeshStatus = boardPlacer.GetType()
                                       .GetMethod("SetChildCircuitsMegaMeshStatus", BindingFlags.NonPublic | BindingFlags.Instance);
     if (_SetChildCircuitsMegaMeshStatus == null)
     {
         IGConsole.Error("Could not get SCCMMS method");
         return;
     }
     IGConsole.Log("Got SCCMMS method");
 }
예제 #30
0
    public override void BeforePatch()
    {
        ComponentRegistry.CreateNew <CustomLabel>("WidePanelLabel", "Wide Panel Label", CreatePanelLabelOfSize(3, 1));
        ComponentRegistry.CreateNew <CustomLabel>("TallPanelLabel", "Tall Panel Label", CreatePanelLabelOfSize(1, 3));
        ComponentRegistry.CreateNew <CustomLabel>("BigPanelLabel", "Big Panel Label", CreatePanelLabelOfSize(2, 2));

        // This game's sequal has been in devolpment for over 2 years. I hope the world is ready
        ComponentRegistry.CreateNew <CustomLabel>("CollosallyWidePanelLabel", "Collosally Wide Panel Label", CreatePanelLabelOfSize(51, 1));
        ComponentRegistry.CreateNew <CustomLabel>("CollosallyTallPanelLabel", "Collosally Tall Panel Label", CreatePanelLabelOfSize(1, 51));
        // On second thought, the world is still not ready to see this one
        // ComponentRegistry.CreateNew<CustomLabel>("TitanicPanelLabel", "Titanic Panel Label", PanelLabelOfSize(400, 700));

        // add labels from file
        if (File.Exists($"{Directory.GetCurrentDirectory()}/sizes_l.txt"))
        {
            string[] sizes = File.ReadAllLines($"{Directory.GetCurrentDirectory()}/sizes_l.txt");
            foreach (string size in sizes)
            {
                try
                {
                    int[] xysize = Array.ConvertAll(size.Split(' '), s => int.Parse(s)); // split the string into a string array at every space and convert that into an int array
                    ComponentRegistry.CreateNew($"{xysize[0]} x {xysize[1]} PanelLabel", $"{xysize[0]} x {xysize[1]} PanelLabel", CreatePanelLabelOfSize(xysize[0], xysize[1]));
                }
                catch (Exception ex) // Catches all exceptions
                {
                    if (ex is ArgumentException)
                    {
                        IGConsole.Log($"Error! Cant load label of size {size} twice");
                    }
                    else
                    {
                        IGConsole.Log($"Error! Cant load label of size {size}, correct format is \"{{X size of label}} {{Y size of label}}\" ");
                    }
                }
            }
        }
        Shell.RegisterCommand <Add_Label>();
        Shell.RegisterCommand <Remove_Label>();
    }