Ejemplo n.º 1
0
        void Start()
        {
            newLog = new ModLogger("[BWPirateChat]", ModLoader.LogPath + "\\PirateChatLog.txt");

            if (!ïçîìäîóäìïæ.òîóëñëäêêòó)
            {
                newLog.Log("client side, so return and not do anything");
                return;
            }
            newLog.Log("in the start function");
            HarmonyInstance.DEBUG = true;
            newLog.Log("set debug to true");
            HarmonyInstance harmonyInstancePirateChat = HarmonyInstance.Create("com.github.windowsxp.BWPirateChat");

            newLog.Log("created harmony instance");
            harmonyInstancePirateChat.PatchAll();
            newLog.Log("patched harmony instance");

            //read the dictionary file
            validFile = readDictionaryFile(dictionaryFileName);
            loadConfigFile(configFileName);
            prefixStrings    = new string[4];
            prefixStrings[0] = "Avast!";
            prefixStrings[1] = "Arr!";
            prefixStrings[2] = "Avast, ye scurvy dogs!";
            prefixStrings[3] = "Arr, matey.";
        }
Ejemplo n.º 2
0
        public static void LoadMods()
        {
            var owmlGo = new GameObject();

            owmlGo.AddComponent <OwmlBehaviour>();
            var owmlConfig        = JsonHelper.LoadJsonObject <OwmlConfig>(ConfigPath);
            var owmlDefaultConfig = JsonHelper.LoadJsonObject <OwmlConfig>(DefaultConfigPath);
            var owmlManifest      = JsonHelper.LoadJsonObject <ModManifest>(ManifestPath);

            if (owmlConfig == null || owmlManifest == null)
            {
                // Everything is wrong and can't write to console...
                return;
            }
            var logger = new ModLogger(owmlConfig, owmlManifest);

            logger.Log("Got config!");
            var console = OutputFactory.CreateOutput(owmlConfig, logger, owmlManifest);

            console.WriteLine("Mod loader has been initialized.");
            var modSorter     = new ModSorter(console);
            var modFinder     = new ModFinder(owmlConfig, console);
            var harmonyHelper = new HarmonyHelper(logger, console);
            var events        = new ModEvents(logger, console, harmonyHelper);
            var inputHandler  = new ModInputHandler(logger, console, harmonyHelper, owmlConfig, events);
            var menus         = new ModMenus(console, events, inputHandler, owmlManifest, owmlConfig, owmlDefaultConfig);
            var owo           = new Owo(modFinder, logger, console, owmlConfig, menus, harmonyHelper, inputHandler, modSorter);

            owo.LoadMods();
        }
Ejemplo n.º 3
0
        /// <summary> An example of mod toggling. </summary>
        /// <param name="onState">True: Enable mod, False: Disable Mod</param>
        /// <returns>True if the toggle was successful.</returns>
        public static bool Toggle(ModEntry entry, bool onState)
        {
            ModLogger logger = entry.Logger;

            logger.Log($"Toggled {onState}");
            return(true);
        }
Ejemplo n.º 4
0
        //+ Setup Handling
        // Setup all callbacks
        internal static void Setup()
        {
            // GUU CALLBACKS
            SRGuu.MainMenuLoaded += ApplyMenuChanges;
            SRGuu.PreLoadGame    += RegisterWorld;
            SRGuu.TimedUpdate    += TimedUpdate;

            // TODO: Remove this
            SRGuu.ZoneEnter += (zone, state) => { ModLogger.Log("Entering zone: " + zone); };
        }
Ejemplo n.º 5
0
        void Start()
        {
            try
            {
                logger.ClearLog();
                logger.Log("Starting Debugger UI");
                debugger.Load();
                debugger.StartWatch();

                screenSelection          = new SelectionGrid(new string[] { "Log", "Mods", "Debugger" }, GUILayout.Height(25));
                screenSelection.Selected = 1;
                logWindow   = LogWindow();
                modWindow   = ModWindow();
                debugWindow = DebugWindow();
                RefreshMods();
                logger.Log("Debugger UI startup complete");
            }
            catch (Exception e)
            {
                logger.Log($"While starting UI threw {e.GetType().FullName}: {e.Message}{Environment.NewLine}{e.StackTrace}");
            }
        }
Ejemplo n.º 6
0
        //+ BRIDGE
        internal static void RegisterCommand(string cmdID, ConsoleCommand cmd)
        {
            if (IGNORE_LIST.Contains(cmdID))
            {
                return;
            }
            if (GuuConsole.commands.ContainsKey(cmdID))
            {
                SRML_LOGGER?.Log($"Found command with conflicting id '{cmdID}', adding prefix, new id is 'srml.{cmdID}'");
                GuuConsole.RegisterCommand(new SRMLCommand(cmd, $"srml.{cmdID}"));
                return;
            }

            GuuConsole.RegisterCommand(new SRMLCommand(cmd));
        }
Ejemplo n.º 7
0
 public static IEnumerator DumpContent(Scene scene)
 {
     lock (_DumpLock) {
         ModLogger.Log("dump", $"Dumping scene: {scene.name}");
         Scene scenePrev = SceneManager.GetActiveScene();
         if (scenePrev != scene)
         {
             SceneManager.SetActiveScene(scene);
             yield return(null);
         }
         GameObject[] objs = Resources.FindObjectsOfTypeAll <GameObject>();
         if (scenePrev != scene)
         {
             SceneManager.SetActiveScene(scenePrev);
             yield return(null);
         }
         _DumpingUILabel.Text = string.Format(_DumpingUIFormat, "", 0, objs.Length);
         _DumpingUIBar.Size.x = 0;
         _DumpingUI.Visible   = true;
         for (int i = 0; i < objs.Length; i++)
         {
             if (objs[i] != null)
             {
                 if (objs[i].scene != scene)
                 {
                     continue;
                 }
                 if (DumpContent(objs[i].transform))
                 {
                     _DumpedThisFrame++;
                 }
                 if (_DumpedThisFrame >= _DumpsPerFrame || i % _MaxObjectsPerFrame == 0)
                 {
                     _DumpedThisFrame     = 0;
                     _DumpingUILabel.Text = string.Format(_DumpingUIFormat, objs[i].name, i, objs.Length);
                     _DumpingUIBar.Size.x = ((float)i / objs.Length) * _DumpingUI.Size.x;
                     yield return(null);
                 }
             }
         }
         _DumpingUI.Visible = false;
     }
 }
Ejemplo n.º 8
0
        // Method that runs when the game starts so it can fix things then
        internal static void FixAtGameLoad()
        {
            // Fixes to the scales
            if (QOL.FixScales)
            {
                // Gilded Ginger Fix
                ScaleFix(Identifiable.Id.GINGER_VEGGIE, Vector3.one * 1.2f, "model_parsnip");
                ObjectFix(Identifiable.Id.GINGER_VEGGIE, (obj) =>
                {
                    // TODO: Fix this later
                    float perc = 1.2f / 2.1f;

                    CapsuleCollider col = obj.GetComponent <CapsuleCollider>();
                    SphereCollider sCol = obj.GetComponent <SphereCollider>();

                    GameObject launch           = obj.FindChild("DelaunchTrigger");
                    launch.transform.localScale = launch.transform.localScale * perc;

                    col.radius *= perc;
                    col.height *= perc;

                    sCol.radius *= perc;
                });
            }

            if (QOL.ImpCollisions)
            {
                ObjectFix(SRObjects.Get <GameObject>("ranchPorch"), (obj) =>
                {
                    ModLogger.Log("Test");
                    foreach (MeshCollider col in obj.GetComponentsInChildren <MeshCollider>())
                    {
                        col.sharedMesh = col.gameObject.GetComponent <MeshFilter>().sharedMesh;
                    }
                });
            }
        }
Ejemplo n.º 9
0
 public static IEnumerator PatchContent(Scene scene)
 {
     lock (_PatchLock) {
         ModLogger.Log("content", $"Patching scene content: {scene.name}");
         Scene scenePrev = SceneManager.GetActiveScene();
         if (scenePrev != scene)
         {
             SceneManager.SetActiveScene(scene);
             yield return(null);
         }
         GameObject[] objs = Resources.FindObjectsOfTypeAll <GameObject>();
         if (scenePrev != scene)
         {
             SceneManager.SetActiveScene(scenePrev);
             yield return(null);
         }
         for (int i = 0; i < objs.Length; i++)
         {
             if (objs[i] != null)
             {
                 if (objs[i].scene != scene)
                 {
                     continue;
                 }
                 if (PatchContent(objs[i].transform))
                 {
                     _PatchedThisFrame++;
                 }
                 if (_PatchedThisFrame >= _PatchesPerFrame || i % _MaxObjectsPerFrame == 0)
                 {
                     _PatchedThisFrame = 0;
                     yield return(null);
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
    public void Update()
    {
        if (ModInput.GetButtonDown("FreeCam Toggle"))
        {
            IsEnabled = !IsEnabled;

            if (!IsEnabled)
            {
                Time.timeScale = 1f;

                FreeCamera.enabled = false;
                if (PrevCamera != null)
                {
                    PrevCamera.enabled = true;
                }
            }
            else
            {
                QualitySettings.lodBias         = 1f;
                QualitySettings.maximumLODLevel = 0;

                PrevCamera = Camera.main;
                if (PrevCamera != null)
                {
                    FreeCamera.transform.position    = PrevCamera.transform.position;
                    FreeCamera.transform.eulerAngles = new Vector3(0f, PrevCamera.transform.eulerAngles.y, 0f);
                    MouseLook.targetDirection        = PrevCamera.transform.rotation.eulerAngles;
                    MouseLook.mouseAbsolute          = Vector2.zero;
                    FreeCamera.fieldOfView           = PrevCamera.fieldOfView;
                    if (FreeCamera.fieldOfView < 10f)
                    {
                        FreeCamera.fieldOfView = 75f;
                    }
                    PrevCamera.enabled = false;
                }
                FreeCamera.enabled = true;

                if (CameraManager.Instance != null)
                {
                    ApplyDOFToFreeCam();
                }
            }

            ModLogger.Log("freecam", $"{(IsEnabled ? "Enabled" : "Disabled")} MAGIC CAMERA™ mode.");
        }

        if (IsEnabled && ModInput.GetButtonDown("FreeCam Light Toggle"))
        {
            IsFullBright = !IsFullBright;
        }
        if (!WasFullBright && IsFullBright)
        {
            OriginalAmbienceColor       = RenderSettings.ambientLight;
            RenderSettings.ambientLight = new Color(1f, 1f, 1f, 1f);
        }
        else if (WasFullBright && !IsFullBright)
        {
            RenderSettings.ambientLight = OriginalAmbienceColor;
        }
        WasFullBright = IsFullBright;

        if (CameraManager.Instance != null)
        {
            CameraManager.Instance.enabled = !IsEnabled;
        }

        GUIInfoGroup.Visible = IsEnabled && IsGUIVisible;

        if (_FreeCamera != null)
        {
            MouseLook.enabled = IsEnabled;
        }

        if (!IsEnabled)
        {
            return;
        }

        MouseLook.enabled = !ModGUI.MainGroup.Visible;

        if (ModInput.GetButtonDown("FreeCam GUI Toggle"))
        {
            IsGUIVisible = !IsGUIVisible;
        }
        if (ModInput.GetButtonDown("FreeCam Game GUI Toggle Ext"))
        {
            ModGUI.ToggleGameGUI();
        }

        /*
         * if (CameraManager.Instance != null) {
         *  FreeCamera.enabled = true;
         *  if (Camera.main != null && Camera.main != FreeCamera)
         *      ApplyDOFToFreeCam();
         * }
         */

        FreeCamera.enabled = true;

        Transform camt = FreeCamera.transform;

        Speed = Mathf.Max(0.01f, Speed + 0.01f * ModInput.GetAxis("FreeCam Move Speed"));
        if (ModInput.GetButton("FreeCam Move Speed Reset"))
        {
            Speed = DefaultSpeed;
        }

        float speed = Speed;

        if (ModInput.GetButton("FreeCam Run"))
        {
            speed *= 4f;
        }

        Vector3 dir = Vector3.zero;

        dir += camt.forward * ModInput.GetAxis("Vertical");

        float angleY = camt.rotation.eulerAngles.y;

        angleY = (angleY + 90f) / 180f * Mathf.PI;
        if (camt.rotation.eulerAngles.z == 180f)
        {
            angleY += Mathf.PI;
        }
        dir += new Vector3(Mathf.Sin(angleY), 0f, Mathf.Cos(angleY)) * ModInput.GetAxis("Horizontal");

        if (dir != Vector3.zero)
        {
            dir.Normalize();
            camt.position += dir * speed * SpeedF;
        }

        camt.position += Vector3.up * ModInput.GetAxis("FreeCam Y Movement") * speed * SpeedF;

        float timeScalePrev = Time.timeScale;

        Time.timeScale = Mathf.Clamp(Time.timeScale + ModInput.GetAxis("FreeCam Game Speed") * (
                                         Time.timeScale < 0.24999f ? 0.01f :
                                         Time.timeScale < 1.99999f ? 0.05f :
                                         Time.timeScale < 7.99999f ? 0.5f :
                                         Time.timeScale < 15.99999f ? 1f :
                                         4f
                                         ), 0f, 100f);

        if (ModInput.GetButton("FreeCam Game Speed Reset"))
        {
            Time.timeScale = 1f;
        }

        if (ModInput.GetButton("FreeCam Game Speed Freeze"))
        {
            Time.timeScale = 0f;
        }

        int scaleRound = Mathf.FloorToInt(Time.timeScale * 100f);

        if (Time.timeScale >= 0.25f && scaleRound % 10 == 9)
        {
            Time.timeScale = (scaleRound + 1) / 100f;
        }

        GUIInfoGameSpeed.Text = $"Game speed: {Mathf.FloorToInt(Time.timeScale * 100f)}%";
        GUIInfoMoveSpeed.Text = $"Movement speed: {(speed / DefaultSpeed * 100f).ToString("N0")}%";
        GUIInfoSceneName.Text = $"Scene (level): {SceneManager.GetActiveScene().name}";
        Vector3 pos = camt.position;
        Vector3 rot = camt.eulerAngles;

        GUIInfoPosition.Text = $"Position: {pos.x.ToString("0000.00")}, {pos.y.ToString("0000.00")}, {pos.z.ToString("0000.00")}";
        GUIInfoRotation.Text = $"Rotation: {rot.x.ToString("0000.00")}, {rot.y.ToString("0000.00")}, {rot.z.ToString("0000.00")}";
    }
Ejemplo n.º 11
0
        public void TestLog__Info()
        {
            logger.Log(LogType.Log, "well hi there");

            innerLogger.Received().Log(LogType.Log, "[MyMod] well hi there");
        }
Ejemplo n.º 12
0
            public bool Load()
            {
                if (mStarted)
                {
                    if (mErrorOnLoading)
                    {
                        return(false);
                    }
                    return(true);
                }
                mErrorOnLoading = false;
                Logger.Log($"Version '{Info.Version}'. Loading.");
                if (string.IsNullOrEmpty(Info.AssemblyName))
                {
                    mErrorOnLoading = true;
                    Logger.Error(string.Format("{0} is null.", "AssemblyName"));
                }
                if (string.IsNullOrEmpty(Info.EntryMethod))
                {
                    mErrorOnLoading = true;
                    Logger.Error(string.Format("{0} is null.", "EntryMethod"));
                }
                if (!string.IsNullOrEmpty(Info.ManagerVersion) && ManagerVersion > GetVersion())
                {
                    mErrorOnLoading = true;
                    Logger.Error($"Mod Manager must be version '{Info.ManagerVersion}' or higher.");
                }
                if (Requirements.Count > 0)
                {
                    foreach (KeyValuePair <string, Version> requirement in Requirements)
                    {
                        string   key      = requirement.Key;
                        ModEntry modEntry = FindMod(key);
                        if (modEntry == null || modEntry.Assembly == null)
                        {
                            mErrorOnLoading = true;
                            Logger.Error($"Required mod '{key}' not loaded.");
                        }
                        else if (!modEntry.Enabled)
                        {
                            mErrorOnLoading = true;
                            Logger.Error($"Required mod '{key}' disabled.");
                        }
                        else if (!modEntry.Active)
                        {
                            Logger.Log($"Required mod '{key}' inactive.");
                        }
                        else if (requirement.Value != null && requirement.Value > modEntry.Version)
                        {
                            mErrorOnLoading = true;
                            Logger.Error($"Required mod '{key}' must be version '{requirement.Value}' or higher.");
                        }
                    }
                }
                if (mErrorOnLoading)
                {
                    return(false);
                }
                string text = System.IO.Path.Combine(Path, Info.AssemblyName);

                if (File.Exists(text))
                {
                    try
                    {
                        if (mAssembly == null)
                        {
                            mAssembly = Assembly.LoadFile(text);
                        }
                    }
                    catch (Exception ex)
                    {
                        mErrorOnLoading = true;
                        Logger.Error($"Error loading file '{text}'.");
                        Logger.Error(ex.ToString());
                        return(false);
                    }
                    try
                    {
                        object[] param = new object[1]
                        {
                            this
                        };
                        Type[] types = new Type[1]
                        {
                            typeof(ModEntry)
                        };
                        if (FindMethod(Info.EntryMethod, types, showLog: false) == null)
                        {
                            param = null;
                            types = null;
                        }
                        if (!Invoke(Info.EntryMethod, out object result, param, types) || (result != null && !(bool)result))
                        {
                            mErrorOnLoading = true;
                            Logger.Log("Not loaded.");
                        }
                    }
                    catch (Exception ex2)
                    {
                        mErrorOnLoading = true;
                        Logger.Error($"Error loading file '{text}'.");
                        Logger.Error(ex2.ToString());
                        return(false);
                    }
                    mStarted = true;
                    if (!mErrorOnLoading && Enabled)
                    {
                        Active = true;
                        return(true);
                    }
                }
                else
                {
                    mErrorOnLoading = true;
                    Logger.Error($"'{text}' not found.");
                }
                return(false);
            }
Ejemplo n.º 13
0
        public static bool readDictionaryFile(string fileName)
        {
            //We need to do as much word parsing and processing as possible on startup to reduce lag. Adding a few extra seconds to server startup isn't near as bad as causing chat lag
            int    counter = 0;
            string line;
            string secondWord = "";

            //if dictionary file is not found, switch to using the shitty built-in dictionary rules instead
            if (!File.Exists(fileName))
            {
                return(false);
            }

            System.IO.StreamReader file = new System.IO.StreamReader(fileName);
            while ((line = file.ReadLine()) != null)
            {
                int            i       = 0;
                WordConversion tempVar = new WordConversion();
                while (line[i] != '=')
                {
                    tempVar.originalWord += line[i];
                    i++;
                }
                newLog.Log("made it past the first while loop. Yay!");
                for (int u = i + 1; u < line.Length; u++)
                {
                    newLog.Log("u = " + u);
                    //keep in mind & is the yarrml whitespace character since spaces in my yarml file are used to seperate and delimit multiple entries
                    //if (line[u] == '&')
                    //{
                    //secondWord += ' ';
                    //}
                    //else
                    //{
                    secondWord += line[u];
                    //}
                    //this should get me a list of all the remaining characters in the line in one single variable
                }
                newLog.Log("made it past that one for loop. Woot!");
                newLog.Log("original word is " + tempVar.originalWord);
                int y = 0;
                foreach (string word in secondWord.Split(' '))
                {
                    if (word.Contains("&"))
                    {
                        tempVar.changeItToThis.Add(word.Replace("&", " "));
                        newLog.Log("found a new result word to add which is" + word.Replace("&", " "));
                    }
                    else
                    {
                        tempVar.changeItToThis.Add(word);
                        newLog.Log("found a new result word to add which is" + word);
                    }
                    y++;
                }
                if (y > 1)
                {
                    tempVar.multipleResults = true;
                }
                else
                {
                    tempVar.multipleResults = false;
                }
                listOfShitAndStuff.Add(new WordConversion());
                listOfShitAndStuff.ToArray()[counter].originalWord    = tempVar.originalWord;
                listOfShitAndStuff.ToArray()[counter].changeItToThis  = tempVar.changeItToThis;
                listOfShitAndStuff.ToArray()[counter].multipleResults = tempVar.multipleResults;
                secondWord = "";
                counter++;
            }

            file.Close();

            newLog.Log("there were " + counter + "lines parsed");

            /*foreach (WordConversion j in listOfShitAndStuff)
             * {
             *  newLog.Log("original word = " + j.originalWord);
             *  newLog.Log("to be replaced by" + j.changeItToThis);
             *  newLog.Log("multiple results" + j.multipleResults.ToString());
             * }*/

            //return false means there were zero results found and therefore file not found
            if (counter > 0)
            {
                newLog.Log("read dictionary file without crashing. yay!");
                return(true);
            }
            else
            {
                newLog.Log("file " + dictionaryFileName + " not found.");
                return(false);
            }
        }
Ejemplo n.º 14
0
 public static void log(string message)
 {
     logger.Log(message);
 }
Ejemplo n.º 15
0
 public void Load()
 {
     logger.Log("Starting Debugger");
     UnityEngine.Object.DontDestroyOnLoad(GameObject);
 }
        protected override bool StartUnlocked => true;         // TODO: Change this to false

        protected override void ApplyUpgrade(PlayerModel player, bool isFirstTime)
        {
            ModLogger.Log("Acquired Viktor's AR Glasses");
        }