use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.
the class RadioMap method getReceiversInRange.
/**
* Gets a list of all receivers in the range
*
* @param range - range to check inside
* @param excludeList - tiles to ignore
* @return list of receivers, or empty list
*/
public List<IRadioWaveReceiver> getReceiversInRange(Cube range, List excludeList) {
List<IRadioWaveReceiver> receivers = new ArrayList();
receivers.addAll(fullMapRangeReceives);
if (range != null) {
for (IRadioWaveReceiver receiver : receive_to_chunks.keySet()) {
if (receiver != null && (excludeList == null || !excludeList.contains(receiver))) {
Cube receiverRange = receiver.getRadioReceiverRange();
if (receiverRange != null && range.doesOverlap(receiverRange)) {
receivers.add(receiver);
}
}
}
}
return receivers;
}
use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doEntityEffects.
protected void doEntityEffects() {
final float entityRadius = this.getBlastRadius() * 1.5f;
// TODO Cache, recalc on movement only
final Cube cube = new Cube(location.add(0.5).sub(entityRadius), location.add(0.5).add(entityRadius));
final AxisAlignedBB bounds = cube.getAABB();
// Get all entities in the cube area
this.world().getEntitiesWithinAABB(Entity.class, bounds).stream().filter(this::shouldHandleEntity).forEach(this::handleEntities);
}
use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.
the class BlastTNT method pushEntities.
public // TODO convert to delay action
void pushEntities(// TODO convert to delay action
float radius, // TODO convert to delay action
float force, // TODO convert to delay action
PushType type) {
// Step 2: Damage all entities
Pos minCoord = location.toPos();
minCoord = minCoord.add(-radius - 1);
Pos maxCoord = location.toPos();
maxCoord = maxCoord.add(radius + 1);
Cube region = new Cube(minCoord, maxCoord);
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, region.getAABB());
for (Entity entity : entities) {
double var13 = entity.getDistance(location.x(), location.y(), location.z()) / radius;
if (var13 <= 1.0D) {
// Get delta
double xDifference = entity.posX - location.x();
double yDifference = entity.posY - location.y();
double zDifference = entity.posZ - location.z();
// Get magnitude
double mag = MathHelper.sqrt(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
// Normalize difference
xDifference /= mag;
yDifference /= mag;
zDifference /= mag;
if (type == PushType.ATTRACT) {
double modifier = var13 * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(-xDifference * modifier, -yDifference * modifier, -zDifference * modifier);
} else if (type == PushType.REPEL) {
double modifier = (1.0D - var13) * force * (entity instanceof EntityPlayer ? 0.5 : 1);
entity.addVelocity(xDifference * modifier, yDifference * modifier, zDifference * modifier);
}
}
}
}
Aggregations