Beispiel #1
0
 public override void Update()
 {
     if (GlobalVariables.GetGlobalVariables().keyBindShowDevelopWindows.IsDown())
     {
         GlobalVariables.GetGlobalVariables().developWindows.IsEnable = true;
     }
     if (GlobalVariables.GetGlobalVariables().keyBindHideDevelopWindows.IsDown())
     {
         GlobalVariables.GetGlobalVariables().developWindows.IsEnable = false;
     }
     if (GlobalVariables.GetGlobalVariables().keyBindReadAllTxt.IsDown())
     {
         GlobalVariables.GetGlobalVariables().mscTranslate.translateText.ReadTranslateTextDict();
     }
     if (GlobalVariables.GetGlobalVariables().keyBindWriteGameObjectToTxt.IsDown())
     {
         WriteGameObject("Systems");
         logger.LOG("写入所有Systems路径下的GameObject到txt");
     }
     if (GlobalVariables.GetGlobalVariables().keyBindWriteFVToTxt.IsDown())
     {
         string[] text = { FsmVariablesUtil.GetAllFsmVariablesAndVaule() };
         File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_FsmVariables.txt"), text);
         logger.LOG("写入所有FsmVariables变量到FsmVariables.txt");
     }
     if (GlobalVariables.GetGlobalVariables().developWindows.isShowCameraData)
     {
         ReadCameraState();
     }
 }
Beispiel #2
0
        public void WriteTranslateTextDict(string dictKey)
        {
            List <string> list = ConverUtil.ConverDictionaryToList(translateTextDict[dictKey]);

            File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), dictKey + ".txt"), list.ToArray());
            logger.LOG("写入" + dictKey + ".txt文件完成");
        }
Beispiel #3
0
        public override void Update()
        {
            if (Application.loadedLevelName == "GAME")
            {
                try
                {
                    if (!m_isLoaded)
                    {
                        if (GameObject.Find("fish trap(itemx)") == null)
                        {
                            return;
                        }

                        // load bundle
                        var path = ModLoader.GetModAssetsFolder(this);
                        if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL") && Application.platform == RuntimePlatform.WindowsPlayer)
                        {
                            path = Path.Combine(path, "bundle-linux");                             // apparently fixes opengl
                        }
                        else if (Application.platform == RuntimePlatform.WindowsPlayer)
                        {
                            path = Path.Combine(path, "bundle-windows");
                        }
                        else if (Application.platform == RuntimePlatform.OSXPlayer)
                        {
                            path = Path.Combine(path, "bundle-osx");
                        }
                        else if (Application.platform == RuntimePlatform.LinuxPlayer)
                        {
                            path = Path.Combine(path, "bundle-linux");
                        }

                        if (!File.Exists(path))
                        {
                            ModConsole.Error("Couldn't find asset bundle from path " + path);
                        }
                        else
                        {
                            m_bundle = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(path));
                            GameObject.Instantiate(m_bundle.LoadAsset <GameObject>("ExplosivesPrefab"))
                            .AddComponent <BoxBehaviour>();
                            m_bundle.Unload(false);
                        }

                        m_isLoaded = true;
                    }
                }
                catch (Exception e)
                {
                    m_isLoaded = true;
                    ModConsole.Error(e.ToString());
                }
            }
            else if (Application.loadedLevelName != "GAME" && m_isLoaded)
            {
                m_isLoaded = false;
            }
        }
Beispiel #4
0
        public void ReadTranslateTextDict(string dictKey)
        {
            List <string> list = File.ReadAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), dictKey + ".txt")).ToList();
            Dictionary <string, string> dict = ConverUtil.ConverListToDictionary(list);

            translateTextDict[dictKey]     = dict;
            translateTextSizeDict[dictKey] = dict.Count;
            logger.LOG("读取" + dictKey + ".txt文件完成");
        }
Beispiel #5
0
        // Update is called once per frame
        public override void Update()
        {
            try
            {
                if (Application.loadedLevelName == "GAME")
                {
                    if (!m_isLoaded)
                    {
                        var path = Path.Combine(ModLoader.GetModAssetsFolder(this), "missing.txt");
                        m_missing = new List <string>();
                        if (File.Exists(path))
                        {
                            m_missing = File.ReadAllLines(path).ToList();
                        }

                        if (GameObject.Find("RadioChannels/Channel1") == null)
                        {
                            return;
                        }
                        if (GameObject.Find("GUI/Indicators/Subtitles") == null)
                        {
                            return;
                        }
                        if (GameObject.Find("PLAYER") == null)
                        {
                            return;
                        }

                        m_radioChannel1Source    = GameObject.Find("RadioChannels/Channel1").GetComponent <AudioSource>();
                        m_radioFolkSource        = GameObject.Find("RadioChannels/Folk").GetComponent <AudioSource>();
                        m_subtitlesText          = GameObject.Find("GUI/Indicators/Subtitles").GetComponent <TextMesh>();
                        m_subtitlesText.richText = true;                         // enable rich text because why would you not have this enabled?
                        m_player = GameObject.Find("PLAYER");

                        m_isLoaded = true;
                    }
                }
                else if (Application.loadedLevelName != "GAME" && m_isLoaded)
                {
                    m_isLoaded            = false;
                    m_radioChannel1Source = null;
                    m_radioFolkSource     = null;
                    m_player        = null;
                    m_subtitlesText = null;
                }

                if (m_isLoaded)
                {
                    UpdateRadioSubtitles();
                }
            }
            catch (Exception e)
            {
                ModConsole.Error(e.ToString());
            }
        }
Beispiel #6
0
        private void initializeAudio()
        {
            // Written, 03.11.2020

            this.turboBackfire                     = this.rigidPart.AddComponent <AudioSource>();
            this.turboBackfireModAudio             = new ModAudio();
            this.turboBackfireModAudio.audioSource = this.turboBackfire;
            this.turboBackfireModAudio.LoadAudioFromFile(System.IO.Path.Combine(ModLoader.GetModAssetsFolder(TurboMod.instance), "backFire_once.wav"), true, false);
            this.turboBackfire.minDistance  = 1f;
            this.turboBackfire.maxDistance  = 10f;
            this.turboBackfire.spatialBlend = 1f;
            this.turboBackfire.volume       = 1;
            //this.turboBackfire.pitch = 1.33f;
        }
Beispiel #7
0
        public override void Update()
        {
            if (Application.loadedLevelName == "GAME")
            {
                if (!m_isLoaded)
                {
                    if (GameObject.Find("PLAYER") == null)
                    {
                        return;
                    }

                    var path = ModLoader.GetModAssetsFolder(this);
                    if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL") && Application.platform == RuntimePlatform.WindowsPlayer)
                    {
                        path = Path.Combine(path, "bundle-linux");                         // apparently fixes opengl
                    }
                    else if (Application.platform == RuntimePlatform.WindowsPlayer)
                    {
                        path = Path.Combine(path, "bundle-windows");
                    }
                    else if (Application.platform == RuntimePlatform.OSXPlayer)
                    {
                        path = Path.Combine(path, "bundle-osx");
                    }
                    else if (Application.platform == RuntimePlatform.LinuxPlayer)
                    {
                        path = Path.Combine(path, "bundle-linux");
                    }

                    if (!File.Exists(path))
                    {
                        ModConsole.Error("Couldn't find asset bundle from path " + path);
                        return;
                    }

                    m_bundle = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(path));

                    var asset = m_bundle.LoadAsset <GameObject>("WoodCarrierPrefab");
                    GameObject.Instantiate(asset).AddComponent <WoodCarrierBehaviour>().id = "home";
                    GameObject.Instantiate(asset).AddComponent <WoodCarrierBehaviour>().id = "cottage";

                    m_bundle.Unload(false);
                    m_isLoaded = true;
                }
            }
            else if (Application.loadedLevelName != "GAME" && m_isLoaded)
            {
                m_isLoaded = false;
            }
        }
Beispiel #8
0
        private void SetupMod()
        {
            ModConsole.Print("Mobile Phone mod loading assetbundle...");
            var path = ModLoader.GetModAssetsFolder(this);

            if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL") && Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = Path.Combine(path, "bundle-linux");                 // apparently fixes opengl
            }
            else if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = Path.Combine(path, "bundle-windows");
            }
            else if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                path = Path.Combine(path, "bundle-osx");
            }
            else if (Application.platform == RuntimePlatform.LinuxPlayer)
            {
                path = Path.Combine(path, "bundle-linux");
            }

            if (!File.Exists(path))
            {
                ModConsole.Error("Couldn't find asset bundle from path " + path);
            }
            else
            {
                var bundle = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(path));
                var prefab = bundle.LoadAsset <GameObject>("PhonePrefab");

                var headPhone = GameObject.Instantiate(prefab);
                GameObject.Destroy(headPhone.GetComponent <Collider>());
                GameObject.Destroy(headPhone.GetComponent <Rigidbody>());
                headPhone.transform.SetParent(GameObject.Find("PLAYER/Pivot/Camera/FPSCamera").transform, false);
                headPhone.transform.localPosition = new Vector3(0.2f, -0.05f, 0.1f);
                headPhone.transform.localRotation = Quaternion.Euler(new Vector3(300, 355, 0));
                headPhone.transform.localScale    = new Vector3(1, 1, 1);
                headPhone.gameObject.SetActive(false);

                var phone = GameObject.Instantiate(prefab);
                phone.AddComponent <PhoneBehaviour>().headPhone = headPhone;

                bundle.Unload(false);

                ModConsole.Print("Mobile Phone mod Setup!");
            }
        }
Beispiel #9
0
        private void SetupMod()
        {
            ModConsole.Print("Magazines mod loading assetbundle...");
            var path = ModLoader.GetModAssetsFolder(this);

            if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL") && Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = Path.Combine(path, "bundle-linux");                 // apparently fixes opengl
            }
            else if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = Path.Combine(path, "bundle-windows");
            }
            else if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                path = Path.Combine(path, "bundle-osx");
            }
            else if (Application.platform == RuntimePlatform.LinuxPlayer)
            {
                path = Path.Combine(path, "bundle-linux");
            }

            if (!File.Exists(path))
            {
                ModConsole.Error("Couldn't find asset bundle from path " + path);
            }
            else
            {
                m_bundle = AssetBundle.CreateFromMemoryImmediate(File.ReadAllBytes(path));

                var canvas = GameObject.Instantiate(m_bundle.LoadAssetWithSubAssets <GameObject>("MagazineCanvas")[0]).GetComponent <Canvas>();
                canvas.gameObject.SetActive(false);
                m_reader = canvas.gameObject.AddComponent <MagazineReader>();

                var obj = GameObject.Instantiate(m_bundle.LoadAsset <GameObject>("MagazineRackPrefab"));
                m_rack = obj.AddComponent <RackBehaviour>();

                m_bundle.Unload(false);
            }
        }
Beispiel #10
0
 private void WriteText(string text, string fileNmae)
 {
     File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), fileNmae), text);
 }
Beispiel #11
0
        private void WriteGameObject(GameObject gameObject)
        {
            string text = GameObjectUtil.GetGameObjectText(gameObject, 0, true, true);

            File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObject.txt"), text);
        }
Beispiel #12
0
 public override void OnLoad()
 {
     assetPath = ModLoader.GetModAssetsFolder(this);
     Keybind.Add(this, keyMoreDirt);
     Keybind.Add(this, keyLessDirt);
 }
Beispiel #13
0
        private void UpdateRadioSubtitles()
        {
            // only show subtitles when playing
            AudioSource source = null;

            if (m_radioChannel1Source.isPlaying && m_radioChannel1Source.volume > 0 && !m_radioChannel1Source.mute)
            {
                source = m_radioChannel1Source;
            }
            if (m_radioFolkSource.isPlaying && m_radioFolkSource.volume > 0 && !m_radioFolkSource.mute)
            {
                source = m_radioFolkSource;
            }

            if (source == null)
            {
                ClearSubtitles();
                return;
            }

            var distance = Vector3.Distance(m_player.transform.position, source.transform.position);

            if (distance > (5 + source.volume * 10f))
            {
                ClearSubtitles();
                return;
            }

            // load subtitles
            var clip = source.clip.name;

            if (m_subtitlesFileOpen != clip)
            {
                var path = Path.Combine(ModLoader.GetModAssetsFolder(this), clip + ".encore.txt");
                if (File.Exists(path))
                {
                    m_subtitlesFileOpen = clip;
                    var lines = File.ReadAllLines(path);
                    m_subtitles = new List <Subtitle>();
                    foreach (var line in lines)
                    {
                        var sub   = new Subtitle();
                        var split = line.Split(' ');
                        sub.start = ConvertTime(split[1]);
                        sub.end   = ConvertTime(split[2]);
                        var str = "";
                        for (var i = 3; i < split.Length; ++i)
                        {
                            str += split[i] + " ";
                        }
                        sub.text = str;
                        m_subtitles.Add(sub);
                    }
                }
                else
                {
                    if (!m_missing.Contains(clip) && source == m_radioChannel1Source)
                    {
                        m_missing.Add(clip);
                        File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(this), "missing.txt"), m_missing.ToArray());
                    }
                }
            }
            else
            {
                // correct subtitle is open
                // has to be at least 6 meters from radio to get subtitles
                if (m_subtitles.Any())
                {
                    var sub = m_subtitles[0];
                    if (source.time > sub.start && (m_subtitlesText.text == m_lastSubtitles || m_subtitlesText.text == ""))
                    {
                        m_subtitlesText.text = sub.text;
                        m_lastSubtitles      = sub.text;
                    }
                    if (source.time > sub.end)
                    {
                        ClearSubtitles();
                        m_subtitles.RemoveAt(0);
                    }
                }
            }
        }
Beispiel #14
0
 private void _initAudioAsync()
 {
     if (_audio.SwitchOn == null)
     {
         if (_load == null)
         {
             _load = new WWW("file:///" + Path.Combine(ModLoader.GetModAssetsFolder(this), _audio.SwitchOnFile));
         }
         if (!_load.isDone)
         {
             return;
         }
         _audio.SwitchOn                  = _lamp.AddComponent <AudioSource>();
         _audio.SwitchOn.clip             = _load.GetAudioClip(true);
         _audio.SwitchOn.transform.parent = _lamp.transform;
         _audio.SwitchOn.spatialBlend     = 1.0f;
         _audio.SwitchOn.maxDistance      = 5.0f;
         _load = null;
         ModConsole.Print("Loaded SwitchOn");
     }
     if (_audio.SwitchOff == null)
     {
         if (_load == null)
         {
             _load = new WWW("file:///" + Path.Combine(ModLoader.GetModAssetsFolder(this), _audio.SwitchOffFile));
         }
         if (!_load.isDone)
         {
             return;
         }
         _audio.SwitchOff                  = _lamp.AddComponent <AudioSource>();
         _audio.SwitchOff.clip             = _load.GetAudioClip(true);
         _audio.SwitchOff.transform.parent = _lamp.transform;
         _audio.SwitchOff.spatialBlend     = 1.0f;
         _audio.SwitchOff.maxDistance      = 5.0f;
         _load = null;
         ModConsole.Print("Loaded SwitchOff");
     }
     if (_audio.HumLoop == null)
     {
         if (_load == null)
         {
             _load = new WWW("file:///" + Path.Combine(ModLoader.GetModAssetsFolder(this), _audio.HumLoopFile));
         }
         if (!_load.isDone)
         {
             return;
         }
         _audio.HumLoop                  = _lamp.AddComponent <AudioSource>();
         _audio.HumLoop.clip             = _load.GetAudioClip(true);
         _audio.HumLoop.loop             = true;
         _audio.HumLoop.volume           = 0.3f;
         _audio.HumLoop.transform.parent = _lamp.transform;
         _audio.HumLoop.spatialBlend     = 1.0f;
         _audio.HumLoop.maxDistance      = 5.0f;
         _load = null;
         ModConsole.Print("Loaded Hum");
     }
     if (_audio.Disconnect == null)
     {
         if (_load == null)
         {
             _load = new WWW("file:///" + Path.Combine(ModLoader.GetModAssetsFolder(this), _audio.DisconnectFile));
         }
         if (!_load.isDone)
         {
             return;
         }
         _audio.Disconnect                  = _lamp.AddComponent <AudioSource>();
         _audio.Disconnect.clip             = _load.GetAudioClip(true);
         _audio.Disconnect.transform.parent = _lamp.transform;
         _audio.Disconnect.spatialBlend     = 1.0f;
         _audio.Disconnect.maxDistance      = 10.0f;
         _load = null;
         ModConsole.Print("Loaded Disconnect");
     }
     if (_audio.Break == null)
     {
         if (_load == null)
         {
             _load = new WWW("file:///" + Path.Combine(ModLoader.GetModAssetsFolder(this), _audio.BreakFile));
         }
         if (!_load.isDone)
         {
             return;
         }
         _audio.Break                  = _lamp.AddComponent <AudioSource>();
         _audio.Break.clip             = _load.GetAudioClip(true);
         _audio.Break.transform.parent = _lamp.transform;
         _audio.Break.spatialBlend     = 1.0f;
         _audio.Break.maxDistance      = 30.0f;
         _load = null;
         ModConsole.Print("Loaded Break");
     }
     _audio.HasLoaded = true;
 }
Beispiel #15
0
        private void GuiGameObjectExplorerWindows(int windowsId)
        {
            if (GUILayout.Button("关闭 unity版本:" + Application.unityVersion))
            {
                isShow = false;
            }

            try
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);

                GUILayout.BeginArea(new Rect(0, 0, 500, 600));

                if (GUILayout.Button("所有GameObject列表(先输筛选的文本再点)"))
                {
                    parentGameObject = null;
                    gameObjectList   = GameObjectUtil.GetAllGameObject();
                }
                if (GUILayout.Button("所有GameObject写入txt(out目录,会卡到吐血)"))
                {
                    parentGameObject = null;
                    gameObjectList   = GameObjectUtil.GetAllGameObject();
                    string text  = "";
                    int    index = 0;
                    foreach (GameObject gameObject in gameObjectList)
                    {
                        text += GameObjectUtil.GetGameObjectText(gameObject, 0, true, true, true, false, false);
                        text += "\n";
                        logger.LOG("写入gameObject ->" + index++);
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "out/_AllGameObject" + index + "_" + gameObject.name + ".txt"), text);
                    }
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("读取根节点"))
                {
                    parentGameObject = null;
                    // gameObjectList = new List<GameObject>(Application. UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects());
                    gameObjectList = GameObjectUtil.GetRootGameObject();
                }

                if (parentGameObject != null)
                {
                    if (GUILayout.Button("<"))
                    {
                        if (parentGameObject.transform.parent == null)
                        {
                            parentGameObject = null;
                            gameObjectList   = GameObjectUtil.GetRootGameObject();
                            // gameObjectList = new List<GameObject>( UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects());
                        }
                        else
                        {
                            gameObjectList   = GameObjectUtil.GetChildGameObjectList(parentGameObject.transform.parent.gameObject);
                            parentGameObject = parentGameObject.transform.parent.gameObject;
                        }
                    }
                }
                GUILayout.EndHorizontal();
                searchName = GUILayout.TextField(searchName);

                gameObjectListScrollPosition = GUILayout.BeginScrollView(gameObjectListScrollPosition);
                if (gameObjectList != null)
                {
                    foreach (GameObject gameObject in gameObjectList)
                    {
                        if (searchName != null && !searchName.Equals(""))
                        {
                            if (gameObject.name.ToLower().IndexOf(searchName.ToLower()) == -1)
                            {
                                continue;
                            }
                        }
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button(gameObject.name))
                        {
                            selectGameObject          = gameObject;
                            selectGameObjectComponent = new List <Component>(gameObject.GetComponents <Component>());
                        }
                        if (GUILayout.Button(">"))
                        {
                            parentGameObject = gameObject;
                            gameObjectList   = GameObjectUtil.GetChildGameObjectList(gameObject);
                        }
                        if (GUILayout.Button("传过去"))
                        {
                            GlobalVariables.GetGlobalVariables().teleport.TeleportTo(GameObjectUtil.GetGameObjectPath(gameObject));
                        }
                        if (GUILayout.Button("传过来"))
                        {
                            GameObject playerGameObject = GameObject.Find("PLAYER");
                            Vector3    clonePosition    = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z);
                            gameObject.transform.position = clonePosition;
                        }
                        if (GUILayout.Button("克隆"))
                        {
                            GameObject playerGameObject = GameObject.Find("PLAYER");
                            Vector3    clonePosition    = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z);
                            // GameObject cloneGameObject = MonoBehaviour.Instantiate(gameObject, clonePosition, gameObject.transform.rotation) as GameObject;
                            gameObject.SetActive(false);
                            GameObject cloneGameObject = GameObject.Instantiate(gameObject);
                            cloneGameObject.transform.position = clonePosition;
                        }
                        if (gameObject.activeSelf == false)
                        {
                            if (GUILayout.Button("启用"))
                            {
                                gameObject.SetActive(true);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("禁用"))
                            {
                                gameObject.SetActive(false);
                            }
                        }

                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();

                GUILayout.EndArea();


                GUILayout.BeginArea(new Rect(500, 0, 500, 600));
                if (selectGameObject != null)
                {
                    GUILayout.Label("选中GameObject:" + GameObjectUtil.GetGameObjectPath(selectGameObject));
                    if (GUILayout.Button("写入txt"))
                    {
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObject.txt"), GameObjectUtil.GetGameObjectText(selectGameObject, 0, true, true, true, false, false));
                    }

                    viewScrollPosition = GUILayout.BeginScrollView(viewScrollPosition);
                    string text = "";
                    foreach (Component component in selectGameObjectComponent)
                    {
                        Type type = component.GetType();
                        GUILayout.Label(type.FullName);
                        GUILayout.BeginVertical("box");
                        foreach (FieldInfo fieldInfo in type.GetFields())
                        {
                            string view = fieldInfo.Name + " : " + fieldInfo.GetValue(component);
                            text += view + "\n";
                            GUILayout.Label(view);
                        }
                        foreach (PropertyInfo propertyInfo in type.GetProperties())
                        {
                            try
                            {
                                string view = "  " + propertyInfo.Name + " : \n" + propertyInfo.GetValue(component, null);
                                text += view + "\n";
                                GUILayout.Label(view);
                            }
                            catch (Exception e)
                            {
                                string view = "  " + propertyInfo.Name + " : \n Error " + e.Message;
                                text += view + "\n";
                                GUILayout.Label(view);
                            }
                        }
                        if (component.GetType().Name.Equals("PlayMakerFSM"))
                        {
                            PlayMakerFSM playMakerFSM = component as PlayMakerFSM;
                            string       view         = "Component is PlayMakerFSM : \n" + FsmVariablesUtil.GetAllFsmVariablesAndVaule(playMakerFSM.FsmVariables);
                            text += view + "\n";
                            GUILayout.Label(view);
                        }

                        GUILayout.EndVertical();
                    }
                    if (GUILayout.Button("写入显示内容到txt"))
                    {
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObjectViewText.txt"), text);
                    }
                    GUILayout.EndScrollView();
                }
                GUILayout.EndArea();


                GUILayout.EndScrollView();
            }
            catch (Exception e)
            {
                GUILayout.Label("exception : " + e.Message);
            }
            GUI.DragWindow();
        }
        public override void OnMenuLoad()
        {
            ScrewablePartV2.version = this.Version;
            string availableVersion = this.Version;

            modsFolderFilePath   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            dllFilePath          = Path.Combine(modsFolderFilePath, $"{ID}.dll");
            xmlFilePath          = Path.Combine(modsFolderFilePath, $"{ID}.xml");
            assetsBundleFilePath = Path.Combine(ModLoader.GetModAssetsFolder(this), assetsFile);

            old_dllFilePath          = dllFilePath.Replace(".dll", ".old_dll");
            old_xmlFilePath          = xmlFilePath.Replace(".xml", ".old_xml");
            old_assetsBundleFilePath = assetsBundleFilePath.Replace(".unity3d", ".old_unity3d");

            LoadSettingsSave();

            CheckForOldFiles();
            try
            {
                interfaceObject = GameObject.Find("Interface");
                interfaceActive = GameObject.Find("Quad 7");
                quad7           = GameObject.Find("InterfaceActive");
            }
            catch {}

            if (!serverReachable)
            {
                ModConsole.Warning($"{ID} could not reach the update server");
                LoadAssets();
                return;
            }

            if (!(bool)ignoreUpdatesSetting.Value)
            {
                try
                {
                    string responseJson = Helper.MakeGetRequest(GetLatestReleaseVersionUrl(Version));
                    UpdateCheckResponse updateCheckResponse = JsonConvert.DeserializeObject <UpdateCheckResponse>(responseJson);
                    availableVersion = updateCheckResponse.available;
                    switch (updateCheckResponse.message)
                    {
                    case "out-dated":
                        ModConsole.Warning($"ScrewablePartAPI outdated. version {updateCheckResponse.available} available");
                        SetMenuVisibility(false);
                        Helper.ShowCustom2ButtonMessage($"ScrewablePartAPI is outdated\n" +
                                                        $"version {updateCheckResponse.available} is available!!\n" +
                                                        $"Do you want to update automatically?\n" +
                                                        $"(Restart will be required)\n" +
                                                        $"This can break mods using outdated versions", "ScrewablePartAPI is outdated",
                                                        new UnityAction(delegate()
                        {
                            SetMenuVisibility(true);
                            LoadAssets();
                        }),
                                                        new UnityAction(delegate()
                        {
                            InstallVersion(updateCheckResponse.available);
                        }));
                        break;

                    case "up-to-date":
                        availableVersion = Version;
                        LoadAssets();
                        break;

                    default:
                        LoadAssets();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ModConsole.Error(ex.Message);
                    LoadAssets();
                }
            }
            else
            {
                LoadAssets();
            }
            GameObject mscLoaderInfo = GameObject.Find("MSCLoader Info");

            try
            {
                GameObject screwablePartMenuInfoTextObject = GameObject.Instantiate(GameObject.Find("MSCLoader Info Text"));
                screwablePartMenuInfoTextObject.name = "ScrewablePartAPI Info Text";
                screwablePartMenuInfoTextObject.transform.SetParent(mscLoaderInfo.transform);
                Text screwablePartMenuInfoText = screwablePartMenuInfoTextObject.GetComponent <Text>();
                screwablePartMenuInfoText.text =
                    $"{Name} <color=cyan>v{Version}</color> loaded! " +
                    $"({(Version == availableVersion ? "<color=lime>Up to date</color>" : "<color=red>Outdated</color>")})";
            }
            catch { }
        }
Beispiel #17
0
        public void LoadRecorder()
        {
            // Create GameObject, load mesh and set Collider and Rigidbody for recorder.
            GameObject _nokkahuilu = LoadAssets.LoadOBJ(this, Path.Combine(ModLoader.GetModAssetsFolder(this), "nokkahuilu.obj"), true, true);

            _nokkahuilu.name = "Nokkahuilu";
            _nokkahuilu.GetComponent <Rigidbody>().interpolation          = RigidbodyInterpolation.None;
            _nokkahuilu.GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous;

            // Set flute to table.
            _nokkahuilu.transform.position      = new Vector3(-10.03136f, 0.23f, 14.44618f);
            _nokkahuilu.transform.localRotation = Quaternion.Euler(358.67f, 89.36f, 321.8837f);

            // Create Material
            Material mat = new Material(Shader.Find("Specular"));

            mat.name  = "RecorderMaterial";
            mat.color = new Color(0.640f, 0.494f, 0.181f, 1);
            _nokkahuilu.GetComponent <Renderer>().material = mat;

            // Make pivot object for recorder and add the actual recorder logic to it (Recorder.cs)
            GameObject RecorderPivot = new GameObject();

            RecorderPivot.name                    = "RecorderPivot";
            RecorderPivot.transform.parent        = GameObject.Find("FPSCamera").transform;
            RecorderPivot.transform.localPosition = Vector3.zero;
            RecorderPivot.transform.localRotation = Quaternion.Euler(0, 0, 0);
            _nokkahuilu.AddComponent <RecorderCollision>().recorder = RecorderPivot.AddComponent <Recorder>();

            // Instantiate copy of recorder to be used in FPS mode
            GameObject _nokkahuiluFPS = GameObject.Instantiate(_nokkahuilu);

            GameObject.Destroy(_nokkahuiluFPS.GetComponent <MeshCollider>());
            GameObject.Destroy(_nokkahuiluFPS.GetComponent <Rigidbody>());
            _nokkahuiluFPS.transform.parent        = GameObject.Find("FPSCamera").transform;
            _nokkahuiluFPS.transform.localPosition = new Vector3(0.0291f, -0.0919f, 0.301f);
            _nokkahuiluFPS.transform.localRotation = Quaternion.Euler(0, 180, 0);

            // Add and setup AudioSource component for recorder.
            RecorderPivot.gameObject.AddComponent <AudioSource>();
            RecorderPivot.GetComponent <AudioSource>().loop         = true;
            RecorderPivot.GetComponent <AudioSource>().spatialBlend = 0;
            RecorderPivot.GetComponent <AudioSource>().volume       = 1;

            // Set variables to RecorderPivot
            RecorderPivot.GetComponent <Recorder>().audio       = RecorderPivot.GetComponent <AudioSource>();
            RecorderPivot.GetComponent <Recorder>().recorder    = _nokkahuilu.transform;
            RecorderPivot.GetComponent <Recorder>().recorderFPS = _nokkahuiluFPS.transform;
            _nokkahuiluFPS.transform.parent = RecorderPivot.transform;
            _nokkahuiluFPS.gameObject.SetActive(false);

            // Load .wav file using WWW -class.
            WWW RecorderSound = new WWW("file:///" + @Path.Combine(ModLoader.GetModAssetsFolder(this), "g5.wav"));

            while (!RecorderSound.isDone)
            {
            }
            ;                                  // Wait sound to be loaded.

            // Add clip to recorder flute.
            RecorderPivot.GetComponent <AudioSource>().clip = RecorderSound.GetAudioClip(false);

            // Stop the loading loop.
            HasLoaded = true;
        }
        private void DevelopConfigWindowsFunction(int windowsId)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            if (GUILayout.Button("关闭"))
            {
                IsEnable = false;
            }
            GUILayout.Label("左Ctrl+R,重新读取所有txt文本");
            GUILayout.Label("左Ctrl+W,写入Systems下的GameObject到txt");
            GUILayout.Label("左Ctrl+F,写入所有FsmVariables变量到FsmVariables.txt");
            GUILayout.Label("左Ctrl+F,写入所有FsmVariables变量到FsmVariables.txt");
            GlobalVariables.GetGlobalVariables().develop.isRayGameObject = GUILayout.Toggle(GlobalVariables.GetGlobalVariables().develop.isRayGameObject, "是否显示鼠标指向的GameObject信息");

            GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.IsEnable = GUILayout.Toggle(GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.IsEnable, "是否启用GUI GameObject查看");
            if (GUILayout.Button("GUI GameObject 查看窗口"))
            {
                GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.isShow = true;
            }

            if (GUILayout.Button("读取所有Renderer名到文件"))
            {
                Renderer[] renderers = Resources.FindObjectsOfTypeAll <Renderer>();
                string     text      = "";
                foreach (Renderer renderer in renderers)
                {
                    text += renderer.name + "\n";
                    text += "  " + GameObjectUtil.GetGameObjectPath(renderer.gameObject) + "\n";
                }
                File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_renderers.txt"), new string[] { text });
            }

            if (GUILayout.Button("读取所有Material名到文件"))
            {
                Material[] materials = Resources.FindObjectsOfTypeAll <Material>();
                string     text      = "";
                foreach (Material material in materials)
                {
                    text += material.name + "\n";
                }
                File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_materials.txt"), new string[] { text });
            }

            if (GUILayout.Button("重新初始化Mod全局变量"))
            {
                GlobalVariables.GetGlobalVariables().Init();
            }
            isShowGlobalVariablesValue = GUILayout.Toggle(isShowGlobalVariablesValue, "是否显示Mod全局变量详情");
            if (isShowGlobalVariablesValue)
            {
                ShowGlobalVariablesValue();
            }

            isShowAllExecutionTime = GUILayout.Toggle(isShowAllExecutionTime, "是否显示Mod执行效率详情");
            if (isShowAllExecutionTime)
            {
                ShowAllExecutionTime();
            }

            isShowCameraData = GUILayout.Toggle(isShowCameraData, "是否显示摄像机详情");
            if (isShowCameraData)
            {
                ShowCameraData();
            }

            isShowGameOverGameObjectCheck = GUILayout.Toggle(isShowGameOverGameObjectCheck, "是否显示GameOver变量详情");
            if (isShowGameOverGameObjectCheck)
            {
                ShowGameOverGameObjectCheck();
            }

            isShowGameObjectTransformUpdate = GUILayout.Toggle(isShowGameObjectTransformUpdate, "是否显示GameObject位置微调");
            if (isShowGameObjectTransformUpdate)
            {
                ShowGameObjectTransformUpdate();
            }
            isViewFsmAllVariablesAndVaule = GUILayout.Toggle(isViewFsmAllVariablesAndVaule, "是否显示所有游戏内全局变量");
            if (isViewFsmAllVariablesAndVaule)
            {
                ViewFsmAllVariablesAndVaule();
            }

            GUILayout.EndScrollView();
            GUI.DragWindow();
        }
Beispiel #19
0
 public override void OnLoad()
 {
     assetPath = ModLoader.GetModAssetsFolder(this);
 }
        // Update is called once per frame
        public override void Update()
        {
            if (Application.loadedLevelName == "GAME")
            {
                try
                {
                    if (!this.m_isLoaded)
                    {
                        if (GameObject.Find("PLAYER/Pivot/Camera/FPSCamera/1Hand_Assemble/Hand") == null)
                        {
                            return;
                        }
                        if (GameObject.Find("SATSUMA(557kg, 248)") == null)
                        {
                            return;
                        }

                        string patch = Path.Combine(ModLoader.GetModAssetsFolder(this), "trailerbundle");
                        if (!File.Exists(patch))
                        {
                            ModConsole.Error("Couldn't find asset bundle from path " + patch);
                            return;
                        }
                        else
                        {
                            this.m_bundle = LoadAssets.LoadBundle(this, patch);
                            if (m_bundle != null)
                            {
                                hitch = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch"));
                                hitch.AddComponent <HitchBehaviour>();

                                hitchv = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("hitch"));
                                hitchv.AddComponent <HitchVBehaviour>();

                                trailer = UnityEngine.Object.Instantiate <GameObject>(this.m_bundle.LoadAsset <GameObject>("carreta"));
                                trailer.AddComponent <TrailerBehaviour>();

                                trailer.GetComponent <TrailerBehaviour>().Hitch  = hitch;
                                trailer.GetComponent <TrailerBehaviour>().HitchV = hitchv;

                                this.m_bundle.Unload(false);
                            }
                            else
                            {
                                ModConsole.Print("Bundle Null: " + patch);
                            }
                        }
                        this.m_isLoaded = true;
                    }
                    return;
                }
                catch (Exception ex)
                {
                    this.m_isLoaded = false;
                    ModConsole.Error(ex.ToString());
                    return;
                }
            }
            if (Application.loadedLevelName != "GAME" && this.m_isLoaded)
            {
                this.m_isLoaded = false;
            }
        }