Automatic assignment of entities
@@ -286,6 +286,20 @@ public class Vec2 implements Vector<Vec2>, Position{
return this;
}
+ public Vec2 tryFromString(String v){
+ int s = v.indexOf(',', 1);
+ if(s != -1 && v.charAt(0) == '(' && v.charAt(v.length() - 1) == ')'){
+ try{
+ float x = Float.parseFloat(v.substring(1, s));
+ float y = Float.parseFloat(v.substring(s + 1, v.length() - 1));
+ return this.set(x, y);
+ }catch(Exception ex){
+ // Throw a ArcRuntimeException
+ }
+ }
+ return setZero();
+ }
+
/**
* Sets this {@code Vec2} to the value represented by the specified string according to the format of {@link #toString()}.
* @param v the string.
