public PhysicObjectBuilder withId(final long id) { return this.withId(EntityId.valueOf(id)); }
/** * Full constructor. * * @param contactX Contact X coordinate value. * @param contactY Contact Y coordinate value. * @param contactZ Contact Z coordinate value. * @param idValue Id of the object found by the ray. */ //@Ensures this.id.equals(EntityId.get(idValue)) == true //@Ensures this.contact.equals(Point3D.xyz(contactX, contactY, contactZ)) //@Ensures this.id != null //@Ensures this.contact != null public RaycastResult(final float contactX, final float contactY, final float contactZ, final long idValue) { this(Point3D.valueOf(contactX, contactY, contactZ), EntityId.valueOf(idValue)); }
@Override public EntityId from(String s) throws MappingException { ImplementationException.throwForNull(s); try { return EntityId.valueOf(Long.parseLong(s)); } catch (final NumberFormatException nfe) { throw new MappingException("Error retrieving id", nfe); } }
@Override public Optional<EntityId> getEntity(final float x, final float y) { final float screenX = x / this.resolutionX; final float screenY = y / this.resolutionY; EntityId id = EntityId.valueOf(this.jni.throwRay(this.pointer.getPointerAddress(), screenX, screenY, false)); if (id.equals(EntityId.WORLD)) { return Optional.empty(); } return Optional.of(id); }
/** * Create a new BaseCity. * * @param id The entity representing this city in the world. * @param initialResource The resources available in the city when creating it. * @param positionOffset Building positions. * @param datas List of building types and their data available. */ protected BaseCity(final CityId id, final PlayerId owner, final Point3D position, final ResourceValue initialResource, final Point3D[] positionOffset, Map<BuildingType, D> datas) { super(); this.id = id; this.position = position; this.owner = owner; this.datas = datas; this.buildings = new ArrayList<>(); this.positionOffset = Arrays.copyOf(positionOffset, positionOffset.length); for (int i = 0; i < this.positionOffset.length; i++) { this.positionOffset[i] = this.positionOffset[i].add(position); } this.producer = new ResourcesProducer(EntityId.valueOf(id.value), System.currentTimeMillis(), initialResource); }