/** * Returns the first entity that can act in the specified turn, or null if * none can.33 */ public Entity getFirstEntity(GameTurn turn) { return getEntity(getFirstEntityNum(turn)); }
/** * looks for an entity by id number even if out of the game */ public Entity getEntityFromAllSources(int id) { Entity en = getEntity(id); if(null == en) { for (Entity entity : vOutOfGame) { if(entity.getId() == id) { return entity; } } } return en; }
public void clearTagInfoShots(Entity ae, Coords tc) { for (int i = 0; i < tagInfoForTurn.size(); i++) { TagInfo info = tagInfoForTurn.elementAt(i); Entity attacker = getEntity(info.attackerId); Targetable target = info.target; if (!ae.isEnemyOf(attacker) && isIn8HexRadius(target.getPosition(), tc)) { info.shots = info.priority; tagInfoForTurn.setElementAt(info, i); } } }
/** * Returns the next selectable entity that can act this turn, or null if * none can. * * @param start the index number to start at (not an Entity Id) */ public Entity getNextEntity(int start) { if (entities.size() == 0) { return null; } start = start % entities.size(); int entityId = entities.get(start).getId(); return getEntity(getNextEntityNum(getTurn(), entityId)); }
Entity toRemove = getEntity(id); if (toRemove == null) {
if (posEntities != null) { for (Integer eId : posEntities) { Entity e = getEntity(eId);
public synchronized void setEntity(int id, Entity entity, Vector<UnitLocation> movePath) { final Entity oldEntity = getEntity(id); if (oldEntity == null) { addEntity(entity); } else { entity.setGame(this); entities.set(entities.indexOf(oldEntity), entity); entityIds.put(id, entity); // Get the collection of positions HashSet<Coords> oldPositions = oldEntity.getOccupiedCoords(); // Update position lookup table updateEntityPositionLookup(entity, oldPositions); // Not sure if this really required if (id > lastEntityId) { lastEntityId = id; } processGameEvent( new GameEntityChangeEvent(this, entity, movePath, oldEntity)); } assert (entities.size() == entityIds.size()) : "Set Entity Failed"; }
/** * Determines if the indicated entity is stranded on a transport that can't * move. * <p/> * According to <a href= * "http://www.classicbattletech.com/w3t/showflat.php?Cat=&Board=ask&Number=555466&page=2&view=collapsed&sb=5&o=0&fpart=" * > Randall Bills</a>, the "minimum move" rule allow stranded units to * dismount at the start of the turn. * * @param entity the <code>Entity</code> that may be stranded * @return <code>true</code> if the entity is stranded <code>false</code> * otherwise. */ public boolean isEntityStranded(Entity entity) { // Is the entity being transported? final int transportId = entity.getTransportId(); Entity transport = getEntity(transportId); if ((Entity.NONE != transportId) && (null != transport)) { // aero units don't count here if (transport instanceof Aero) { return false; } // Can that transport unload the unit? if (transport.isImmobile() || (0 == transport.getWalkMP())) { return true; } } return false; }
Entity e = getEntity(eId); if (e == null) { continue;
switch (nType) { case Targetable.TYPE_ENTITY: return getEntity(nID); case Targetable.TYPE_HEX_CLEAR: case Targetable.TYPE_HEX_IGNITE: