示例#1
0
        public override void Initialize()
        {
            AssetPath = "file:///";
            Caching.expirationDelay = 1;
            Caching.CleanCache();
            _inst = this;
            if (!Directory.Exists(RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor"))
            {
                Directory.CreateDirectory(RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor");
            }

            SavedObjectsPath = RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\Objects.txt";
            if (!File.Exists(SavedObjectsPath))
            {
                File.Create(SavedObjectsPath).Dispose();
            }

            RustBuster2016.API.Hooks.OnRustBusterClientPluginsLoaded += Loaded;
            RustBuster2016.API.Hooks.OnRustBusterClientChat          += OnRustBusterClientChat;

            AssetPath  = AssetPath + @RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\myasset.unity3d";
            MainHolder = new GameObject();
            Handler    = MainHolder.AddComponent <LoadingHandler>();
            UnityEngine.Object.DontDestroyOnLoad(Handler);
            try
            {
                Handler.StartCoroutine(Handler.LoadAsset());
            }
            catch (Exception ex)
            {
                RustBuster2016.API.Hooks.LogData("WorldEditor", "Exception: " + ex);
            }
        }
示例#2
0
        public override void Initialize()
        {
//            var AssetPath_ = "file:///";
            _inst = this;
            if (!Directory.Exists(RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor"))
            {
                Directory.CreateDirectory(RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor");
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var webClient = new WebClient();

            _worldeditorTxtURL =
                true ? "http://absolomrust.ddnss.org/WorldEditor.txt" : "http://192.168.0.199/WorldEditor.txt";

            var filesTxt = webClient.DownloadString(_worldeditorTxtURL);

            foreach (var s in filesTxt.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
            {
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                var fileAndOverwrite = s.Split('|');

                var fileName = RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\" +
                               Path.GetFileName(fileAndOverwrite[0]);

                if (File.Exists(fileName) && !bool.Parse(fileAndOverwrite[1]))
                {
                    continue;
                }

                webClient.DownloadFile(fileAndOverwrite[0], fileName);
            }

            stopwatch.Stop();
            Debug.Log("Downloading WorldEditor files took " + stopwatch.ElapsedMilliseconds + " ms");

            SavedObjectsPath = RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\Objects.txt";
            if (!File.Exists(SavedObjectsPath))
            {
                File.Create(SavedObjectsPath).Dispose();
            }

            RustBuster2016.API.Hooks.OnRustBusterClientPluginsLoaded += OnRustBusterClientPluginsLoaded;
            RustBuster2016.API.Hooks.OnRustBusterClientChat          += OnRustBusterClientChat;
            RustBuster2016.API.Hooks.OnRustBusterClientConsole       += OnRustBusterClientConsole;
            Hooks.OnRustBusterWeaponFire        += OnRustBusterWeaponFire;
            Hooks.OnRustBusterClientDeathScreen += OnRustBusterClientDeathScreen;

            SettingsParser =
                new IniParser(@RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\WorldEditor\\Settings.ini");

//            _missingBundles = new List<string>();
//            var bundlesString = SettingsParser.GetSetting("Settings", "AssetBundles");
            _bundleLink = SettingsParser.GetSetting("Settings", "BundleDownloadLink");

            var bundleLinkSplitted = _bundleLink.Split('|');

            foreach (var bundleLinkEntryString in bundleLinkSplitted)
            {
                if (string.IsNullOrEmpty(bundleLinkEntryString))
                {
                    continue;
                }
                var bundleLinkEntry = bundleLinkEntryString.Split('§');
                Bundles.Add(bundleLinkEntry[0] + "|" + bundleLinkEntry[1]);
            }

//            if (!string.IsNullOrEmpty(bundlesString))
//            {
//                foreach (var bundle in bundlesString.Split(','))
//                {
//                    if (string.IsNullOrEmpty(bundle))
//                        continue;

//                    var bundlePath = (AssetPath_ + @RustBuster2016.API.Hooks.GameDirectory +
//                                     "\\RB_Data\\WorldEditor\\" + bundle + ".unity3d");
//                    if (!File.Exists(bundlePath.Substring(8)))
//                    {
//                        _missingBundles.Add(bundle);
//                        continue;
//                    }
//                    Bundles.Add(bundle + "|" + bundlePath);
//                }
//            }

//            if (_missingBundles.Count != 0)
//            {
//                Rust.Notice.Popup("", "The following bundles are missing: " + string.Join(", ", _missingBundles.ToArray()), 30);
//                Hooks.OnRustBusterClientMove += HooksOnOnRustBusterClientMove;
//                return;
//            }

            MainHolder   = new GameObject();
            Handler      = MainHolder.AddComponent <LoadingHandler>();
            TimedSpawns_ = MainHolder.AddComponent <TimedSpawns>();
            UnityEngine.Object.DontDestroyOnLoad(MainHolder);
        }