示例#1
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 4)
     {
         error = $"{args.Count} arguments supplied; should be 4";
         return(false);
     }
     else if (!float.TryParse(args[0], out float i))
     {
         error = $"Unable to parse \"{args[0]}\" (i) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float j))
     {
         error = $"Unable to parse \"{args[1]}\" (j) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float k))
     {
         error = $"Unable to parse \"{args[2]}\" (k) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[3], out float w))
     {
         error = $"Unable to parse \"{args[3]}\" (w) as `float`.";
         return(false);
     }
     else
     {
         result = new RealQuaternion(i, j, k, w);
         error  = null;
         return(true);
     }
 }
示例#2
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 4)
     {
         error = $"{args.Count} arguments supplied; should be 4";
         return(false);
     }
     else if (!float.TryParse(args[0], out float a))
     {
         error = $"Unable to parse \"{args[0]}\" (a) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float r))
     {
         error = $"Unable to parse \"{args[1]}\" (r) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float g))
     {
         error = $"Unable to parse \"{args[2]}\" (g) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[3], out float b))
     {
         error = $"Unable to parse \"{args[3]}\" (b) as `float`.";
         return(false);
     }
     else
     {
         result = new RealArgbColor(a, r, g, b);
         error  = null;
         return(true);
     }
 }
示例#3
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 2)
     {
         error = $"{args.Count} arguments supplied; should be 2";
         return(false);
     }
     else if (!float.TryParse(args[0], out float x))
     {
         error = $"Unable to parse \"{args[0]}\" (x) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float y))
     {
         error = $"Unable to parse \"{args[1]}\" (y) as `float`.";
         return(false);
     }
     else
     {
         result = new RealPoint2d(x, y);
         error  = null;
         return(true);
     }
 }
示例#4
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 3)
     {
         error = $"{args.Count} arguments supplied; should be 3";
         return(false);
     }
     else if (!float.TryParse(args[0], out float i))
     {
         error = $"Unable to parse \"{args[0]}\" (i) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float j))
     {
         error = $"Unable to parse \"{args[1]}\" (j) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float d))
     {
         error = $"Unable to parse \"{args[2]}\" (d) as `float`.";
         return(false);
     }
     else
     {
         result = new RealPlane2d(i, j, d);
         error  = null;
         return(true);
     }
 }
示例#5
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 4)
     {
         error = $"{args.Count} arguments supplied; should be 4";
         return(false);
     }
     else if (!short.TryParse(args[0], out short top))
     {
         error = $"Unable to parse \"{args[0]}\" (top) as `short`.";
         return(false);
     }
     else if (!short.TryParse(args[1], out short left))
     {
         error = $"Unable to parse \"{args[1]}\" (left) as `short`.";
         return(false);
     }
     else if (!short.TryParse(args[2], out short bottom))
     {
         error = $"Unable to parse \"{args[2]}\" (bottom) as `short`.";
         return(false);
     }
     else if (!short.TryParse(args[3], out short right))
     {
         error = $"Unable to parse \"{args[3]}\" (right) as `short`.";
         return(false);
     }
     else
     {
         result = new Rectangle2d(top, left, bottom, right);
         error  = null;
         return(true);
     }
 }
示例#6
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 2)
     {
         error = $"{args.Count} arguments supplied; should be 2";
         return(false);
     }
     else if (!float.TryParse(args[0], out float yaw))
     {
         error = $"Unable to parse \"{args[0]}\" (yaw) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float pitch))
     {
         error = $"Unable to parse \"{args[1]}\" (pitch) as `float`.";
         return(false);
     }
     else
     {
         result = new RealEulerAngles2d(
             Angle.FromDegrees(yaw),
             Angle.FromDegrees(pitch));
         error = null;
         return(true);
     }
 }
示例#7
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     result = cache.StringTable.GetStringId(args[0]);
     error  = null;
     return(true);
 }
示例#8
0
文件: Tag.cs 项目: jaron780/TagTool
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     else if (!cache.TryParseGroupTag(args[0], out Tag groupTag))
     {
         error = $"Invalid tag group specifier: {args[0]}";
         return(false);
     }
     else
     {
         result = groupTag;
         error  = null;
         return(true);
     }
 }
示例#9
0
 public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     else if (!float.TryParse(args[0], out float _value))
     {
         error = $"Unable to parse \"{args[0]}\" as `float`.";
         return(false);
     }
     else
     {
         result = Angle.FromDegrees(_value);
         error  = null;
         return(true);
     }
 }
示例#10
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;
            var argType  = this.GetType().GenericTypeArguments[0];
            var argCount = SetFieldCommand.RangeArgCount(argType);

            if (argCount * 2 != args.Count)
            {
                error = $"{args.Count} arguments supplied; should be {argCount * 2}";
                return(false);
            }

            var min = SetFieldCommand.ParseArgs(cacheContext, argType, null, args.Take(argCount).ToList());

            if (min.Equals(false))
            {
                error = $"{min} (min) is `false`";
                return(false);
            }

            var max = SetFieldCommand.ParseArgs(cacheContext, argType, null, args.Skip(argCount).Take(argCount).ToList());

            if (max.Equals(false))
            {
                error = $"{max} (max) is `false`";
                return(false);
            }

            result = Activator.CreateInstance(this.GetType(), new object[] { min, max }) as IBlamType;
            error  = null;
            return(true);
        }
示例#11
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 2)
            {
                error = $"{args.Count} arguments supplied; should be 4";
                return(false);
            }
            else if (!short.TryParse(args[0], out short x))
            {
                error = $"Unable to parse \"{args[0]}\" (x) as `short`.";
                return(false);
            }
            else if (!short.TryParse(args[1], out short y))
            {
                error = $"Unable to parse \"{args[1]}\" (y) as `short`.";
                return(false);
            }
            else
            {
                result = new Point2d(x, y);
                error  = null;
                return(true);
            }
        }
示例#12
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 3)
     {
         error = $"{args.Count} arguments supplied; should be 3";
         return(false);
     }
     else if (!float.TryParse(args[0], out float r))
     {
         error = $"Unable to parse \"{args[0]}\" (r) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float g))
     {
         error = $"Unable to parse \"{args[1]}\" (g) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float b))
     {
         error = $"Unable to parse \"{args[2]}\" (b) as `float`.";
         return(false);
     }
     else
     {
         result = new RealRgbColor(r, g, b);
         error  = null;
         return(true);
     }
 }
示例#13
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 6)
            {
                error = $"{args.Count} arguments supplied; should be 6";
                return(false);
            }
            else if (!float.TryParse(args[0], out float minX))
            {
                error = $"Unable to parse \"{args[0]}\" (minX) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[1], out float maxX))
            {
                error = $"Unable to parse \"{args[1]}\" (maxX) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[2], out float minY))
            {
                error = $"Unable to parse \"{args[2]}\" (minY) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[3], out float maxY))
            {
                error = $"Unable to parse \"{args[3]}\" (maxY) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[4], out float minZ))
            {
                error = $"Unable to parse \"{args[4]}\" (minZ) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[5], out float maxZ))
            {
                error = $"Unable to parse \"{args[5]}\" (maxZ) as `float`.";
                return(false);
            }
            else
            {
                result = new RealBoundingBox(minX, maxX, minY, maxY, minZ, maxZ);
                error  = null;
                return(true);
            }
        }
示例#14
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 4)
     {
         error = $"{args.Count} arguments supplied; should be 4";
         return(false);
     }
     else if (!float.TryParse(args[0], out float i))
     {
         error = $"Unable to parse \"{args[0]}\" (i) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float j))
     {
         error = $"Unable to parse \"{args[1]}\" (j) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float k))
     {
         error = $"Unable to parse \"{args[2]}\" (k) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[3], out float d))
     {
         error = $"Unable to parse \"{args[3]}\" (d) as `float`.";
         return(false);
     }
     else
     {
         result = new RealPlane3d(i, j, k, d);
         error  = null;
         return(true);
     }
 }
示例#15
0
        public bool TryParse(GameCache cache, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 12)
            {
                error = $"{args.Count} arguments supplied; should be 12";
                return(false);
            }
            else if (!float.TryParse(args[0], out float M11))
            {
                error = $"Unable to parse \"{args[0]}\" (M11) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[1], out float M12))
            {
                error = $"Unable to parse \"{args[1]}\" (M12) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[2], out float M13))
            {
                error = $"Unable to parse \"{args[2]}\" (M13) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[3], out float M21))
            {
                error = $"Unable to parse \"{args[3]}\" (M21) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[4], out float M22))
            {
                error = $"Unable to parse \"{args[4]}\" (M22) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[5], out float M23))
            {
                error = $"Unable to parse \"{args[5]}\" (M23) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[6], out float M31))
            {
                error = $"Unable to parse \"{args[6]}\" (M31) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[7], out float M32))
            {
                error = $"Unable to parse \"{args[7]}\" (M32) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[8], out float M33))
            {
                error = $"Unable to parse \"{args[8]}\" (M33) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[9], out float M41))
            {
                error = $"Unable to parse \"{args[9]}\" (M41) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[10], out float M42))
            {
                error = $"Unable to parse \"{args[10]}\" (M42) as `float`.";
                return(false);
            }
            else if (!float.TryParse(args[11], out float M43))
            {
                error = $"Unable to parse \"{args[11]}\" (M43) as `float`.";
                return(false);
            }
            else
            {
                result = new RealMatrix4x3(
                    M11, M12, M13,
                    M21, M22, M23,
                    M31, M32, M33,
                    M41, M42, M43);

                error = null;
                return(true);
            }
        }
示例#16
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     result = cacheContext.GetStringId(args[0]);
     error  = null;
     return(true);
 }
示例#17
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 1)
     {
         error = $"{args.Count} arguments supplied; should be 1";
         return(false);
     }
     else if (!cacheContext.TryGetTag(args[0], out var tag))
     {
         error = $"Unable to locate tag: {args[0]}";
         return(false);
     }
     else
     {
         result = tag;
         error  = null;
         return(true);
     }
 }
示例#18
0
        public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
        {
            result = null;

            if (args.Count != 2)
            {
                error = $"{args.Count} arguments supplied; should be 2";
                return(false);
            }
            else
            {
                var cacheAddressType = SetFieldCommand.ParseArgs(cacheContext, typeof(CacheResourceAddressType), null, args.Take(1).ToList());
                if (!(cacheAddressType is CacheResourceAddressType))
                {
                    error = $"Failed to parse `{args[0]}` as `CacheAddressType`";
                    return(false);
                }
                else if (!int.TryParse(args[1], out int offset))
                {
                    error = $"Failed to parse `{args[1]}` as `int` (offset).";
                    return(false);
                }
                else
                {
                    result = new CacheResourceAddress((cacheAddressType as CacheResourceAddressType?).Value, offset);
                    error  = null;
                    return(true);
                }
            }
        }
示例#19
0
 public bool TryParse(HaloOnlineCacheContext cacheContext, List <string> args, out IBlamType result, out string error)
 {
     result = null;
     if (args.Count != 3)
     {
         error = $"{args.Count} arguments supplied; should be 3";
         return(false);
     }
     else if (!float.TryParse(args[0], out float x))
     {
         error = $"Unable to parse \"{args[0]}\" (x) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[1], out float y))
     {
         error = $"Unable to parse \"{args[1]}\" (y) as `float`.";
         return(false);
     }
     else if (!float.TryParse(args[2], out float z))
     {
         error = $"Unable to parse \"{args[2]}\" (z) as `float`.";
         return(false);
     }
     else
     {
         result = new RealPoint3d(x, y, z);
         error  = null;
         return(true);
     }
 }