/** * Creates a new Vector3 with the same value as the input vector. */ public Vector3Int(IVector3 vector) { x_ = vector.getXAsInteger(); y_ = vector.getYAsInteger(); z_ = vector.getZAsInteger(); }
/** Subtracts a scalar to each component of this vector. * * @param scalar scalar value as double * @return a reference to the called vector (NOT a copy) */ public IVector3 subtract(IVector3 vector) { x_ -= vector.getXAsInteger(); y_ -= vector.getYAsInteger(); z_ -= vector.getZAsInteger(); return this; }
/** Assigns this vector the values of another vector. * * @param vector the other vector * @return a reference to the called vector (NOT a copy) */ public IVector3 assign(IVector3 vector) { x_ = vector.getXAsInteger(); y_ = vector.getYAsInteger(); z_ = vector.getZAsInteger(); return this; }
/** Adds another vector to this vector, adding individual components. * * @param vector the vector to add to this vector * @return a reference to the called vector (NOT a copy) */ public IVector3 add(IVector3 vector) { x_ += vector.getXAsInteger(); y_ += vector.getYAsInteger(); z_ += vector.getZAsInteger(); return this; }
/** Performs a division on the vector. * * @param vector vector * @return a reference to the called vector (NOT a copy) */ public IVector3 divide(IVector3 vector) { x_ /= vector.getXAsInteger(); y_ /= vector.getYAsInteger(); z_ /= vector.getZAsInteger(); return this; }
/** Performs a multiplication on the vector. * * @param vector vector * @return a reference to the called vector (NOT a copy) */ public IVector3 multiply(IVector3 vector) { x_ *= vector.getXAsInteger(); y_ *= vector.getYAsInteger(); z_ *= vector.getZAsInteger(); return this; }
/** Applies a modulo vector. The modulus will be added first so that * values in the interval (-modulus, 0) will wrap over into the positive range. * * @param modulus modulus * @return a reference to the called vector (NOT a copy) */ public IVector3 mod(IVector3 modulus) { int mx = modulus.getXAsInteger(); int my = modulus.getYAsInteger(); int mz = modulus.getZAsInteger(); x_ = (x_ + mx) % mx; y_ = (y_ + my) % my; z_ = (z_ + mz) % mz; return this; }
/** * Set the area size. * @param areasize The area size. */ public void setAreaSize(IVector3 areasize) { synchronized(monitor) { this.areasize = areasize==null? null: new Vector3Int(areasize.getXAsInteger(), areasize.getYAsInteger(), areasize.getZAsInteger()); } }
IVector3 fieldpos = new Vector3Int(position.getXAsInteger(), position.getYAsInteger(), position.getZAsInteger());
/** * Creates a new {@link ContinuousSpace2D} with a special ID. * @param name the name of this space * @param areasize the size of the 2D area * @param actionexecutor executor for component actions */ public Grid3D(Object name, IVector3 areasize) { super(areasize==null? null: new Vector3Int(areasize.getXAsInteger(), areasize.getYAsInteger(), areasize.getZAsInteger())); this.setProperty("name", name); this.objectsygridpos = new MultiCollection(); }
/** * Destroys an object in this space. * @param objectId the object's ID */ public void destroySpaceObject(Object id) { try { synchronized(monitor) { // remove the object from grid IVector3 pos = (IVector3)getSpaceObject(id).getProperty(Space3D.PROPERTY_POSITION); if(pos!=null) { IVector3 fieldpos = new Vector3Int(pos.getXAsInteger(), pos.getYAsInteger(), pos.getZAsInteger()); objectsygridpos.removeObject(fieldpos, spaceobjects.get(id)); } super.destroySpaceObject(id); } } catch(Exception e) { e.printStackTrace(); } }
int sizez = areasize.getZAsInteger();
if(oldpos!=null) oldpos = new Vector3Int(oldpos.getXAsInteger(), oldpos.getYAsInteger(), oldpos.getZAsInteger()); if(objectsygridpos.containsKey(oldpos)) if(newpos!=null) objectsygridpos.add(new Vector3Int(newpos.getXAsInteger(), newpos.getYAsInteger(), newpos.getZAsInteger()), obj);
for(int z=0; ret==null && x<areasize.getZAsInteger(); z++)