close_lock_container.c

skylib_fluffos_v3/mudlib/std/basic/close_lock_container.c · 1.5 KB

From the archive skylib_fluffos_v3.zip

Download the archive   « Back to the archive contents

/**
 * This file should be used in containers that wish to notify the
 * above container that they are able to be registered or not.
 * The function we_moved(object from, object to) should be called
 * to allow the object to add and remove itself from the correct
 * places.
 * <p>
 * We only worry about the open/close state, if something is open and
 * locked we don't care.  (I guess stuff can be locked open
 * anyway).
 * @author Pinkfish
 * @started Thu Mar  5 16:20:10 CST 1998
 * @see we_moved()
 */
inherit "/std/basic/close_lock";

/** @ignore yes */
void set_closed() {
   ::set_closed();
   if (environment()) {
      environment()->remove_inventory_container(TO);
   }
} /* set_closed() */

/** @ignore yes */
void reset_closed() {
   ::set_closed();
   if (environment()) {
      environment()->add_inventory_container(TO);
   }
} /* reset_closed() */

/**
 * This method should be called when an object is moved.  This will
 * remove itself from the leaving container and add itself to the
 * new one.
 * @param from the object we came from
 * @param to the object we are going to
 */
void we_moved(object from, object to) {
   if (!query_closed()) {
      if (from) {
         from->remove_inventory_container(TO);
      }
      if (to) {
         to->add_inventory_container(TO);
      }
   }
} /* we_moved() */

/** @ignore yes */
void dest_me() {
   /* Please note, this is not designed to kill the object... */
   if (environment()) {
      environment()->remove_inventory_container(TO);
   }
} /* dest_me() */

Site Stats

Snippets: 1791
Codebases: 571