Ejemplo n.º 1
0
 public void hitByExplosion(
     CollisionParticipant source, LocalObject obj, DecalManager decal, CollisionEvent ce) {
   if (shield.getVisibility()) {
     // If the shield is visible, we are invincible...
     return;
   }
   Event event = new Event(Event.EXPLOSION_HIT, -99, obj.getObjectID(), obj.getClientID());
   source.getEventQueue().add(event);
 }
Ejemplo n.º 2
0
 public void hitByExplosion(
     CollisionParticipant source, LocalObject obj, DecalManager decal, CollisionEvent ce) {
   if (!isInactive()) {
     Event event = new Event(Event.CRATE_HIT, -99, obj.getObjectID(), -99);
     int[] ids = ce.getPolygonIDs();
     if (ids != null) {
       // The Crates on the bot client don't return those IDs...and
       // they don't have to.
       PolygonManager pm = getPolygonManager();
       SimpleVector normal = pm.getTransformedNormal(ids[0]);
       event.setOrigin(normal);
     }
     source.getEventQueue().add(event);
   }
 }
Ejemplo n.º 3
0
 /**
  * Removes an object from the server's list, i.e. it doesn't exist on the client any longer.
  *
  * @param lo the object to remove
  * @param ci the client info
  */
 public void removeObject(LocalObject lo, ClientInfo ci) {
   LocalObjectList lol = getLocalObjectList(ci);
   boolean ok = lol.remove(lo);
   if (ok) {
     NetLogger.log(
         "Server: Removed an object ("
             + lo.getObjectID()
             + ") of client "
             + ci.getID()
             + "! Client's object count is now: "
             + lol.size());
   } else {
     NetLogger.log("Server: Failed to remove object of client " + ci);
   }
 }
Ejemplo n.º 4
0
 /**
  * Gets a local object stored on the server identified by the clientID and the objectID. The
  * actual client don't know a thing about which local object ID their objects will get on the
  * server which is why they can't transmit them. All they know is, how THEY identify their
  * objects. This method maps between those two worlds.
  *
  * @param objID the objectID
  * @param clientID the clientID
  * @return LocalObject the corresponding local object
  */
 public LocalObject getLocalObjectToIDs(int objID, int clientID) {
   for (Iterator<LocalObjectList> itty = client2LocalObj.values().iterator(); itty.hasNext(); ) {
     LocalObjectList entry = itty.next();
     for (Iterator<LocalObject> itty2 = entry.iterator(); itty2.hasNext(); ) {
       LocalObject lo = itty2.next();
       if (lo.getClientID() == clientID) {
         if (lo.getObjectID() == objID) {
           return lo;
         }
       } else {
         break; // Wrong client!
       }
     }
   }
   return null;
 }