private void addField(String name, Object value) { if (value == null) { return; } if (value instanceof LocalDate) { // TODO: is this correct? Shouldnt we use LocalTime here? DateTime time = ((LocalDate) value).toDateTimeAtStartOfDay(); addDateTimeInUTC(name, time); } else if (value instanceof Interval) { Interval interval = (Interval) value; DateTime start = interval.getStart(); DateTime end = interval.getEnd(); addDateTimeInUTC(name + "_start", start); addDateTimeInUTC(name + "_end", end); } else if (value instanceof ValueObject) { ValueObject object = (ValueObject) value; inputDocument.addField(name, object.getIndexingValue()); } else if (value instanceof AbstractEntity) { AbstractEntity object = (AbstractEntity) value; inputDocument.addField(name, object.getId()); } else if (value instanceof Collection) { Collection list = (Collection) value; if (!list.isEmpty()) { for (Object object : list) { addField(name, object); } } } else { inputDocument.addField(name, value.toString()); } }
/** * This method will always add these fields to the solr index: * * <ul> * <li>id * <li>tags * <li>type * </ul> * * It will also try to add the keywords list and name properties if they exist. * * @param resource * @param additionalFields * @throws Exception */ public void add(final AbstractEntity resource, final Map<String, Object> additionalFields) { addField("id", resource.getId()); addField("tags", resource.getTags()); addTypeField(resource); maybeAddNamedProperty("keywords", resource); maybeAddNamedProperty("name", resource); if (additionalFields != null) { for (Map.Entry<String, Object> entry : additionalFields.entrySet()) { addField(entry.getKey(), entry.getValue()); } } }
@Override protected synchronized void setApplication(Application app) { if (app.getId().equals(getId())) { application = getProxy() != null ? (Application) getProxy() : app; } else { application = app; // Alex, Mar 2013: added some checks; // i *think* these conditions should not happen, // and so should throw but don't want to break things (yet) if (getParent() == null) { log.warn( "Setting application of " + this + " to " + app + ", but " + this + " is not parented"); } else if (getParent().getApplicationId().equals(app.getParent())) { log.warn( "Setting application of " + this + " to " + app + ", but parent " + getParent() + " has different app " + getParent().getApplication()); } } super.setApplication(app); }
/** Add all parts of the car to the world. */ public void addToWorld(World world) { super.addToWorld(world); world.addObject(rightFront); world.addObject(rightRear); world.addObject(leftFront); world.addObject(leftRear); }
/* (non-Javadoc) * @see com.soartech.simjr.sim.entities.AbstractEntity#tick(double) */ @Override public void processTick(double dt) { if (hit) { return; } Vector3 targetPos = target != null ? target.getPosition() : staticTarget; Vector3 dir = targetPos.subtract(getPosition()).normalized(); setHeading(Math.atan2(dir.y, dir.x)); setVelocity(dir.multiply(speed)); super.processTick(dt); Vector3 newPos = getPosition(); if (newPos.subtract(targetPos).length() < speed * dt * 1.5) { hit = true; getSimulation().detonate(new Detonation(getSimulation(), weapon, target, staticTarget)); // if (shooter != null) // { // removeFlyOut(shooter, this); // } weapon.removeFlyout(this); getSimulation().removeEntity(this); } }
@Override public void render(@Nonnull Graphics g) { if (performRendering()) { super.render(g); if (showNumber && (number != null)) { number.render(g); } } showHighlight = 0; }
@Override public void update(@Nonnull GameContainer container, int delta) { super.update(container, delta); if (showNumber && (number != null)) { number.addToCamera(getDisplayCoordinate().getX(), getDisplayCoordinate().getY()); number.updateHeightAndWidth(); number.setOffset( (MapConstants.TILE_W / 2) - number.getHeight() - number.getWidth(), -number.getHeight() / 2); number.update(container, delta); } }
private void addTypeField(AbstractEntity resource) { String type; if (resource instanceof Session) { type = ObjectType.session.name(); } else if (resource instanceof Person) { type = ObjectType.person.name(); } else if (resource instanceof Event) { type = ObjectType.event.name(); } else { throw new IllegalArgumentException("I cannot index this object type: " + resource.getClass()); } addField("type", type); }
@Override public void render(Batch batch) { super.render(batch); float delta = Gdx.graphics.getDeltaTime(); updateCurrentSpeed(delta); doCollisionDetectionHorizontal(); doCollisionDetectionVertical(); doOutOfMapDetectionBottom(); doItemDetection(); updateLadderFlag(); updateLastXDirection(); }
public AbstractApplication setParent(Entity parent) { super.setParent(parent); return this; }
@Override public void writeSpawnData(ByteBuf data) { if (angler != null) { data.writeInt(angler.getEntityId()); } }
/** Called to update the entity's position/logic. */ @Override public void onUpdate() { onEntityUpdate(); if (fishPosRotationIncrements > 0) { final double var21 = posX + (fishX - posX) / fishPosRotationIncrements; final double var22 = posY + (fishY - posY) / fishPosRotationIncrements; final double var23 = posZ + (fishZ - posZ) / fishPosRotationIncrements; final double var7 = MathHelper.wrapAngleTo180_double(fishYaw - rotationYaw); rotationYaw = (float) (rotationYaw + var7 / fishPosRotationIncrements); rotationPitch = (float) (rotationPitch + (fishPitch - rotationPitch) / fishPosRotationIncrements); --fishPosRotationIncrements; setPosition(var21, var22, var23); setRotation(rotationYaw, rotationPitch); } else { if (!worldObj.isRemote) { if (angler != null) { final ItemStack itemStack = angler.getHeldItem(); if (angler.isDead || !angler.isEntityAlive() || itemStack == null || itemStack.getItem() != Items.fishing_rod || getDistanceSqToEntity(angler) > 1024.0D) { setDead(); angler.fishingChore.fishEntity = null; return; } } else { setDead(); } if (field_146043_c != null) { if (!field_146043_c.isDead) { posX = field_146043_c.posX; posY = field_146043_c.boundingBox.minY + field_146043_c.height * 0.8D; posZ = field_146043_c.posZ; return; } field_146043_c = null; } if (this != null) { if (isDead && field_146043_c != null) { field_146043_c.setDead(); } } } if (field_146044_a > 0) { --field_146044_a; } // TODO // if (this.inGround) // { // if (this.worldObj.getBlock(this.field_146037_g, this.field_146048_h, // this.field_146050_i) == this.field_146046_j) // { // ++this.ticksInGround; // // if (this.ticksInGround >= 20) // { // this.setDead(); // // try // { // angler.fishingChore.fishEntity = null; // } // // catch (NullPointerException e) // { // return; // } // } // // return; // } // // this.inGround = false; // this.motionX *= this.rand.nextFloat() * 0.2F; // this.motionY *= this.rand.nextFloat() * 0.2F; // this.motionZ *= this.rand.nextFloat() * 0.2F; // this.ticksInGround = 0; // this.ticksInAir = 0; // } // // else // { // ++this.ticksInAir; // } Vec3 vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); Vec3 motionVector = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); MovingObjectPosition movingObjectPosition = worldObj.rayTraceBlocks(vector, motionVector); vector = worldObj.getWorldVec3Pool().getVecFromPool(posX, posY, posZ); motionVector = worldObj .getWorldVec3Pool() .getVecFromPool(posX + motionX, posY + motionY, posZ + motionZ); if (movingObjectPosition != null) { motionVector = worldObj .getWorldVec3Pool() .getVecFromPool( movingObjectPosition.hitVec.xCoord, movingObjectPosition.hitVec.yCoord, movingObjectPosition.hitVec.zCoord); } Entity entity = null; final List entityList = worldObj.getEntitiesWithinAABBExcludingEntity( this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double zeroDistance = 0.0D; double vectorDistance; for (int i = 0; i < entityList.size(); ++i) { final Entity entityInList = (Entity) entityList.get(i); if (entityInList.canBeCollidedWith() && (entityInList != angler || ticksInAir >= 5)) { final float boundingBoxExpansion = 0.3F; final AxisAlignedBB bb = entityInList.boundingBox.expand( boundingBoxExpansion, boundingBoxExpansion, boundingBoxExpansion); final MovingObjectPosition interceptPosition = bb.calculateIntercept(vector, motionVector); if (interceptPosition != null) { vectorDistance = vector.distanceTo(interceptPosition.hitVec); if (vectorDistance < zeroDistance || zeroDistance == 0.0D) { entity = entityInList; zeroDistance = vectorDistance; } } } } if (entity != null) { movingObjectPosition = new MovingObjectPosition(entity); } if (movingObjectPosition != null) { if (movingObjectPosition.entityHit != null) { if (movingObjectPosition.entityHit.attackEntityFrom( DamageSource.causeThrownDamage(this, angler), 0)) { field_146043_c = movingObjectPosition.entityHit; } } else { inGround = true; } } if (!inGround) { moveEntity(motionX, motionY, motionZ); final float motion = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI); for (rotationPitch = (float) (Math.atan2(motionY, motion) * 180.0D / Math.PI); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F) {; } while (rotationPitch - prevRotationPitch >= 180.0F) { prevRotationPitch += 360.0F; } while (rotationYaw - prevRotationYaw < -180.0F) { prevRotationYaw -= 360.0F; } while (rotationYaw - prevRotationYaw >= 180.0F) { prevRotationYaw += 360.0F; } rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; float motionModifier = 0.92F; if (onGround || isCollidedHorizontally) { motionModifier = 0.5F; } final byte endByte = 5; double yMotion = 0.0D; for (int i = 0; i < endByte; ++i) { final double boundingBoxMinY = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * (i + 0) / endByte - 0.125D + 0.125D; final double boundingBoxMaxY = boundingBox.minY + (boundingBox.maxY - boundingBox.minY) * (i + 1) / endByte - 0.125D + 0.125D; final AxisAlignedBB bb = AxisAlignedBB.getAABBPool() .getAABB( boundingBox.minX, boundingBoxMinY, boundingBox.minZ, boundingBox.maxX, boundingBoxMaxY, boundingBox.maxZ); if (worldObj.isAABBInMaterial(bb, Material.water)) { yMotion += 1.0D / endByte; } } if (yMotion > 0.0D) { if (ticksCatchable > 0) { --ticksCatchable; } else { short fishCatchChance = 500; if (worldObj.canLightningStrikeAt( MathHelper.floor_double(posX), MathHelper.floor_double(posY) + 1, MathHelper.floor_double(posZ))) { fishCatchChance = 300; } if (rand.nextInt(fishCatchChance) == 0) { ticksCatchable = rand.nextInt(30) + 10; motionY -= 0.20000000298023224D; playSound( "random.splash", 0.25F, 1.0F + (rand.nextFloat() - rand.nextFloat()) * 0.4F); final float floorMinY = MathHelper.floor_double(boundingBox.minY); int i; float randomFloat1; float randomFloat2; for (i = 0; i < 1.0F + width * 20.0F; ++i) { randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width; randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width; worldObj.spawnParticle( "bubble", posX + randomFloat1, floorMinY + 1.0F, posZ + randomFloat2, motionX, motionY - rand.nextFloat() * 0.2F, motionZ); } for (i = 0; i < 1.0F + width * 20.0F; ++i) { randomFloat1 = (rand.nextFloat() * 2.0F - 1.0F) * width; randomFloat2 = (rand.nextFloat() * 2.0F - 1.0F) * width; worldObj.spawnParticle( "splash", posX + randomFloat1, floorMinY + 1.0F, posZ + randomFloat2, motionX, motionY, motionZ); } } } } if (ticksCatchable > 0) { motionY -= rand.nextFloat() * rand.nextFloat() * rand.nextFloat() * 0.2D; } vectorDistance = yMotion * 2.0D - 1.0D; motionY += 0.03999999910593033D * vectorDistance; if (yMotion > 0.0D) { motionModifier = (float) (motionModifier * 0.9D); motionY *= 0.8D; } motionX *= motionModifier; motionY *= motionModifier; motionZ *= motionModifier; setPosition(posX, posY, posZ); } } try { if (angler.fishingChore.hasEnded) { setDead(); } } catch (final NullPointerException e) { return; } }
/* 208: */ /* 209: */ public static final String stateToString(int state) /* 210: */ { /* 211:383 */ return AbstractEntity.stateToString(state); /* 212: */ }