public static Vector3Int Parse(string input) { var m = vec_reg.Match(input); if (m.Success) { Vector3Int val = new Vector3Int(); val.x = int.Parse(m.Groups["X"].Value); val.y = int.Parse(m.Groups["Y"].Value); val.z = int.Parse(m.Groups["Z"].Value); return val; } else throw new FormatException("Input string was not in correct format"); }
public static bool TryParse(string input, out Vector3Int ret) { var m = vec_reg.Match(input); ret = new Vector3Int(); if (m.Success) { if (int.TryParse(m.Groups["X"].Value, out ret.x)) if (int.TryParse(m.Groups["Y"].Value, out ret.y)) return int.TryParse(m.Groups["Z"].Value, out ret.z); else return false; else return false; } else return false; }
public static int Dot(Vector3Int a, Vector3Int b) { return a.x * b.x + a.y * b.y + a.z * b.z; }