コード例 #1
0
        private void LoadSteamConfig()
        {
            Logger.LogInformation("Loading Steam system configuration.");
            var steamKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam");

            if (steamKey == null)
            {
                Logger.LogError("Steam could not be detected from the registry.");
                return;
            }

            var installDir = (string)steamKey.GetValue("SteamPath");

            Logger.LogInformation($"Found Steam at {installDir}");

            Cache.LibraryPaths.Add(Path.Combine(installDir, @"steamapps\common"));

            try
            {
                _configVdf = VdfConvert.Deserialize(File.ReadAllText($@"{installDir}\config\config.vdf"));
            }
            catch (Exception e)
            {
                Logger.LogError(e, "Encountered an exception while reading the VDF. Steam configuration will not be loaded.");
                return;
            }

            Logger.LogInformation("Steam configuration loaded successfully.");
        }
コード例 #2
0
        public static VProperty AddProperty(this VToken vdf, string key, object value = null)
        {
            var property = new VProperty(key, new VValue(value ?? ""));

            (vdf as VObject).Add(property);
            return(property);
        }
コード例 #3
0
        private void load()
        {
            String strSteamInstallPath = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Valve\\Steam").GetValue("InstallPath").ToString();

            Console.WriteLine(strSteamInstallPath);
            VProperty volvo = VdfConvert.Deserialize(File.ReadAllText(strSteamInstallPath + "\\config\\loginusers.vdf"));

            foreach (VToken vt in volvo.Value.ToList())
            {
                dynamic user         = VdfConvert.Deserialize(vt.ToString());
                Int64   steamId      = Convert.ToInt64(user.Key);
                String  accountName  = user.Value.AccountName.ToString();
                String  personalName = user.Value.PersonaName.ToString();
                Console.WriteLine(accountName);
                Image picture;

                try
                {
                    picture = Image.FromFile(strSteamInstallPath + "\\config\\avatarcache\\" + steamId + ".png");
                }
                catch (FileNotFoundException E)
                {
                    picture = Easy_switch.Properties.Resources.questionPicture;
                }


                flPanel.Controls.Add(createPanel(picture, accountName, personalName));
                flPanel.Update();
                flPanel.Show();
            }
        }
コード例 #4
0
 public static void ReID(this VProperty vProperty, ref int highID)
 {
     if (vProperty.Name == "id")
     {
         vProperty.Value = (highID++).ToString();
     }
 }
コード例 #5
0
        public Dictionary <string, SteamUserInfo> get()
        {
            FileStream    fs   = File.OpenRead(Path);
            StringBuilder sb   = new StringBuilder();
            int           code = 0;

            do
            {
                byte[] bt = new byte[fs.Length > 1024 ? 1024 : fs.Length];
                code = fs.Read(bt, 0, bt.Length);
                sb.Append(UTF8Encoding.UTF8.GetString(bt));
            } while (code == 1024);
            fs.Close();
            VProperty v = VdfConvert.Deserialize(sb.ToString());

            VToken[] keys = v.Value.ToArray <VToken>();
            Dictionary <string, SteamUserInfo> list = new Dictionary <string, SteamUserInfo>();

            foreach (VToken vt in keys)
            {
                dynamic       data = vt;
                SteamUserInfo user = new SteamUserInfo();
                user.user = data.Value.AccountName.ToString();
                user.id64 = data.Key;
                user.name = data.Value.PersonaName.ToString();
                list.Add(data.Key, user);
            }
            return(list);
        }
コード例 #6
0
 public static string[] GetSteamLibraryPaths()
 {
     string[] libraryPaths = Array.Empty <string>();
     using (RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))// Doesn't work in 32 bit mode without this
     {
         using (RegistryKey steamKey = hklm?.OpenSubKey(STEAM_PATH_KEY))
         {
             string path = (string)steamKey?.GetValue("InstallPath", string.Empty);
             if (path != null && path.Length > 0)
             {
                 string configPath = Path.Combine(path, STEAM_CONFIG_PATH);
                 if (File.Exists(configPath))
                 {
                     VProperty   v             = VdfConvert.Deserialize(File.ReadAllText(configPath));
                     VToken      ics           = v?.Value;
                     VToken      soft          = ics?["Software"];
                     VToken      valve         = soft?["Valve"];
                     VObject     steamSettings = valve?["Steam"] as VObject;
                     VProperty[] settings      = steamSettings?.Children <VProperty>()?.ToArray();
                     if (settings != null)
                     {
                         libraryPaths = settings.Where(p => p.Key.StartsWith("BaseInstallFolder"))
                                        .Select(p => p.Value.ToString()).ToArray();
                     }
                 }
             }
         }
     }
     return(libraryPaths);
 }
コード例 #7
0
        private void ParseVDFLibraries(string libraryFile, ref List <string> directories)
        {
            try
            {
                VProperty library = VdfConvert.Deserialize(File.ReadAllText(libraryFile));
                foreach (var child in library?.Value?.Children())
                {
                    VProperty prop = child as VProperty;
                    if (prop == null)
                    {
                        Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries failed to convert entity to VProperty: {child}");
                        continue;
                    }

                    // Folders have a numeric value
                    if (!Int32.TryParse(prop.Key, out _))
                    {
                        continue;
                    }

                    string path = string.Empty;
                    if (prop.Value.Type == VTokenType.Value)
                    {
                        path = prop.Value?.ToString();
                        if (String.IsNullOrEmpty(path) || !Directory.Exists(path))
                        {
                            Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries (Old Format) failed to locate path: {prop}");
                            continue;
                        }
                    }
                    else if (prop.Value.Type == VTokenType.Object)
                    {
                        path = prop.Value?["path"]?.ToString();
                        if (string.IsNullOrEmpty(path))
                        {
                            Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries failed to locate path: {prop}");
                            continue;
                        }

                        string mounted = prop.Value?["mounted"]?.ToString() ?? "1";
                        if (mounted != "1")
                        {
                            Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries skipping unmounted folder: {path}");
                            continue;
                        }
                    }
                    else
                    {
                        Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} ParseVDFLibraries invalid property type: {prop.Value.Type} for {prop}");
                        continue;
                    }

                    directories.Add(Path.Combine(path, STEAM_APPS_DIR));
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"{this.GetType()} ParseVDFLibraries Exception: {ex}");
            }
        }
コード例 #8
0
        void GetCraftbotPath()
        {
            // Get Steam location from registry
            SteamInstallPath = (String)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", "NOT FOUND");
            Debug.Print("SteamPath: \"{0}\"", SteamInstallPath);
            if (!Directory.Exists(SteamInstallPath))
            {
                SteamError();
            }
            // Turning VDF into JSON, because it's not possible to select the "1" key with VDF
            // Unique case worth fixing:
            // TODO: Fix exception when installation on external drive is disconnected
            dynamic libraryfoldersjson = new VProperty();

            try
            {
                libraryfoldersjson = VdfConvert.Deserialize(File.ReadAllText(SteamInstallPath + "\\steamapps\\libraryfolders.vdf")).Value.ToJson();
            }
            catch
            {
                SteamError();
            }
            if (File.Exists(SteamInstallPath + "\\steamapps\\appmanifest_387990.acf"))
            {
                CraftingPath = SteamInstallPath + "\\steamapps\\common\\Scrap Mechanic\\Survival\\CraftingRecipes\\";
            }
            else
            {
                CraftingPath = libraryfoldersjson.Value <String>("1") + "\\steamapps\\common\\Scrap Mechanic\\Survival\\CraftingRecipes\\";
            }

            Debug.Print("Registered steam: " + SteamInstallPath);
            Debug.Print("Game Path:        " + CraftingPath);
        }
コード例 #9
0
        public void CommentsDeserializeCorrectly()
        {
            const string vdf    = @"
                // Comment type A (at the start of the file)
                ""root""
                {
                    // Comment type B (as a child to an object)
                    key1 ""value1""
                    ""key2"" // Comment type C (to the right of a property name)
                    {
                        ""key3"" ""value3"" // Comment type D (to the right of a property value)
                    }
                }
                // Comment type E (at the end of the file)
            ";
            VProperty    result = VdfConvert.Deserialize(vdf);

            VProperty expected = new VProperty("root", new VObject
            {
                VValue.CreateComment(" Comment type B (as a child to an object)"),
                new VProperty("key1", new VValue("value1")),
                new VProperty("key2", new VObject
                {
                    new VProperty("key3", new VValue("value3")),
                    VValue.CreateComment(" Comment type D (to the right of a property value)"),
                }),
            });

            Assert.True(VToken.DeepEquals(result, expected));
        }
コード例 #10
0
        public void DeepEqualsSucceedsCorrectly()
        {
            VProperty prop1 = new VProperty("key1", new VValue("value1"));
            VProperty prop2 = new VProperty("key1", new VValue("value1"));

            Assert.True(VToken.DeepEquals(prop1, prop2));
        }
コード例 #11
0
        public List <GameRom> GetSteamGame(Emulator emu)
        {
            string steamfolder;
            var    key64 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam";
            var    key32 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam";

            if (Environment.Is64BitOperatingSystem)
            {
                steamfolder = (string)Microsoft.Win32.Registry.GetValue(key64, "InstallPath", string.Empty);
            }
            else
            {
                steamfolder = (string)Microsoft.Win32.Registry.GetValue(key32, "InstallPath", string.Empty);
            }

            if (steamfolder != null)
            {
                List <string> foldersTosearch = new List <string>();
                foldersTosearch.Add(Path.Combine(steamfolder, "steamapps"));
                VProperty volvo  = VdfConvert.Deserialize(File.ReadAllText(Path.Combine(steamfolder, "steamapps", "libraryfolders.vdf")));
                var       childs = volvo.Value.Children();
                foreach (var child in childs)
                {
                    var childKV      = (VProperty)child;
                    var childValueKV = childKV.Value;
                    var pathchildKV  = childValueKV.FirstOrDefault();
                    if (pathchildKV != null)
                    {
                        //if (Directory.Exists(((VProperty)child).Value.ToString()))
                        if (Directory.Exists(((VProperty)pathchildKV).Value.ToString()))
                        {
                            foldersTosearch.Add(Path.Combine(((VProperty)pathchildKV).Value.ToString(), "steamapps"));
                        }
                    }
                }
                List <GameRom> gamesfind        = new List <GameRom>();
                List <String>  appmanifestfiles = new List <string>();
                foreach (string foldertoSeek in foldersTosearch)
                {
                    appmanifestfiles.AddRange(Directory.GetFiles(foldertoSeek, "appmanifest_*.acf").ToList());
                }

                foreach (var file in appmanifestfiles)
                {
                    dynamic appfile = VdfConvert.Deserialize(File.ReadAllText(file));
                    GameRom game    = new GameRom();
                    game.EmulatorID = emu.EmulatorID;
                    game.SteamID    = int.Parse(appfile.Value.appid.Value);
                    game.Name       = appfile.Value.name.Value;

                    gamesfind.Add(game);
                }
                return(gamesfind);
            }
            else
            {
                return(null);
            }
        }
コード例 #12
0
        public static JProperty ToJson(this VProperty prop, VdfJsonConversionSettings settings = null)
        {
            if (settings == null)
            {
                settings = new VdfJsonConversionSettings();
            }

            return(new JProperty(prop.Key, prop.Value.ToJson(settings)));
        }
コード例 #13
0
 public LoginUsers(VProperty volvo)
 {
     SteamId64        = ulong.Parse(volvo.Key);
     AccountName      = volvo.Value[@"AccountName"].ToString();
     PersonaName      = volvo.Value[@"PersonaName"].ToString();
     RememberPassword = int.Parse(volvo.Value[@"RememberPassword"].ToString()) == 1;
     MostRecent       = int.Parse(volvo.Value[@"mostrecent"].ToString()) == 1;
     LastLoginTime    = Utils.Util.GetTime(volvo.Value[@"Timestamp"].ToString());
 }
コード例 #14
0
        static public VProperty InsertValueIntoMaterial <T>(dynamic Material, string parameter, T value)
        {
            VValue    vvalue          = new VValue(value);
            VProperty propertyToWrite = CaseInsensitiveParameterCheck(Material.Value, parameter);

            propertyToWrite.Value = vvalue;
            Material.Value.Add(propertyToWrite);
            return(RemoveProxiesWithOverridingMaterialParameters(Material, parameter));
        }
コード例 #15
0
        public void DeepEqualsFailsCorrectly()
        {
            VProperty prop1 = new VProperty("key1", new VValue("value1"));
            VProperty prop2 = new VProperty("key2", new VValue("value1"));
            VProperty prop3 = new VProperty("key1", new VValue("value2"));

            Assert.False(VToken.DeepEquals(prop1, prop2));
            Assert.False(VToken.DeepEquals(prop1, prop3));
        }
コード例 #16
0
        static public VProperty InsertVector3IntoMaterial(dynamic Material, string parameter, float[] values)
        {
            VValue    vvalue          = new VValue("[" + string.Join(" ", values) + "]");
            VProperty propertyToWrite = CaseInsensitiveParameterCheck(Material.Value, parameter);

            propertyToWrite.Value = vvalue;
            Material.Value.Add(propertyToWrite);
            return(RemoveProxiesWithOverridingMaterialParameters(Material, parameter));
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
        public static bool ProcessTriggerBhop(VProperty bhop, StringBuilder sb)
        {
            var propDelay             = bhop.Value["delay"];
            var propTarget            = bhop.Value["target"];
            var propUseLandmarkAngles = bhop.Value["UseLandmarkAngles"];

            if (bhop.Value["target"] == null)
            {
                WriteError("Target Destination on trigger_bhop is empty.");
                return(false);
            }

            var delay = propDelay != null?float.Parse(propDelay.ToString()) : 0.07f;

            var target            = propTarget.ToString();
            var useLandmarkAngles = propUseLandmarkAngles != null?propUseLandmarkAngles.ToString() : "0";

            var filterName = "_ex_bhop";

            // Write the teleport trigger.
            sb.AppendLine("entity {");
            sb.AppendLine("classname \"trigger_teleport\"");
            sb.AppendLine("spawnflags \"4097\"");
            sb.AppendLine($"filtername \"{filterName}\"");
            sb.AppendLine($"target \"{target}\"");
            sb.AppendLine($"UseLandmarkAngles \"{useLandmarkAngles}\"");
            AppendSolids(bhop, sb);
            sb.AppendLine("}");

            // Write the filter trigger.
            sb.AppendLine("entity {");
            sb.AppendLine("classname \"trigger_multiple\"");
            sb.AppendLine("spawnflags \"4097\"");
            sb.AppendLine("wait \"0.02\"");
            sb.AppendLine("connections {");
            sb.AppendLine($"OnStartTouch \"!activator{ESC}AddOutput{ESC}targetname {filterName}{ESC}{delay}{ESC}-1\"");
            sb.AppendLine($"OnStartTouch \"!activator{ESC}AddOutput{ESC}targetname default{ESC}{delay + 0.02}{ESC}-1\"");
            sb.AppendLine("}");
            AppendSolids(bhop, sb);
            sb.AppendLine("}");

            // Write filter.
            if (!BhopFilter)
            {
                BhopFilter = true;

                sb.AppendLine("entity {");
                sb.AppendLine("classname \"filter_activator_name\"");
                sb.AppendLine($"filtername \"{filterName}\"");
                sb.AppendLine("Negated \"Allow entities that match criteria\"");
                sb.AppendLine($"targetname \"{filterName}\"");
                sb.AppendLine($"origin \"{Cube.ORIGIN}\"");
                sb.AppendLine("}");
            }

            return(true);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
 public static void AppendSolids(VProperty vdf, StringBuilder sb)
 {
     foreach (var prop in vdf.Value.Cast <VProperty>())
     {
         if (prop.Key == "solid")
         {
             sb.AppendLine(prop.ToString());
         }
     }
 }
コード例 #19
0
        static void ModMountCfg(string gmod, string cstrike)
        {
            VProperty prop = VdfConvert.Deserialize(File.ReadAllText(string.Join(Path.DirectorySeparatorChar, new List <string> {
                gmod, "garrysmod", "cfg", "mount.cfg"
            })));

            prop.Value["cstrike"] = new VValue(cstrike);
            File.WriteAllText(string.Join(Path.DirectorySeparatorChar, new List <string> {
                gmod, "garrysmod", "cfg", "mount.cfg"
            }), VdfConvert.Serialize(prop));
        }
コード例 #20
0
ファイル: VPK_Reader.cs プロジェクト: 18swenskiq/SourcePorter
        public void GrabTexturesFromMaterials()
        {
            VProperty currentVmt = VdfConvert.Deserialize(File.ReadAllText("graygrid.vmt"));


            foreach (VToken token in currentVmt.Value)
            {
                Console.WriteLine(token.Value <VProperty>().Key);

                // Check if the value of this field is a texture in the VPK
            }
        }
コード例 #21
0
        /// <summary>
        /// Gets the games folder path.
        /// </summary>
        public static IEnumerable <string> GetGamesFolderPaths()
        {
            string SteamPath   = SteamHelper.GetSteamAppsPath();
            string LibraryPath = SteamHelper.GetLibraryPath();
            string LibraryFile = File.ReadAllText(LibraryPath);

            if (string.IsNullOrEmpty(LibraryFile) == false)
            {
                VProperty Library = VdfConvert.Deserialize(LibraryFile);
                JProperty Json    = Library.ToJson();

                if (Json.Value["1"] != null)
                {
                    string GamesPath = Json.Value["1"].ToObject <string>();

                    if (string.IsNullOrEmpty(GamesPath) == false)
                    {
                        if (string.IsNullOrEmpty(GamesPath) == false)
                        {
                            string CommonPath = Path.Combine(GamesPath, "steamapps\\common\\");

                            if (string.IsNullOrEmpty(CommonPath) == false)
                            {
                                yield return(CommonPath);
                            }
                            else
                            {
                                Log.Warning(typeof(SteamHelper), "CommonPath is empty.");
                            }
                        }
                        else
                        {
                            Log.Warning(typeof(SteamHelper), "GamesPath is empty.");
                        }
                    }
                    else
                    {
                        Log.Warning(typeof(SteamHelper), "GamesPath property is empty.");
                    }
                }
                else
                {
                    Log.Warning(typeof(SteamHelper), "LibraryFolders property is empty.");
                }
            }
            else
            {
                Log.Error(typeof(SteamHelper), "Empty ?");
            }

            yield return(Path.Combine(SteamPath, "common"));
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
 public static void ProcessTriggerReset(VProperty reset, StringBuilder sb)
 {
     // Write the filter reset trigger.
     sb.AppendLine("entity {");
     sb.AppendLine("classname trigger_multiple");
     sb.AppendLine("spawnflags \"4097\"");
     sb.AppendLine("wait \"0.02\"");
     sb.AppendLine("connections {");
     sb.AppendLine($"OnStartTouch \"!activator{ESC}AddOutput{ESC}targetname default{ESC}0.02{ESC}-1\"");
     sb.AppendLine("}");
     AppendSolids(reset, sb);
     sb.AppendLine("}");
 }
コード例 #23
0
        public void DeepCloneWorksCorrectly()
        {
            VProperty original = new VProperty("key1", new VObject
            {
                new VProperty("key2", new VValue("value2")),
            });

            VProperty clone = original.DeepClone() as VProperty;

            clone.Value = new VValue("value3");

            Assert.True(original.Value is VObject);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
 public static void ProcessTriggerAntiBhop(VProperty antibhop, StringBuilder sb)
 {
     sb.AppendLine("entity {");
     sb.AppendLine("classname \"trigger_multiple\"");
     sb.AppendLine("spawnflags \"4097\"");
     sb.AppendLine("wait \"0.02\"");
     sb.AppendLine("connections {");
     sb.AppendLine($"OnStartTouch \"!activator{ESC}RunScriptCode{ESC}local v=self.GetVelocity();if(v.z>0.01){{v.z=-v.z*0.25;self.SetVelocity(v);}}{ESC}0.01{ESC}-1\"");
     sb.AppendLine($"OnStartTouch \"!activator{ESC}RunScriptCode{ESC}local v=self.GetVelocity();if(v.z>0.01){{v.z=-v.z*0.50;self.SetVelocity(v);}}{ESC}0.05{ESC}-1\"");
     sb.AppendLine($"OnStartTouch \"!activator{ESC}AddOutput{ESC}gravity 1{ESC}0.2{ESC}-1\"");
     sb.AppendLine($"OnStartTouch \"!activator{ESC}AddOutput{ESC}gravity 40{ESC}0.1{ESC}-1\"");
     sb.AppendLine("}");
     AppendSolids(antibhop, sb);
     sb.AppendLine("}");
 }
コード例 #25
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
 public static void CacheStuff(VProperty vdf)
 {
     foreach (var prop in vdf.Value.Cast <VProperty>())
     {
         if (prop.Key == "entity")
         {
             switch (prop.Value["classname"].ToString())
             {
             case "info_teleport_destination":
                 CacheInfoTeleportDestination(prop);
                 break;
             }
         }
     }
 }
コード例 #26
0
        private static void HandleValueDuplicateKey(JObject baseObj, VProperty prop, VdfJsonConversionSettings settings)
        {
            switch (settings.ValueDuplicateKeyHandling)
            {
            case DuplicateKeyHandling.Ignore:
                break;

            case DuplicateKeyHandling.Replace:
                baseObj[prop.Key] = prop.Value.ToJson(settings);
                break;

            case DuplicateKeyHandling.Throw:
                throw new Exception($"Key '{prop.Key}' already exists in object.");
            }
        }
コード例 #27
0
ファイル: Connection.cs プロジェクト: emily33901/BrakeMyMap
        public Connection(VProperty val)
        {
            connection = val;
            output     = val.Key;
            // TODO: this split token can change per engine version
            string[] parts = val.Value.ToString().Split('\x1b');


            // parse the input
            TargetEntity = parts[0];
            input        = parts[1];
            parameter    = parts[2];
            delay        = float.Parse(parts[3]);
            timesToFire  = int.Parse(parts[4]);
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: Szwagi/HammerEx
        public static bool ProcessTriggerAntiCrouch(VProperty anticrouch, StringBuilder sb)
        {
            var propTarget            = anticrouch.Value["target"];
            var propUseLandmarkAngles = anticrouch.Value["UseLandmarkAngles"];

            if (anticrouch.Value["target"] == null)
            {
                WriteError("Target Destination on trigger_anti_crouch is empty.");
                return(false);
            }

            var target            = propTarget.ToString();
            var useLandmarkAngles = propUseLandmarkAngles != null?int.Parse(propUseLandmarkAngles.ToString()) != 0 : false;

            if (!TeleportDestinations.TryGetValue(target, out var tpDest))
            {
                WriteError($"Target Destination '{target}' on trigger_anti_crouch doesn't exist.");
                return(false);
            }

            var px = tpDest.px;
            var py = tpDest.py;
            var pz = tpDest.pz;
            var rx = tpDest.rx;
            var ry = tpDest.ry;
            var rz = tpDest.rz;

            // Write the trigger.
            sb.AppendLine("entity {");
            sb.AppendLine("classname \"trigger_multiple\"");
            sb.AppendLine("spawnflags \"4097\"");
            sb.AppendLine("wait \"0.02\"");
            sb.AppendLine("connections {");
            if (useLandmarkAngles)
            {
                sb.AppendLine($"OnTrigger \"!activator{ESC}RunScriptCode{ESC}if(self.GetBoundingMaxs().z<70.0){{local v=self.GetVelocity();v.z=0;self.SetVelocity(v);self.SetOrigin(Vector({px},{py},{pz}));self.SetAngles({rx},{ry},{rz});}}{ESC}0.03{ESC}-1\"");
            }
            else
            {
                sb.AppendLine($"OnTrigger \"!activator{ESC}RunScriptCode{ESC}if(self.GetBoundingMaxs().z<70.0){{local v=self.GetVelocity();v.z=0;self.SetVelocity(v);self.SetOrigin(Vector({px},{py},{pz}));}}{ESC}0.03{ESC}-1\"");
            }
            sb.AppendLine("}");
            AppendSolids(anticrouch, sb);
            sb.AppendLine("}");

            return(true);
        }
コード例 #29
0
        public void DoubleSlashInValueDeserializesCorrectly()
        {
            const string vdf    = @"
                ""root""
                {
                    ""key1"" ""//""
                }
            ";
            VProperty    result = VdfConvert.Deserialize(vdf);

            VProperty expected = new VProperty("root", new VObject
            {
                new VProperty("key1", new VValue("//")),
            });

            Assert.True(VToken.DeepEquals(result, expected));
        }
コード例 #30
0
        /// <summary>
        ///  Finds the collection of Steam library folders
        /// </summary>
        /// <param name="steamPath">The located path to the Steam installation folder.</param>
        /// <returns>The collection of Steam library folders.</returns>
        ///
        /// <exception cref="ArgumentNullException">
        ///  <paramref name="steamPath"/> is null.
        /// </exception>
        /// <exception cref="SteamException">
        ///  An error occurred while reading the Steam folders.
        /// </exception>
        public static SteamLibraryFolders FindLibrariesFromSteamPath(string steamPath)
        {
            if (steamPath == null)
            {
                throw new ArgumentNullException(nameof(steamPath));
            }

            List <string> folders = new List <string>();

            steamPath = PrettifyDir(steamPath);
            string steamApps = Path.Combine(steamPath, SteamApps);

            if (!PathUtils.IsValidDirectory(steamPath) || !Directory.Exists(steamApps))
            {
                throw new SteamException($"Steam installation path does not have a \"{SteamApps}\" folder!");
            }
            folders.Add(steamPath);

            string libraryFolders         = Path.Combine(steamApps, LibraryFolders);
            string libraryFoldersRelative = Path.Combine(SteamApps, LibraryFolders);             // Relative for exceptions

            if (!File.Exists(libraryFolders))
            {
                throw new SteamException($"Steam installation path does not have a \"{libraryFoldersRelative}\" file!");
            }
            try {
                VProperty vlibsRoot = VdfConvert.Deserialize(File.ReadAllText(libraryFolders));
                VObject   vlibs     = vlibsRoot.Value as VObject;
                int       index     = 1;
                while (vlibs.TryGetValue((index++).ToString(), out VToken vlibToken))
                {
                    string folder = vlibToken.Value <string>();
                    if (PathUtils.IsValidDirectory(folder) && Directory.Exists(folder))
                    {
                        folders.Add(PrettifyDir(folder));
                    }
                }
            } catch (Exception ex) {
                throw new SteamException($"An error occurred while trying to load the " +
                                         $"\"{libraryFoldersRelative}\" file!", ex);
            }

            return(new SteamLibraryFolders(steamPath, folders));
        }